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 6051481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:49:28+00:00 2026-05-23T07:49:28+00:00

I have an class that loads the assembly dynamically like so: Assembly asm =

  • 0

I have an class that loads the assembly dynamically like so:

    Assembly asm = Assembly.LoadFile(args[1]);        
    runner.RunTestOnAssembly(asm);

then another class runs the test on that assembly:

    foreach (var cspecType in asm.GetTypes())
    {
        RunTestOnType(cspecType);
    }

The loaded assembly references other assemblies in the same folder, [Debug\Tests] and the program that loads the assembly is in the [Debug] folder.

The loaded Assembly (CalcSpecAsm):

    public class CalcSpec : CSpecFacade<ICalc>
    {
        public CalcSpec()
        : base(new Calc())
        {

        }
    }

The referenced Assembly (CalcAsm):

    public class Calc : ICalc
    {
    /// <summary>
    /// Initalisation constructor
    /// resets the Total value.
    /// </summary>
    public Calc()
    {
        Total = 0;
    }
    .....

The CSpecFacade is referenced in another assembly.

And now the problem is that if I load the assembly CalcSpecAsm I get assembly loaderError on GetTypes() that it cannot resolve a reference to CalcAsm assembly.

The problem is this line of code: public class CalcSpec : CSpecFacade<ICalc>

If I remove the generic arg ICalc and initize it in the constructor then it works perfect but that’s not what I’m after.

BUT: If i copy the loaderAssembly program to the [Debug\Test] and then run it, everything works fine.

How to resolve the problem, and what causes it?

  • 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-23T07:49:28+00:00Added an answer on May 23, 2026 at 7:49 am

    when you load assemblies from other locations, you might get errors saying that assembly could not be loaded or it’s dependencies could not be loaded.

    This means that when loading your assembly .Net Runtime was not able to resolve all dependencies of your assembly.

    So you need to provide a way to resolve this.

    First you will have to add resolve event to your appdomain like this

    AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
    

    Then in that event you will have to load your dependencies.

        Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
    
            //Build the path of the assembly from where it has to be loaded.                
            assemblyPath = System.IO.Path.Combine("your path", args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll");
            assembly = Assembly.LoadFrom(assemblyPath);
    
            //Return the loaded assembly.
            return assembly;
        }
    

    Hope this will help.

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

Sidebar

Related Questions

I have an AS 3.0 class that loads a JSON file in using a
in AS3, I have an external class ImageLoader, that loads an image upon request.
I have a Java program that loads thirdparty class files (classes I did not
I have a class that I want to use to store properties for another
I have a .NET 4.0 class that uses Assembly.LoadFrom to load a .NET 3.5
I have this class that have a function to load other classes and create
I have a class - XClass, that I want to load into an array
I have class that represents users. Users are divided into two groups with different
I have class method that returns a list of employees that I can iterate
I have a class that map objects to objects, but unlike dictionary it maps

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.