Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install windows service

I have created a very simple window service using visual studio 2010 and .NُET 4.0.

This service has no functionality added from the default windows service project, other than an installer has been added.

If I run "installutil.exe appName.exe" on my dev box or other windows 2008 R2 machines in our domain the windows service installs without issue.

When I try to do this same thing on our customer site, it fails to install with the following error.

Microsoft (R) .NET Framework Installation utility Version 4.0.30319.1 Copyright (c) Microsoft Corporation.  All rights reserved.  Exception occurred while initializing the installation: System.IO.FileLoadException: Could not load file or assembly 'file:///C:\TestService\WindowsService1.exe' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515). 

This solution has only 1 project and no dependencies added.

I have tried it on multiple machines in our environment and two in our customers. The machines are all windows 2008 R2, both fresh installs. One machine has just .net 2.0 and .net 4.0. The other .net 2, 3, 3.5 and 4.

I am a local admin on each of the machines.

I have also tried the 64bit installer but get the following error, so I think the 32 bit one is the one to use. System.BadImageFormatException

Any guidance would be appreciated. Thanks.

like image 871
Matthew Dalton Avatar asked Nov 10 '10 09:11

Matthew Dalton


People also ask

How do I install Windows Service Installer?

With the designer in focus, right-click, and then click Add Installer. A new class, ProjectInstaller , and two installation components, ServiceProcessInstaller and ServiceInstaller, are added to your project, and property values for the service are copied to the components.


1 Answers

Another reason for this error might be that you copied your program from a source which windows considers untrusted. You can unblock the assembly by clicking "unblock" after you right-click and select properties on the file.

like image 80
doublehelix Avatar answered Oct 20 '22 06:10

doublehelix