GurdeepS
GurdeepS

Reputation: 67283

Assembly not referenced error in Windows Service

I am designing a windows service and now deploying it.

I have the code:

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

How do I fix this? I'm thinking I need an app config file in my Windows Service?

Upvotes: 1

Views: 3380

Answers (2)

flipdoubt
flipdoubt

Reputation: 14475

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?

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.

Upvotes: 0

Marc Gravell
Marc Gravell

Reputation: 1064204

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

It should already be installed in the GAC of the target machine, so there shouldn't be anything else to do.

Upvotes: 5

Related Questions