Reputation: 32587
I am in the process of creating an installer for a Windows Service with WIX.
The service is ready to be installed (it has a ServiceInstaller
defined in the project). Therefore, if I install the service using installutil
, it works perfectly.
Trying to create a WIX installer, I created the following component in the product:
<Component ...>
<File Id="ServiceDll" Name="$(var.Scheduler.TargetFileName)" Source="$(var.Scheduler.TargetPath)"/>
<File Id="Connector" Name="Connector.dll" Source="$(var.Scheduler.TargetPath)"/>
<!-- some more dependencies -->
<ServiceInstall Id="InstallService" Name="ScheduleService" Start="auto" Type="ownProcess" ErrorControl="normal"/>
</Component>
Scheduler
is the name of the service project. I added a reference to this project from the wix project. Connector.dll
is a .Net assembly that is copied to the service's output directory because it is referenced. ScheduleService
is the service name.
If I run the installer, the service is successfully installed. However, starting it fails because of an assembly bind error:
The service failed to start. System.IO.FileLoadException. The file or assembly "Connector, Version=1.0.0.0, Culture=neutral, PublickKeyToken=null" or a dependency could not be found. The located assembly's manifest definition does not match the assembly reference (HRESULT: 0x80131040). at ScheduleService.OnStart()
I wondered why there could be a mismatch. So I had a closer look at the files. The files that WIX copys to the install dir actually differ from the source files. The original file size is 11,776 bytes, the copied file size is 12,800 bytes. If I open the dlls in Visual Studio I get different views:
+ Original Connector.dll
+ RT_MANIFEST
1 [neutral]
+ Version
1 [neutral]
and
+ Copied Connector.dll
+ Version
1 [neutral]
So WIX seems to have removed the manifest. If I overwrite the copied DLLs with the original ones, I am again able to start the service. Why does WIX do this? And more importantly, how can I discourage WIX from tampering with the files so the service can be started?
I already cleaned the solution and issued a rebuild, leading to the same scenario.
Upvotes: 0
Views: 216
Reputation: 20772
So WIX seems to have removed the manifest.
That's fine as a literary descriptive device but, of course, that's not what's happening.
My guess that you have multiple build configurations for your Scheduler project. And, you are looking at one build while WiX is grabbing another, which happens to be missing the "native" manifest.
BTW-Don't use multiple File elements in the same Component unless they are inseparable (e.g., in the same .NET assembly, which is rare). See Organizing Applications into Components.
Upvotes: 4