locked
Adding assembly references at runtime RRS feed

  • Question

  • Hi friends,

    Can we add (not assembly.load()) assembly references at runtime?

    Case:

    I’m trying to develop an application which supports for both Frameworks (fw) 3.5 and 4.0. 

     1. On before application initialization, found the client machine fw 3.5 or 4.0 

     2. Based on step1 add system references dynamically to my application. For example if client machine have 3.5 we should add only fw 3.5 relevant references and same for fw 4.0 - is this possible????

    Correct me if am wrong.

    Thanks,

    Nagarajan Govindarajan.

     

    Wednesday, September 1, 2010 10:19 AM

Answers

  • Hi,

    Thanks for your post. Just a quick reflection, if what you said can be done, what version of .NET framework will your application be built against? I don't think we can build an applicaiton targeting at different .NET versions at the same time. But we can specify the supported runtime version in configuration file with <supportedRuntime> Element.


    Please mark the right answer at right time.
    Thanks,
    Sam
    • Edited by SamAgain Friday, September 3, 2010 3:13 AM refine
    • Marked as answer by SamAgain Thursday, September 9, 2010 9:24 AM
    Friday, September 3, 2010 3:11 AM
  • Hi Nagarajan,

    If you goal is to have your app support both 3.5 and 4.0, the easier way is to build and test your app on 3.5, and also tests on 4.0 to make sure it works on 4.0. The references of framework assemblies are automatically redirected to the right version for you. You just need to make sure you have entries in the config file indicating that your app supports both 3.5 and 4.0, and have done testing to make sure your app works on both versions of the runtime.

    Thanks,

    Yi

    • Marked as answer by SamAgain Thursday, September 9, 2010 9:25 AM
    Friday, September 3, 2010 6:55 AM
    Moderator

All replies

  • Hi,

    Thanks for your post. Just a quick reflection, if what you said can be done, what version of .NET framework will your application be built against? I don't think we can build an applicaiton targeting at different .NET versions at the same time. But we can specify the supported runtime version in configuration file with <supportedRuntime> Element.


    Please mark the right answer at right time.
    Thanks,
    Sam
    • Edited by SamAgain Friday, September 3, 2010 3:13 AM refine
    • Marked as answer by SamAgain Thursday, September 9, 2010 9:24 AM
    Friday, September 3, 2010 3:11 AM
  • Hi Nagarajan,

    If you goal is to have your app support both 3.5 and 4.0, the easier way is to build and test your app on 3.5, and also tests on 4.0 to make sure it works on 4.0. The references of framework assemblies are automatically redirected to the right version for you. You just need to make sure you have entries in the config file indicating that your app supports both 3.5 and 4.0, and have done testing to make sure your app works on both versions of the runtime.

    Thanks,

    Yi

    • Marked as answer by SamAgain Thursday, September 9, 2010 9:25 AM
    Friday, September 3, 2010 6:55 AM
    Moderator