Today I made a windows Service and encountered a problem during installation.
Problem description
1. It seems that the installation is successful, because this service exists in the service column:
2. But it cannot be started. Point start
System Environment:
Win7, Framework 4
Why?
I haven't tried it for a long time. So, after I call out a previously written windows Service (CareEye), install and start the service:
?
?
Best Practice: Compare the differences between projects. The program does not need to be viewed, mainly in project configuration. I found the problem:
This is a service that can run:
The following is the service configuration that cannot run:
Client Profile. NET Framework
What is the difference between different frameworks? So, let's look at it. This is roughly the case:
The. NET Framework of the Client Profile is a subset that is not added or a lite Version ).
Why should we introduce this simplified version?
Reduces the deployment time of. NET Framework and. NET Framework applications;
Failed to deploy. NET Framework;
Reduce the size of the. NET Framework in the ISV software, so as to provide more space for the software;
Reduce the "interface" of the system where the. NET Framework Client Profile is installed, because the Client Profille contains ASP. NET and the components required by some servers;
Jossef's blog What's new in. NET Framework 4 Client Profile Beta 2 provides a detailed explanation.
The problem is fixed. But all my projects use Framework 4 and must be changed to the Client Profile?
It turns out to be nonsense.
I think twice and cannot modify Framework 4, which is undoubtedly a major version change. All system modules in the Framewok version must be consistent before they can run. The system is running online, which is a big taboo in operation.
However, I would like to look back to the question: According to my previous analysis, Framework 4 cannot create a windows service, but what Client Profile version does it have to be? It's impossible to think about it. I went back and found a problem at the service portal. I didn't notice it during deployment:
Simple Description: I didn't configure the startup parameters when creating the service. Therefore, when the service is started without parameters, it will enter the "background control" type of code. The background control code requires interaction with the desktop, and the default service cannot interact with the desktop, which is certainly a problem. (It doesn't matter if you don't understand it. After all, you don't have to be interested in it ).
You only need to know one thing: because of the general idea of detail processing, it is eager to deploy the service, and ignoring this, it takes more than half a day to find the problem. So it is important to slow down your work.