WCF 服务作为 Windows 服务的问题 (Windows 7)

发布于 2024-09-29 03:55:11 字数 878 浏览 4 评论 0原文

我按照此处的步骤制作我现有的 WCF 服务(作为控制台应用程序已经可以正常工作),在我的 Windows 7 计算机(也是我的开发计算机)上也可以是 Windows 服务。

无论我尝试什么,在执行使用 installutil 的最后一步时,我都会在命令行中收到以下消息:

初始化安装时发生异常:
System.BadImageFormatException:无法加载文件或程序集“file:///[此处的路径]”或其依赖项之一。
尝试加载格式不正确的程序..

我的控制台应用程序主类继承自 ServiceBase 并实现 OnStartOnEnd方法。

我添加了从 System.Configuration.Install.Installer 继承的 ProjectInstaller 类,标记有 [RunInstaller(true)] 属性以及它们提供的代码在构造函数中。

我已经尝试过的内容在上面的文章中没有提到?

  1. 以管理员身份运行命令
  2. 行导航到 EXE 文件所在的目录并运行 installutil 为
  3. EXE 文件及其使用的所有 DLL 提供强密钥

另外,即使使用 /LogFile=myLog.txt 指定它,我也没有得到任何日志文件。

欢迎任何想法,谢谢。

I followed the steps here to make my existing WCF service (already working fine as console application) be Windows Service as well, on my Windows 7 machine which is also my development machine.

No matter what I tried, when doing the last step of using installutil, I'm getting the following message in the command line:

Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///[path here]' or one of its dependencies.
An attempt was made to load a program with an incorrect format..

I have my console application main class inherit from ServiceBase and implement OnStart and OnEnd methods.

I have added ProjectInstaller class inheriting from System.Configuration.Install.Installer marked with [RunInstaller(true)] attribute and with the code they supplied in the constructor.

What I already tried that is not mentioned in the above article?

  1. Running the command line as administrator
  2. Navigating to the directory where the EXE file is located and running
    installutil from there
  3. Giving strong key to the EXE file and all DLL's it's using

Also, I don't get any log file even when specifying it with /LogFile=myLog.txt.

Any ideas are welcome, thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

始终不够爱げ你 2024-10-06 03:55:11

这听起来像是 32 位/64 位问题。

您的机器是 64 位 Windows 7 吗?您的服务是否以某种方式引用了 32 位的内容,例如旧的 COM 组件或其他内容?

您可能需要在 Visual Studio 中使用 x86 平台编译您的内容才能使其正常工作...

That smells like a 32-/64-bit problem.

Is your machine 64-bit Windows 7 by any chance?? Does your service somehow reference something 32-bit , like an old COM component or something??

You might need to compile your stuff with the x86 platform in Visual Studio to get it to work properly...

烟若柳尘 2024-10-06 03:55:11

BadImageFormat 异常通常在旧版本的 .NET 框架(没有 4.0 的计算机上的 4.0 程序集)中加载程序集时发生。由于您在同一台计算机上进行部署,我的猜测是您没有使用正确版本的 installutil。

确保您使用位于此处的 installutil:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319

BadImageFormat exceptions usually occur when the assembly is loaded in an older version of the .NET framework (4.0 assembly on a machine without 4.0). Since you are deploying on the same machine, my guess would be that you are not using the correct version of installutil.

Make sure you use the installutil located here : C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文