[英]C# : .Net : Code working on Console application . Same code is failing when running on WCF service
I have an application which is using a module A(.net assembly) and module A uses module B(.net assembly) and module B uses module C(C++). 我有一个使用模块A(.net程序集)的应用程序,模块A使用模块B(.net程序集),模块B使用模块C(C ++)。
Since many applications in the server use this, i have registered the managed modules to registry and installed them in GAC. 由于服务器中的许多应用程序都使用此功能,因此我已将托管模块注册到注册表并将其安装在GAC中。
Now i am accessing module A(which does all the job) by below code : 现在我通过以下代码访问模块A(完成所有工作):
Type moduleAType = Type.GetTypeFromProgID("ModuleA.Class1"); 输入moduleAType = Type.GetTypeFromProgID(“ModuleA.Class1”); object class1Object = Activator.CreateInstance(moduleAType);
object class1Object = Activator.CreateInstance(moduleAType);
The above two lines of Code works fine when running as console application. 上面两行代码在作为控制台应用程序运行时工作正常。 But the same code throws an error when i deploy it as WCF service and make a request :
但是,当我将其部署为WCF服务并发出请求时,相同的代码会引发错误:
"Could not load the assembly ModuleB or one of its dependencies". “无法加载程序集ModuleB或其依赖项之一”。
To try fix the above error in WCF service , i copied all the dlls ModuleA , ModuleB and ModuleC to the bin of my service installation folder and now i get the same above error while browsing the service. 为了在WCF服务中尝试修复上述错误,我将所有dll ModuleA,ModuleB和ModuleC复制到我的服务安装文件夹的bin中,现在我在浏览服务时遇到了同样的错误。 I guess some system modules are not being picked up when running as WCF service.
我想有些系统模块在作为WCF服务运行时没有被选中。
I tried using ProcMon to see where Asp.Net is picking up the dlls from , but i was not able to figure it out. 我尝试使用ProcMon来查看Asp.Net从哪里拿起dll,但我无法弄明白。 Any suggestions / help would be very helpfull
任何建议/帮助都会非常有帮助
Note : Both Console App and WCF service run under same user in the same machine. 注意:Console App和WCF服务在同一台计算机上的同一用户下运行。
I somehow made this work for me. 我以某种方式为我做了这项工作。 Hope it helps others by sharing it.
希望通过分享来帮助他人。
I did some logging and found that the running directory of my service is c:\\windows\\system32\\inetsrv and in dependency walker i found most of the dlls(system specific) that my ModuleB depends are in c:\\windows\\system32. 我做了一些日志记录,发现我的服务的运行目录是c:\\ windows \\ system32 \\ inetsrv,在依赖walker中,我发现我的ModuleB所依赖的大多数dll(系统特定的)都在c:\\ windows \\ system32中。
So i created a shortcut to system32(c:\\windows\\system32) folder inside inetsrv(c:\\windows\\system32\\inetsrv) and it started working for me. 所以我在inetsrv(c:\\ windows \\ system32 \\ inetsrv)中创建了system32(c:\\ windows \\ system32)文件夹的快捷方式,它开始为我工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.