【问题标题】:Assembly not referenced error in Windows ServiceWindows 服务中的程序集未引用错误
【发布时间】:2008-11-05 11:54:00
【问题描述】:

我正在设计一个 Windows 服务并正在部署它。

我有代码:

ServiceInstaller serviceInstaller1 = new ServiceInstaller();

这会实例化对象(很明显,但会引发以下编译时错误:

错误 1 ​​类型“System.Configuration.Install.ComponentInstaller”在未引用的程序集中定义。您必须添加对程序集“System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”的引用。 C:\Users\firstname.lastnameDocuments\Visual Studio 20

我该如何解决这个问题?我在想我的 Windows 服务中需要一个应用配置文件?

【问题讨论】:

    标签: c# windows-services


    【解决方案1】:

    在构建时是否在您的开发机器上出现此错误(看起来是这样的)?还是安装时在目标机器上?

    如果是前者:照它说的做:添​​加所需的参考;参考->添加参考->System.Configuration.Install

    它应该已经安装在目标机器的 GAC 中,所以应该没有什么可做的。

    【讨论】:

      【解决方案2】:

      System.Configuration.Install 应该在 GAC 中。它不在那里吗?目标机器是否只有 .NET 1.0 或 1.1?还是 app.config(您说您可能不存在)是否规定应该使用那些较早的 .NET Framework 版本之一?

      啊,它在开发机器上。然后你应该使用 Marc 的答案,只需将 System.Configuration.Install 程序集的引用添加到你的项目中。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多