views:

185

answers:

2

I have a .NET Windows serivce protected with {smartassembly} which works fine, except that I can't get the protected version to install. When I did the testing the service was already installed, then I copied the protected version over the original.

There are some instructions on the {smartassembly} web site regarding Windows services (How to protect Windows services?). I followed suggestion number one, using the CodeProject article (Windows Services Can Install Themselves) to embed the installer into the service. The self-install works fine until the service is protected.

The install log file shows the following error message:

An exception occurred while trying to find the installers in the C:\path-to-service\service.exe assembly. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

I went back to tried removing any protection options that said they could cause problems with reflection. I still got the same error.

Then I tried turning all of the protection options off. Still the same error.

I have sent an email to {smartassembly} support but have not received a response yet. It has only been 24 hours, but I thought someone here on SO might have run into this issue before.

Any ideas?

Edit #1

I know I can write another exe that uses the Windows API to install the service, but I would like to get the built-in install working if possible.

A: 

Self-installers suck. So does Visual Studio "Setup" project. Instead, write a proper installer using WiX.

zvolkov
Self installers and setup projects have their place. I'm tempted to downvote this for the "windows sucks, install linux" approach.
phsr
I am using Inno Setup for the project installer. I am only talking about .NET's ability for Windows services to have embedded installers.
Dana Holt
A: 

Ok, I feel kind of stupid now. I figured out the issue, so maybe it will help someone else who is having the same brain fart.

The protected assembly is written to a different folder than the source assembly, and one of the project's referenced assemblies was missing from that folder. DOH!

Dana Holt