I am designing a windows service and now deploying it.
我正在设计一个Windows服务,现在正在部署它。
I have the code:
我有代码:
ServiceInstaller serviceInstaller1 = new ServiceInstaller();
ServiceInstaller serviceInstaller1 = new ServiceInstaller();
This instantiates the object (obviously, but throws the following compile-time error:
这实例化了对象(显然,但会引发以下编译时错误:
Error 1 The type 'System.Configuration.Install.ComponentInstaller' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. C:\Users\firstname.lastnameDocuments\Visual Studio 20
错误1类型'System.Configuration.Install.ComponentInstaller'在未引用的程序集中定义。您必须添加对程序集'System.Configuration.Install,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'的引用。 C:\ Users \ firstname.lastnameDocuments \ Visual Studio 20
How do I fix this? I'm thinking I need an app config file in my Windows Service?
我该如何解决?我想我的Windows服务中需要一个app配置文件?
2 个解决方案
#1
5
Is this error on your dev machine when building (which is what it looks like)? Or on the target machine when installing?
构建时你的开发机器上有这个错误(它看起来像什么)?或者在安装时在目标机器上?
If the former: do what it says: add the required reference; References->Add Reference->System.Configuration.Install
如果是前者:按照说法做:添加所需的参考;参考 - >添加参考 - > System.Configuration.Install
It should already be installed in the GAC of the target machine, so there shouldn't be anything else to do.
它应该已经安装在目标机器的GAC中,因此不应该做任何其他事情。
#2
0
System.Configuration.Install should be in the GAC. Is it not there? Does the target machine only have .NET 1.0 or 1.1? Or does the app.config (which you say you might not have present) stipulate one of those earlier .NET Framework versions should be used?
System.Configuration.Install应该在GAC中。不存在吗?目标计算机只有.NET 1.0或1.1吗?或者app.config(你说你可能没有)会规定应该使用其中一个早期的.NET Framework版本吗?
Ah, it is on the dev machine. Then you should go with Marc's answer and just add a reference to the System.Configuration.Install assembly to your project.
啊,它是在开发机器上。然后你应该使用Marc的答案,只需将System.Configuration.Install程序集的引用添加到项目中。
#1
5
Is this error on your dev machine when building (which is what it looks like)? Or on the target machine when installing?
构建时你的开发机器上有这个错误(它看起来像什么)?或者在安装时在目标机器上?
If the former: do what it says: add the required reference; References->Add Reference->System.Configuration.Install
如果是前者:按照说法做:添加所需的参考;参考 - >添加参考 - > System.Configuration.Install
It should already be installed in the GAC of the target machine, so there shouldn't be anything else to do.
它应该已经安装在目标机器的GAC中,因此不应该做任何其他事情。
#2
0
System.Configuration.Install should be in the GAC. Is it not there? Does the target machine only have .NET 1.0 or 1.1? Or does the app.config (which you say you might not have present) stipulate one of those earlier .NET Framework versions should be used?
System.Configuration.Install应该在GAC中。不存在吗?目标计算机只有.NET 1.0或1.1吗?或者app.config(你说你可能没有)会规定应该使用其中一个早期的.NET Framework版本吗?
Ah, it is on the dev machine. Then you should go with Marc's answer and just add a reference to the System.Configuration.Install assembly to your project.
啊,它是在开发机器上。然后你应该使用Marc的答案,只需将System.Configuration.Install程序集的引用添加到项目中。