Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6794453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:13:26+00:00 2026-05-26T18:13:26+00:00

I have developed on EXE project(use for startup task) and use following dlls of

  • 0

I have developed on EXE project(use for startup task) and use following dlls of Microsoft Azure ,

dlls

It’s work very well in .Net framework 3.5 but in my case i need to use system.runtime.serialization to serialize class as json string as per following way

 public static string Serialize<T>(T obj)
        {
            System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new

            System.Runtime.Serialization.Json.DataContractJsonSerializer(obj.GetType());
            MemoryStream ms = new MemoryStream();
            serializer.WriteObject(ms, obj);
            string retVal = Encoding.Default.GetString(ms.ToArray());
            ms.Dispose();
            return retVal;
        }

For this i need to change framework to 4.0 but at that time i got exception from Azure dlls
like

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

I think all Microsoft’s dlls are with backward compatibly so what’s going wrong in this matter?

I should find another way to serialize to json string?
OR
I should to change Azure’s dlls to latest version?

Thanks in Advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:13:27+00:00Added an answer on May 26, 2026 at 6:13 pm

    If you write 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 generated in the default 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a build script (.bat) that invokes MSBUILD ( C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe ) that used
I have some .NET code I use from VB6 code. I have always developed
I have console project. It is developed in VS2010. It uses Mysql.net connector. When
I have developed a website using Razor (Microsoft WebMatrix) and now I want to
I have developed a PHP-MySQL web application, which is a school-based project. My client
I developed a C++ program which utilises an .exe file through the following code:
I have a really simple build script that looks like this: <Project xmlns=http://schemas.microsoft.com/developer/msbuild/2003 ToolsVersion=4.0
We have developed an exe and we have created a website to download that
I have developed a windows application via .NET 3.5 and now I want to
I have an ATL/WTL project developed using Visual Studio 2008 and up until now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.