In Dotnet 4.0 "Mixed mode assembly is built against version 'v2.0.50727'.... " issue in custom config file (rename app.config) file RRS feed

  • Question

  • Hi,

    My Winform applilcation has used Microsoft.SqlServer.Management.Common namespace(assembly :Microsoft.Sqlserver.smo.dll/Microsoft.Sqlserver.ConnectionInfo.dll) and developed in .NET 4.0.

    Problem:Application is throw an exception when it tries to use above assembly reference methods. Full error text is shown below,

    "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. "

    Error is resolved when we include "app.config" file with below code,

    <?xml version="1.0"?>
    <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

    But, I need to keep configuration file as "renamed.config" and not to include app.config file as of the project requirement.I have set configuration file as "renamed.config" file using below code,

    //AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", "d:\\reanmed.config" );

    I have also included <Startup> element in this "renamed.config" configuration file and removed the app.config file.But it raise me below error, it always expect app.config file with <Startup> element to resolve this issue.

    so, If anyone have an idea for this issue resolution then please share.

    Thank you,

    Dhaval Soni

    Friday, August 13, 2010 8:06 AM

All replies

  • Hi,

    Thanks for your post. So the question is indeed how to bind to a custom config file.Your code  seems fine. But note that the binding of a config file happens once and we need to make sure it happens before it is used for the first time. This article addressed that.

    As an alternative, we could reference a external config file in the App.config. This article addressed that.

    I hope the above info could be helpful.

    Please mark the right answer at right time.
    Monday, August 16, 2010 3:30 AM
  • I have included configuration file setting code at program.cs - Main() - at first line. I think it should be fine.


    Mainly, "<startup useLegacyV2RuntimeActivationPolicy="true">" is not worked when we dont' include app.config file.


    It always expect app.config file.  But, As per requirement, I need to use custom.config file and not to include app.config file.


    Please let me know if you have an idea.

    Tuesday, August 17, 2010 12:13 PM