开发者

InstallUtil throw error message

Trying to run on W7 64-bits, using .Net 3.5 on Visual C# 2008 Express, I tried running installutil.exe in Framework and Framework64 folder, both throw the same error. 3.5 folder doesn't have installutil.exe and 4.0 in both folders doesn't work too.

In IDE, there is no Release build but Publish, are they the same?

I follow the tutorial from this article: http://www.switchonthecode.com/tutorials/creating-a-simple-windows-service-in-csharp

What could be wrong?

D:\install>C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe setup.e
xe
Microsoft (R) .NET Framework Installation utility Version 2.0.50727.4927
Copyr开发者_C百科ight (c) Microsoft Corporation.  All rights reserved.

Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///D:\inst
all\setup.exe' or one of its dependencies. The module was expected to contain an
 assembly manifest..


The System.BadIMageFormatException normally occurs when you try to load a 64bit assembly or native dll in a 32bit context or vice-versa.

If you are running on a 64bit version of windows there is also a directory c:\windows\Microsoft.Net\Framework64\. Try the installutil that you find in one of the subdirectories there.

Another possible problem is that you are running InstallUtil against the wrong assembly (.exe or .dll). You are running it against setup.exe. In the tutorial that you are referring to there is no explicit setup program. InstallUtil is ran against MyWindowsService.exe. In the tutorial you create a program that uses the System.Configuration.Install namespace. InstallUtil uses the attribute [RunInstaller(true)] from that namespace to find ´installation instructions´ in an assembly, so there is no need for a seperate installer program (setup.exe).

Have you tried following the tutorial to the letter first and then extend it with your own code?


The same problem you get when building windows service in .NET 4 and trying install with installutil.exe from .NET v2 directory. You must use installutil.exe from .NET v4 directory (Windows/Microsoft .NET/Framework/v4.0.30319/installutil.exe)


This is so old, but I still had some trouble doing this nowadays, and other threads like this, with the same answers didn't help me, so I thought this had to be the answer (version conflict).

I was just too dumb to see my error, my path to the .exe file had a space in one of the folders (user name had 2 names separated with space), all I had to do was run the command with the path to .exe file between "" and problem fixed. Just is case someone else runs to this problem like I did.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜