Reuse Windows Service classes
I have a ASP Net project of the type Windows Service.
When I build that project an exe file is generated.
Now I also have another project os the type Web Service, that uses开发者_如何转开发 classes from the previous Windows Service project.
When I build the Web Service, on it's bin/debug folder, the Windows Service exe is there, instead of a DLL.
This way, when I deploy the Web Service on ISS, I get an exception when the part of the code that instatiates a class on the Windows Service project is executed.
The only whay I found to solve this issue, is to make the output type of the Windows Service to DLL instead of EXE, and the Web Service runs correctly.
But, of course, when I try to install the Windows Service, I get this error:
Can I even do this?
Windows Services and web services are different project types. You cannot run the same executable. You have to options:
- Either you put the common code into a class library and create a project for the windows service and one for the webservice
- You create to build targets.
Option 1 seems to be easier for me
精彩评论