C# – WCF service unable to load referenced assemblies from the GAC

ciisnetvisual studiowcf

I've got a WCF service, hosted in IIS, which is built in Visual Studio. The WCF service library references a few other assemblies, which are part of the same Visual Studio solution.

I deploy all the assemblies to the GAC, then start a service client, and see it fail trying to resolve one of the referenced client assemblies. I've added a breakpoint in the WCF service contructor, and it appears to not try to load its referenced assemblies using qualified names (and thus not find them in the GAC). If I run an Assembly.Load in the immediate window, once breaked into the WCF contructor, within IIS, I'm able to load each of the missing dlls using qualified (publickeytoken and such) names.

Why does the CLR, or my service library, attempt to load the libraries using names only?

Best Answer

Try updating the IIS web app web.config that with the following

<compilation debug="true">
      <assemblies>
        <add assembly="MyWcfAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=AAAAAAAAAA"/>

From my experience this is needed sometimes when the dll isn't copied local and needs to be read from the GAC.

You also need to reload your app domain for your web page to use the latest assembly installed into your GAC. You can reload your app domain by doing an iisreset, touching the web.config or iis manager.