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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:38:51+00:00 2026-05-19T01:38:51+00:00

I’m currently using the following code: AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => { var name

  • 0

I’m currently using the following code:

AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => {
    var name = args.Name + ".dll";
    using (var input = Assembly.GetExecutingAssembly()
                               .GetManifestResourceStream(name)) {
        Assembly dll = input != null
            ? Assembly.Load(input.ToArray())
            : null;

        return dll;
    }
};

In all instances locally it seems to work just fine, however one client is having trouble loading the included dlls (they do not have source code access).

Are there any trust issues or gotchas that I should be aware of when using this type of dynamic dll loading?

Medium Trust issues don’t seem to be an issue, however our resulting dll requires Full Trust anyway. I guess it might come down to Security Permissions or something.

Update

After going through the docs, again, I noticed a single line that I skipped over before and I think it’s related to my problem.

“Beginning with the .NET Framework 4, the ResolveEventHandler event is raised for all assemblies, including resource assemblies. In earlier versions, the event was not raised for resource assemblies. If the operating system is localized, the handler might be called multiple times: once for each culture in the fallback chain.”

Whereas in 3.5 it wasn’t. I’ll post an updated when I confirm.

  • 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-19T01:38:52+00:00Added an answer on May 19, 2026 at 1:38 am

    Well, not having any details it’s hard to diagnose; however, I would suggest a few changes to the code above:

    1. args.Name is actually a full assembly name, not just a simple name, but can contain versions etc. Passing this value to the constructor of AssemblyName parses just the simple name. I doubt this is the issue your experiencing.

    2. You should propagate the current domains evidence when loading the assembly bits. This may be the issue your seeing in the field, but then again maybe not.

    3. Don’t use executing assembly, access the correct assembly containing the resource via an explicit reference to a type contained in that assembly. Just replace ‘THIS_CLASS’ in the example below. This is my best guess as to the root cause of the issue your having.

    4. You should go ahead and cache the results of this method into a global dictionary. Why? You can be called to load the same assembly multiple times and for each time you are called you must return the same instance of the assembly. Your example loads the assembly again and again.

    5. Add detailed logging, log what assembly your looking for, the resource name your trying to load, the assembly your loading it from, if the stream is null, the result of the Load() method, etc.

      static Dictionary<String, Assembly> _assemblies = new Dictionary<String, Assembly>(StringComparer.OrdinalIgnoreCase);
          AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
          {
              Assembly dll;
              var name = new AssemblyName(args.Name).Name + ".dll";
              if(!_assemblies.TryGetValue(name, out dll))
              {
                  Assembly res = typeof(THIS_CLASS).Assembly;
                  using (var input = res.GetManifestResourceStream(name))
                  {
                      if (input == null)
                      {
                          LogWrite("Assembly {0} does not contain {1}", res, name);
                          return null;
                      }
                      if (null == (dll = Assembly.Load(input.ToArray(), AppDomain.CurrentDomain.Evidence)))
                      {
                          LogWrite("Assembly {0} failed to load.", name);
                          return null;
                      }
                      LogWrite("Loaded assembly {0}.", name);
                      _assemblies[name] = dll;
                      return dll;
                  }
              }
              return dll;
          };
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.