AX 2009 AIF error: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded

Hello,

When I browse the ‘SalesOrderService.svc’ file in IIS, I get the following error:

Server Error in ‘/MicrosoftDynamicsAXAif50’ Application.


Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load file or assembly ‘microsoft.dynamics.integrationframework.service’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Source Error:

``

<br>Line 57: <add assembly="System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/><br>Line 58: <add assembly="System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/><br>Line 59: <add assembly="*"/><br>Line 60: <add assembly="System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><br>Line 61: <add assembly="System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><br>

Source File: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Config\web.config Line: 59

Assembly Load Trace: The following information can be helpful to determine why the assembly ‘microsoft.dynamics.integrationframework.service’ could not be loaded.

``

<br>Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll<br>Running under executable c:\windows\system32\inetsrv\w3wp.exe<br>--- A detailed error log follows. <br><br>=== Pre-bind state information ===<br>LOG: User = MyDomain\axbc<br>LOG: DisplayName = microsoft.dynamics.integrationframework.service<br> (Partial)<br>LOG: Appbase = file:///C:/Program Files/Microsoft Dynamics AX/50/AifWebServices/<br>LOG: Initial PrivatePath = C:\Program Files\Microsoft Dynamics AX\50\AifWebServices\bin<br>Calling assembly : (Unknown).<br>===<br>LOG: This bind starts in default load context.<br>LOG: Using application configuration file: C:\Program Files\Microsoft Dynamics AX\50\AifWebServices\web.config<br>LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Aspnet.config<br>LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.<br>LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).<br>LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/microsoftdynamicsaxaif50/5f42b57f/8609327f/microsoft.dynamics.integrationframework.service.DLL.<br>LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/microsoftdynamicsaxaif50/5f42b57f/8609327f/microsoft.dynamics.integrationframework.service/microsoft.dynamics.integrationframework.service.DLL.<br>LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Dynamics AX/50/AifWebServices/bin/microsoft.dynamics.integrationframework.service.DLL.<br>ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated.<br><br>

Event Viewer has the following information:

WebHost failed to process a request.
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/25753987
Exception: System.ServiceModel.ServiceActivationException: The service ‘/MicrosoftDynamicsAXAif50/salesorderservice.svc’ cannot be activated due to an exception during compilation. The exception message is: Could not load file or assembly ‘microsoft.dynamics.integrationframework.service’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. (C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Config\web.config line 59). —> System.Configuration.ConfigurationErrorsException: Could not load file or assembly ‘microsoft.dynamics.integrationframework.service’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. (C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Config\web.config line 59) —> System.BadImageFormatException: Could not load file or assembly ‘microsoft.dynamics.integrationframework.service’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: ‘microsoft.dynamics.integrationframework.service’
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
— A detailed error log follows.

=== Pre-bind state information ===
LOG: User = MyDomain\axbc
LOG: DisplayName = microsoft.dynamics.integrationframework.service
(Partial)
LOG: Appbase = file:///C:/Program Files/Microsoft Dynamics AX/50/AifWebServices/
LOG: Initial PrivatePath = C:\Program Files\Microsoft Dynamics AX\50\AifWebServices\bin
Calling assembly : (Unknown).

LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files\Microsoft Dynamics AX\50\AifWebServices\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/microsoftdynamicsaxaif50/5f42b57f/8609327f/microsoft.dynamics.integrationframework.service.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/microsoftdynamicsaxaif50/5f42b57f/8609327f/microsoft.dynamics.integrationframework.service/microsoft.dynamics.integrationframework.service.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Dynamics AX/50/AifWebServices/bin/microsoft.dynamics.integrationframework.service.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated.

— End of inner exception stack trace —
at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
at System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)
at System.Web.Configuration.AssemblyInfo.get_AssemblyInternal()
at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
at System.Web.Compilation.WebDirectoryBatchCompiler…ctor(VirtualDirectory vdir)
at System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors)
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetCompiledCustomString(String virtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.GetCompiledCustomString(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
— End of inner exception stack trace —
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
Process Name: w3wp
Process ID: 7900

Contents of my C:\Program Files\Microsoft Dynamics AX\50\AifWebServices\web.config file:

<?xml version="1.0" encoding="utf-8" ?>

</system.web>

<system.diagnostics>

<system.serviceModel>








schemas.microsoft.com/.../services"](http://schemas.microsoft.com/dynamics/2008/01/services) contract="Microsoft.Dynamics.IntegrationFramework.Service.CustomerService" /> schemas.microsoft.com/.../services"](http://schemas.microsoft.com/dynamics/2008/01/services) contract="Microsoft.Dynamics.IntegrationFramework.Service.AddressService" /> schemas.microsoft.com/.../services"](http://schemas.microsoft.com/dynamics/2008/01/services) contract="Microsoft.Dynamics.IntegrationFramework.Service.SalesOrderService" />

I’ve tried different settings in the highlighted Startup tag to no avail.

Thanks.

Some additional information:

When I click the generate button on the Services form, the following file is created: “C:\Program Files\Microsoft Dynamics AX\50\AifWebServices\Bin\microsoft.dynamics.integrationframework.service.dll”

I used the following PowerShell commands and the result was V4.0.30319

$path = “C:\Program Files\Microsoft Dynamics AX\50\AifWebServices\Bin\microsoft.dynamics.integrationframework.service.dll”
[Reflection.Assembly]::ReflectionOnlyLoadFrom($path).ImageRuntimeVersion

If I run the same PowerShell commands on my production server, I get 2.0.50727.

This proves the error message in my DEV environment that the the assembly is built by a newer runtime.

So, the question becomes – how do I force the 2.0.50727 runtime when I’m generating the DLL?

Any thoughts?

Thanks

We found a solution to this issue

The AOS server’s ax32Serv.exe.config file located in “C:\Program Files\Microsoft Dynamics AX\50\Server<yourInstance>\Bin” had the following entry

Temporarily commenting this out and generating the service produced the DLL with 2.0.50727 CLR version.