none
Common Language Runtime error after upgradation to .NET 4.6.2

    Question

  • Very recently, our application was upgraded from .NET FW 4.5.2 to .NET FW 4.6.2. The application is a web application with 2 solutions, the front end solution which is hosted on IIS and the Services solution which has third-party integrations as well as ADO.NET overridden methods.

    The application uses as WCF services installed as a Windows service to connect the 2 solutions for synchronous calls.

    Now, when we upgraded our framework to 4.6.2 the service did not start. We got the following error -

    Log Name:      Application
    Source:        NameofWindowsService
    Date:          11/17/2016 7:03:29 AM
    Event ID:      2055
    Task Category: None
    Level:         Error
    Keywords:      Classic
    User:          N/A
    Computer:      ComputerName
    Description:
    Web Service Engine NameofWindowsService' failed to start.
    Common Language Runtime detected an invalid program.
       at System.ServiceModel.Dispatcher.DispatchRuntime..ctor(SharedRuntimeState shared)
       at System.ServiceModel.Dispatcher.DispatchRuntime..ctor(EndpointDispatcher endpointDispatcher)
       at System.ServiceModel.Dispatcher.EndpointDispatcher..ctor(EndpointAddress address, String contractName, String contractNamespace, Boolean isSystemEndpoint)
       at System.ServiceModel.Description.DispatcherBuilder.BuildDispatcher(ServiceHostBase service, ServiceDescription serviceDescription, ServiceEndpoint endpoint, ContractDescription contractDescription, EndpointFilterProvider provider)
       at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
       at System.ServiceModel.ServiceHostBase.InitializeRuntime()
       at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at NameofWindowsService.OnStart(String[] args) in PathOfFile:line 101
    Event Xml:
    <Event xmlns="link text modified due to msdn rules">
      <System>
        <Provider Name="NameofWindowsService" />
        <EventID Qualifiers="0">2055</EventID>
        <Level>2</Level>
        <Task>0</Task>
        <Keywords>0x80000000000000</Keywords>
        <TimeCreated SystemTime="2016-11-17T12:03:29.000000000Z" />
        <EventRecordID>143974</EventRecordID>
        <Channel>Application</Channel>
        <Computer>ComputerName</Computer>
        <Security />
      </System>
      <EventData>
        <Data>Web Service Engine 'COP WebService Engine Service(PROD01)' failed to start.
    Common Language Runtime detected an invalid program.
       at System.ServiceModel.Dispatcher.DispatchRuntime..ctor(SharedRuntimeState shared)
       at System.ServiceModel.Dispatcher.DispatchRuntime..ctor(EndpointDispatcher endpointDispatcher)
       at System.ServiceModel.Dispatcher.EndpointDispatcher..ctor(EndpointAddress address, String contractName, String contractNamespace, Boolean isSystemEndpoint)
       at System.ServiceModel.Description.DispatcherBuilder.BuildDispatcher(ServiceHostBase service, ServiceDescription serviceDescription, ServiceEndpoint endpoint, ContractDescription contractDescription, EndpointFilterProvider provider)
       at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
       at System.ServiceModel.ServiceHostBase.InitializeRuntime()
       at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at NameofWindowsService.OnStart(String[] args) in PathOfFile:line 101</Data>
      </EventData></Event>

    The code which threw this exception -

    ServiceHost serviceHost = new ServiceHost(serviceHostData.Type);

    serviceHost.Open();

    We got this error on production in 4 out of 6 servers. We have no idea why this worked on 2 servers but that saved us major embarrassment. We tried everthing - reinstalling the FW, repairing the FW, clearing temporary files etc but what worked was updating the service config with the following code -

    <configuration>
      <runtime>
        <useLegacyJit enabled="1" />
      </runtime>
    </configuration>

    I hope this helps someone who is facing the same issue but I have questions -

    1. Microsoft has mentioned that with the 4.6.2 release these issues would be fixed but it seems they missed this one. Can we expect a hotfix?

    2. What is the impact of making this change?

    3. Can a dll compiled in the new JIT compiler be referenced by this service which was compiled with the legacy compiler? New third party assemblies might be available to us soon and we want to be sure.

    Any help is appreciated.

    Friday, November 18, 2016 2:36 PM

Answers

All replies