Tuesday, May 31, 2011

Console Application fails on Windows Azure

Last week I was trying to add a console application as a startup task to a Windows Azure project. However each time the startup task was executed it failed with the following error

“Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.”

It took me some time to figure out that the issue was caused by the Microsoft.WindowsAzure.ServiceRuntime dll which is a mixed mode assembly. When I  commented out some code and removed this DLL reference, everything worked.

So what can you do to solve this error?

  • Option 1: Compile your application against the .NET 3.5 framework instead of .NET 4.0.
  • Option 2: Add a "useLegacyV2RuntimeActivationPolicy" to the startup tag generated in the default app.config:
<startup useLegacyV2RuntimeActivationPolicy="true">

The useLegacyV2RuntimeActivationPolicy attribute is required for referencing any mixed mode assembly.

No comments: