Using Windows Azure RoleEnvironment in a console app in .NET4

If you are writing a console app in .NET4 and want to use the RoleEnvironment then you’ll get an error:

The type initializer for ‘Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment’ threw an exception.

To get around this, just add a “useLegacyV2RuntimeActivationPolicy” to the startup tag in your app.config:

<startup useLegacyV2RuntimeActivationPolicy=”true”>

 This is because Microsoft.WindowsAzure.ServiceRuntime.dll is a mixed mode assembly. The useLegacyV2RuntimeActivationPolicy attribute is required for referencing any mixed mode assembly, not only the Windows Azure ones.

Pingbacks and trackbacks (1)+

Comments are closed

Hi there !

 

Specialized in .net technologies for many years, I am a technology fan in both asp.net and wpf/silverlight, using c# and .net 4.

Taking advantages of new opportunities offered by the Windows Azure platform and WP7, I develop applications for Windows 7 Phone, 2 of them are already available on the market place.


 

 

Month List