gpt4 book ai didi

c# - 启动 Windows 服务时无法找到程序集文件 'example.dll'

转载 作者:可可西里 更新时间:2023-11-01 10:07:58 32 4
gpt4 key购买 nike

我开发了一个 WCF 服务,它使用 net.tcp 绑定(bind)和读取写入 文件到文件系统。当我启动 Windows 服务(在控制台中)时,即使 sample.dll 在文件夹中,我也会收到以下错误:

无法找到程序集文件 sample.dll

此特定 WCF 服务托管在 Windows 7 64 位上运行的 Windows 服务中,我有以下问题:

我应该为我的应用程序使用哪个帐户:

用户/网络服务/本地系统/本地服务

为什么操作系统不能加载 dll,即使它存在?

预先感谢您的帮助!

最佳答案

对于 dll,您应该在 OnStart 方法的开头添加以下代码行。

 System.Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory

这应该允许您的服务从实际目录加载 dll。

关于c# - 启动 Windows 服务时无法找到程序集文件 'example.dll',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10754189/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com