How to set a specific RUNTIME for a library?

I have used Visual Sturdio 2003 to create a DLL compativle with COM and I want that dll to run in .net 1.1 even if .net 2.0 is installed.
Can I set this property in anyway to my library or it will always run with the las .net installed in the machine


Answer this question

How to set a specific RUNTIME for a library?

  • CJWalsh



  • Craig Westlake

    If you a have 1.1 .NET assembly generated with VS 2003 and it's called via COM from unmanaged code, the default behavior is that Windows will run it with the latest runtime on the system, so your COM assembly will run in a 2.0 framework.

    Another scenario is when an app built with VS 2005 is running with the 2.0 framework and it was built with a reference to your 1.1 assembly. Your assembly will run in the 2.0 framework because that's the one that was loaded into the 2.0 app.

    So there are at least two scenarios where a 1.1 Dll assembly can end up running in the 2.0 framework.



  • Chrispwill

    Hi,

    I would like to know is there any final solution after the debate It seems that it still can't be done.



  • Polishchuk Maxim

    MSDN says:

    The startup code for an application hosted in Microsoft Internet Explorer ignores the <requiredRuntime> element.

    So this is still an issue sometimes.



  • Francesco75

    Sorry for trouble you again,

    Do you know if this feature about configuring the run time is available for a DLL that is accessed as a COM object
    I have tried creating that config file MyDll.dll.config and placing it in the same folder than my dll (it is not necessary registering it, or doing something else ) and it is still not working because still uses the 2.0 although the config file tells it to run under the 1.1!!!!

    Do you know if there is 2.0 installed on the machine Visual Studio 2003 uses 1.1 to build

  • CStacker

    Only if you can install a config file for your client programs with this in it, below. This works for unmanaged clients too, it's not just for managed code.

    <configuration>
    <startup>
    <requiredRuntime version="v1.1.4322" />
    </startup>
    </configuration>



  • Sean Feldman

    Now everything fits.
    But there is anyway to change this behaviour and make my 1.1 .NET assembly ,generated with VS 2003 and called via COM from unmanaged code, run on 1.1

  • Dave987654321

    You may force runtime version in config file (see "How to: Use an Application Configuration File to Target a .NET Framework Version" in MSDN):

    <configuration>
      <startup>
       <supportedRuntime version="v1.1.4322"/>
       <supportedRuntime version="v1.0.3705"/>
      </startup>
    </configuration>


  • Robert Shurbet

    Hi!

    If you compile assembly under 1.1 it will always run under 1.1.

    2.0 runtime will run only 2.0 compiled versions.

    .NET will always try to match versions of runtime/assembly.

    But, if you can - recompile under 2.0. This will make less requirements on user's machines - no need to have 1.1 installed and less memory required.



  • Kirk Brote

    I'm afraid that is not 100% true.
    I have created and assembly ( a library) on Visual Studio 2003, which means that has been compiled for 1.1. Correct
    Then I have run that assembly on my machine that has both 2.0 and 1.1 installed and it fails (this is due a bug on 2.0 when using smart cards to sign), then I uninstall 2.0 and it works. That means that the assembly runs in the last version available on the machine.
    I'm right or there is something wrong in my reasoning

  • zisha

    2003 will use 1.1 or 1.0 (depend on project settings), but it never works with .NET 2.0.

    I don't think all assemblies must be registered. Perhabs you may try some configurations wizards that .NET install in Administrative Tools menu



  • How to set a specific RUNTIME for a library?