FileLoadException during activation of WCF service

2

After deploying my WCF service in IIS, I get this error when accessing the service:

Server Error in '/MyService' Application.

The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[FileLoadException: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)]
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +153 System.Type.GetType(String typeName) +89 System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +936
System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +76
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +901

[ServiceActivationException: The service '/MyService/MySvcImpl.svc' cannot be activated due to an exception during compilation. The exception message is: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047).]
System.Runtime.AsyncResult.End(IAsyncResult result) +650220
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +210733
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +166

I turned on the Assembly Binding Log Viewer (FUSLOGVW.EXE), but it does not show me any binding failures. Anyone any idea what could cause this, or how to debug this?

wcf
iis
activation
fileloadexception
asked on Stack Overflow Apr 20, 2013 by MvdD • edited Apr 20, 2013 by MvdD

2 Answers

2

Found the issue! Posting here as it may help someone someday.

My web.config contains a service activation element with a factory attribute like this:

<serviceHostingEnvironment>
  <serviceActivations>
    <add relativeAddress="MyService.SvcImpl.svc" 
         service="MyService.SvcImpl" 
         factory="MyCompany.MyServiceHostFactory, MyCompany.MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=" />
  </serviceActivations>
</serviceHostingEnvironment>

The factory attribute contains a class reference from a strongly named assembly. However, the PublicKeyToken atribute was supposed to be set by the build system to the correct value, depending on whether a test signing cert or the official signing cert was used. The build step somehow failed and left the strong name of the assembly invalid. So, the first part of the message in the exception was pretty acurate. It just did not tell me which assembly could not be loaded. Nor was FUSLOGVW.EXE any helpful here.

answered on Stack Overflow Apr 20, 2013 by MvdD
0

I have the same problem when I tried to reference a file in this location 'AppCode/Authentication' but when I changed the name of the folder to 'App_Code/Authentication' the problem was resolved.

answered on Stack Overflow Dec 10, 2019 by Abdelwahid Oubaalla

User contributions licensed under CC BY-SA 3.0