问题
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