WCF: Could not load file or assembly … the system cannot find the file specified

你离开我真会死。 提交于 2019-12-11 09:51:07

问题


I've got a WCF Service hosted in IIS 6/7. I tried different things with the .svc file, but I can't get it to work. I always get a FileNotFoundException "Could not load file or assembly 'X.Y.Z' or one of its depencies. The system cannot find the file specified."

The assembly is in the bin folder, not in the GAC. But X.Y.Z is the namespace and classname, so the server is looking for the wrong assembly filename. The Assembly Load Trace confirms, that it's looking for an X.Y.Z.DLL in various places, but that namespace and classname ... X.Y.DLL would be the assembly.

I tried the svc, Visual Studio 2010 generated and I modified it to contain only the fully qualified name

<%@ ServiceHost Service="X.Y.Z, X.Y, Version=1.0.2.0, Culture=neutral, PublicKeyToken=xxxxx" %>

回答1:


Use the assembly bind log viewer to see the locations that the clr is looking at for the requested assembly - http://msdn.microsoft.com/en-us/library/e74a18c4(v=VS.100).aspx




回答2:


The error msg might be misleading. Try to create a test page in the same project and create an instance of the service class from the type name. When you navigate to this test page, it should give the right error message about what assemblies it's not able to find. You can use the following code, e.g.



    Type serviceType = Type.GetType("X.Y.Z, X.Y, Version=1.0.2.0, Culture=neutral, PublicKeyToken=xxxxx");
var serviceInstance = Activator.CreateInstance(serviceType);
Response.Write(serviceInstance);



回答3:


Does this WCF has any third party libraries referring, which demand Applicatin Pool to be either 32-bit version or 64-bit version? Verify AppPool set to classic, integrated as appropriately



来源:https://stackoverflow.com/questions/6993563/wcf-could-not-load-file-or-assembly-the-system-cannot-find-the-file-specifi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!