System.ServiceModel.ServiceActivationException , The CLR Type could not be loaded during service compilation (Error is not happening on all machines

1.3k views Asked by At

enter image description hereI recently upgraded my solution from .netframework 4 to 4.7.2 ( It was in VS 2010 and I upgraded it using VS2019) . The solution contains WCF Services and some class library and a mvc 3 website . I had not have issue running my website and it worked without issue . However my other colleagues who got my changes having the following error. The also recently installed VS 2019 and it is strange that I do not have issue but other have, The error is below:

Exception Type: System.ServiceModel.ServiceActivationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Message: The service '/Reporting/ReportingService.svc' cannot be activated due to an exception during compilation. The exception message is: The CLR Type 'X.Services.Reporting.WebService.ServiceBehaviours.ReportingServiceHostFactory' could not be loaded during service compilation. Verify that this type is either defined in a source file located in the application's \App_Code directory, contained in a compiled assembly located in the application's \bin directory, or present in an assembly installed in the Global Assembly Cache. Note that the type name is case-sensitive and that the directories such as \App_Code and \bin must be located in the application's root directory and cannot be nested in subdirectories.

Stack Trace: System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath, EventTraceActivity eventTraceActivity) System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest() System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest() System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state) System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

This makes me think there might be something that I have on my machine and others don't. Any suggestion would be much appreciated.

please note I do not directly use servicehostfactory

public class ReportingServiceHostFactory : UnityServiceHostFactory {....}

This is how my svc file is <%@ ServiceHost Language="C#" Debug="true" Service="X.Services.Reporting.WebService.RepotingService" Factory="X.Services.Reporting.WebService.ServiceBehaviours.ReportingServiceHostFactory"%>

Any help would be much appreciated!

Thanks,

1

There are 1 answers

0
user464291 On

I found out what the issue is. The issue is the platform after changing the platform from x86 to AnyCPU in all my projects the issue is fixed. I think the reason is that with x86 platform the debug folder is nested in X*^ folder and that caused the isssue