haughtonomous
haughtonomous

Reputation: 4850

Service cannot find referenced DLLs

I have a C# service app that references a dll ('A') that in turn reference other dlls ('B' and 'C', say). The service project references all the necessary dlls.

The entry code calls a method in 'A' that calls methods in 'B' or 'C'. We are getting a custom error message from 'A' that says that 'B' and 'C' cannot be found, in spite of them being in the same folder as the service, and we know that this indicates that the process working folder is incorrect (ie the process thinks the working folder is elsewhere).

The question is: how can I explicitly tell the service what the working folder is?

TIA

Upvotes: 1

Views: 1809

Answers (2)

haughtonomous
haughtonomous

Reputation: 4850

The key turns out to be that I have to fool the service to think the working folder is where the service executable is located, which I can now easily do in code, thanks to some of the links above.

Upvotes: 1

Shaz
Shaz

Reputation: 1396

Services run in System32.

If you copy B.dll and C.dll into your System32 folder, it'll probably work.

To fix it, you should create an installer project in your solution. The installer will handle installing all of the necessary .dlls in the right place.

Here's a SO example

Edit #1:

This post has the last piece of the puzzle. Dlls have to be added to the setup project separately from the original project.

Upvotes: 3

Related Questions