Windows服务中的程序集未引用错误

Gur*_*epS 1 c# windows-services

我正在设计一个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服务中需要一个app配置文件?

Mar*_*ell 5

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

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

它应该已经安装在目标机器的GAC中,因此不应该做任何其他事情.