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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:19:16+00:00 2026-06-04T19:19:16+00:00

Background First of all, I did look elsewhere for a solution and found this

  • 0

Background
First of all, I did look elsewhere for a solution and found this solution, but this does not solve my issue.

I have an assembly referenced in my main project in Visual Studio, but I need to load it from outside my project, not in a sub-folder. I can load the assembly with the call…

System.Reflection.Assembly.LoadFrom(myExternalAssemblyPath);

…but the program will not run and gives me the following error:

FileNotFoundException was unhandled

Could not load file or assembly ‘MyAssembly, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The
system cannot find the file specified.

I have no calls to the assembly before the call to load it, but the program still expects, even before it even enters the Main function apparently, that the DLL be in the program’s folder.

Quesiton:
How do I get my program to still reference this in Visual Studio, but load it from a different location when actually running the program? Is there a directive I need to specify somewhere to tell the program to wait to load it? Is there some other solution?

NOTE: I do not want to add the folder and DLL to the PATH variable. That is not a viable solution.

  • 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-06-04T19:19:17+00:00Added an answer on June 4, 2026 at 7:19 pm

    The trick is to implement the AssemblyResolve event on your application domain.

    http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve.aspx

    This is where you help the runtime to locate assemblies which it tries to load and cannot find using the default searching strategy. This should be straightforward, the runtime will call your handler for each missing assembly and you just have to load it by yourself from the custom path and return from the handler.

    An important point to remember: in .NET the JIT processes methods (into native code) fully before they are invoked. If your Main method uses any types or methods from the assembly you are trying to load, it won’t get as far as executing Main. Consequently, Main should only setup the assembly-loading. All other code (especially code relating to the assembly in question) must be moved to another method, so it gets JIT-ted separately.

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

Sidebar

Related Questions

This issue appears to affect all WebKit-based browsers, including the iPhone. First some background.
Background / Disclaimer First of all, please feel free to skip this entirely if
I have set Application does not run in background mode property key to YES
First, some background: I'm developing a web application using Python. All of my (text)
Some setup background first: I have a cronjob which runs a PHP file called
I'm using jQuery validation plugin. I have two images: first background of label, when
Hi and thanks for your attention. First some background on the question: I have
First a little background: I have already managed to connect to a Microsoft SOAP
Background I have two lists, the first is items which contains around 250 tuples,
First three elements of the background: I have created a Excel Template which is

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.