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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:42:07+00:00 2026-06-11T21:42:07+00:00

I am trying to load dlls into my program at runtime that match a

  • 0

I am trying to load dlls into my program at runtime that match a specific assembly attribute that I have set. In order to make sure that the dll is loadable before I check its flag I have written the following method:

private bool IsValidDll(string dll) {
        try {
            System.Reflection.Assembly.LoadFrom(dll);
            return true;
        } catch (Exception ex) { return false; }
    }

I can loop through dlls in my current directory and call this method to see if it will be safe to load the dll and check its assembly attributes. However, I am hitting a dll that is not throwing/catching an Exception and is still just directly crashing the program. The relevant output window information is as follows:

LoaderException: System.IO.FileLoadException: Mixed mode assembly is built against 
version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. - Adapters.Spryware.SprywareAdapter
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

I have tried catching the specific Exception (System.IO.FileLoadException) but the catch block is still skipped over and I still crash. Any thoughts?

Also, I find that this is a pretty heavy handed way of checking for my assembly attribute. Is there a way to check for my flag without having to load the dll with Reflection first?

  • 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-11T21:42:08+00:00Added an answer on June 11, 2026 at 9:42 pm

    Have to confess, I dont see why your code doesnt work either:

    I made a .net 4 thing and ran and mine did catch it:

        private void button1_Click(object sender, EventArgs e)
        {
           // foreach (String file in Directory.GetFiles("c:\\windows", "*.dll"))
            String file = @"C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Data.dll";
            {
                try
                {
                    //System.Reflection.Assembly.ReflectionOnlyLoadFrom(file);
                    System.Reflection.Assembly.LoadFrom(file);
                }
                catch (Exception ee)
                {
                    textBox1.Text += ee.Message + Environment.NewLine;
                }
            }
        }
    

    On clicking the text box reads:
    Could not load file or assembly ‘file:///C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Data.dll’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

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

Sidebar

Related Questions

I'm trying to load an assembly at runtime. For that I'm using the following
I have a problem with out of memory when I'm trying load a few
Trying to load content into a div, then on click load the previous content
Trying to load a small .txt file into mysql but get all my data
trying to load in a bunch of images into a list from a directory...my
Im trying to load a image at runtime in WPF using the following code
I am trying to speed up my app by loading certain DLLs into the
I am trying to test out MVVMLight but the DLLs that come with it
Hey I'm trying to load a Lua file into my c++ project but there
I have been trying to load a 32-bit dll using C++ (from a 32-bit

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.