InstallUtil抛出错误消息

Pro*_*yb2 1 c#

尝试在Visual C#2008 Express上使用.Net 3.5在W7 64位上运行,我尝试在Framework和Framework64文件夹中运行installutil.exe,两者均引发相同的错误。3.5文件夹没有installutil.exe,两个文件夹中的4.0也不起作用。

在IDE中,除了发布之外没有发布版本,它们是一样的吗?

我遵循本文中的教程:http : //www.switchonthecode.com/tutorials/creating-a-simple-windows-service-in-csharp

有什么事吗

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
Copyright (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..
Run Code Online (Sandbox Code Playgroud)

Jer*_*ink 5

System.BadIMageFormatException当您尝试在32位环境中加载64位程序集或本机dll时,通常会发生这种情况,反之亦然。

如果您在64位版本的Windows上运行,则还有一个目录c:\windows\Microsoft.Net\Framework64\。尝试在其中一个子目录中找到的installutil。

另一个可能的问题是,您对错误的程序集(.exe或.dll)运行InstallUtil。您正在针对setup.exe运行它。在您所参考的教程中,没有明确的安装程序。InstallUtil遭到攻击MyWindowsService.exe。在本教程中,您将创建一个使用System.Configuration.Install名称空间的程序。InstallUtil使用该[RunInstaller(true)]名称空间中的属性在程序集中查找“安装说明”,因此不需要单独的安装程序(setup.exe)。

您是否尝试过首先按照本教程进行操作,然后再使用自己的代码对其进行扩展?