简体   繁体   中英

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

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.

关键在于,我必须欺骗服务以认为工作文件夹是服务可执行文件所在的位置,由于上面的某些链接,现在我可以轻松地用代码来完成工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM