I've been trying to work out why my C# Windows service won't install and it seems to be being caused by including Entity Framework.
To test this, I created a new project using the Windows Service template in Visual Studio and just let the wizard do its thing.
Deployed to my test server, installed and everything worked as expected... I then uninstalled.
Next, I added (DB First) Entity Framework model to the project, again something very basic and deployed to server..
This time, when I install, I get the following..
Microsoft (R) .NET Framework Installation utility Version 4.0.30319.17929 Copyright (C) Microsoft Corporation. All rights reserved.
Running a transacted installation.
Beginning the Install phase of the installation. See the contents of the log file for the D:\SandBox\TestService\TestService.exe assembly's progress. The file is located at D:\SandBox\TestService\TestService.InstallLog. Installing assembly 'D:\SandBox\TestService\TestService.exe'. Affected parameters are:
logtoconsole = logfile = D:\SandBox\TestService\TestService.InstallLog assemblypath = D:\SandBox\TestService\TestService.exe An exception occurred while trying to find the installers in the D:\SandBox\TestService\TestService.exe assembly. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Aborting installation for D:\SandBox\TestService\TestService.exe.An exception occurred during the Install phase. System.InvalidOperationException: Unable to get installer types in the D:\SandBox\TestService\TestService.exe assembly. The inner exception System.Reflection.ReflectionTypeLoadException was thrown with the following error message: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information..
The Rollback phase of the installation is beginning. See the contents of the log file for the D:\SandBox\TestService\TestService.exe assembly's progress. The file is located at D:\SandBox\TestService\TestService.InstallLog. Rolling back assembly 'D:\SandBox\TestService\TestService.exe'. Affected parameters are:
logtoconsole = logfile = D:\SandBox\TestService\TestService.InstallLog assemblypath = D:\SandBox\TestService\TestService.exe An exception occurred while trying to find the installers in the D:\SandBox\TestService\TestService.exe assembly. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Aborting installation for D:\SandBox\TestService\TestService.exe. An exception occurred during the Rollback phase of the System.Configuration.Install.AssemblyInstaller installer. System.InvalidOperationException: Unable to get installer types in the D:\SandBox\TestService\TestService.exe assembly. The inner exception System.Reflection.ReflectionTypeLoadException was thrown with the following error message: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.. An exception occurred during the Rollback phase of the installation. This exception will be ignored and the rollback will continue. However, the machine might not fully revert to its initial state after the rollback is complete.The Rollback phase completed successfully.
The transacted install has completed. The installation failed, and the rollback has been performed.
When the service was deployed, I copied the EntityFramework.dll and EntityFramework.SqlServer.dll with the exe and config files and are all in the same folder.
So, what explicitly is InstallUtil complaining about. How can I find out
FYI: "Works on my machine" as per any developer problem
EDIT:
References to this SO question Error message 'Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.' are when something goes wrong during RUNTIME ... My specific issue is during INSTALL
Well, I have managed to resolve/work around the problem.
Rather than have the EF model within the service application, I hived it off into its own class library and then just added that as a reference and voilà, install successful.