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

  • Home
  • SEARCH
  • 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 6610791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:53:10+00:00 2026-05-25T19:53:10+00:00

I have an application that has reference to Microsoft.Data.SqlXml.dll assembly (part of SQLXML ).

  • 0

I have an application that has reference to Microsoft.Data.SqlXml.dll assembly (part of SQLXML). But on different machines, depending on whether it’s live environment or test, or developers local PC, different versions of SQLXML are installed. This arises an issue: depending on destination machine I have to compile application against correct Microsoft.Data.SqlXml.dll assembly.

In Subversion I keep csproj and dll file that is used on live environment. When I have to test modules that take advantage of Microsoft.Data.SqlXml.dll locally, I change reference in project, and revert them back. But several times I forgot to rollback changes and I checked in csproj and Microsoft.Data.SqlXml.dll with version that didn’t comply with SQLXML installed on live server. As a result, I received runtime errors.

My question is: is there any way to dynamically load assemblies in runtime? I can have switch statement somewhere in application that would load correct assembly depending on entry in app.config (eg. env=”live|test|local”) ? Or perhaps there is another way to address this issue?

Thanks,Pawel

  • 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-25T19:53:10+00:00Added an answer on May 25, 2026 at 7:53 pm

    From Microsoft page:

    AppDomain currentDomain = AppDomain.CurrentDomain;
    currentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler);
    
    private Assembly MyResolveEventHandler(object sender,ResolveEventArgs args)
    {
        //This handler is called only when the common language runtime tries to bind to the assembly and fails.
    
        //Retrieve the list of referenced assemblies in an array of AssemblyName.
        Assembly MyAssembly,objExecutingAssemblies;
        string strTempAssmbPath="";
    
        objExecutingAssemblies=Assembly.GetExecutingAssembly();
        AssemblyName [] arrReferencedAssmbNames=objExecutingAssemblies.GetReferencedAssemblies();
    
        //Loop through the array of referenced assembly names.
        foreach(AssemblyName strAssmbName in arrReferencedAssmbNames)
        {
            //Check for the assembly names that have raised the "AssemblyResolve" event.
            if(strAssmbName.FullName.Substring(0, strAssmbName.FullName.IndexOf(","))==args.Name.Substring(0, args.Name.IndexOf(",")))
            {
                //Build the path of the assembly from where it has to be loaded.                
                strTempAssmbPath="C:\\Myassemblies\\"+args.Name.Substring(0,args.Name.IndexOf(","))+".dll";
                break;
            }
    
        }
        //Load the assembly from the specified path.                    
        MyAssembly = Assembly.LoadFrom(strTempAssmbPath);                   
    
        //Return the loaded assembly.
        return MyAssembly;          
    }
    

    Naturally you have to change the part //Build the path of the assembly using what you need.

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

Sidebar

Related Questions

I have an application that has Powershell 1 embedded into it, but we need
I have an application that has many different types of objects that each persist
I have an application that has several objects (about 50 so far, but growing).
We have an application that has to be flexible in how it displays it's
I have an application that has created a number of custom event log sources
We have an application that has one or more text console windows that all
I have an application that has multiple states, with each state responding to input
I have an application that has to deal with getting special characters in its
I have an application that has a primary layout of portrait (it is fixed
Background: We have an application that has been in the works for over a

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.