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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:43:17+00:00 2026-05-17T14:43:17+00:00

I have a 32 bit .NET class library having a simple public class and

  • 0

I have a 32 bit .NET class library having a simple public class and a simple public method. I have a 64 bit .NET console application where using reflection, I wish to load the 32 bit assembly and consume its method.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Host.TestLib;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var lib = Assembly.LoadFrom("Simple32bitAssembly.dll");
        }
    }
}

When I run this I get the following exception thrown:

System.BadImageFormatException was unhandled
Message=Could not load file or assembly 
'file:///E:\AjitTemp\c\32bit64Bit\ReflectionTest\test\bin\Debug\Simple32bitAssembly.dll' 
or one of its dependencies. An attempt was made to load a program with an incorrect format.

Googling suggests that I need to create a 64 bit wrapper for this 32 bit dll and load this wrapper using relection in my 64 bit console application? Is this the way? Any sample code would be very helpful.

  • 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-17T14:43:18+00:00Added an answer on May 17, 2026 at 2:43 pm

    If you’ve specifically targeted both assemblies as 32bit and 64bit builds then you can’t load a 32bit assembly into a 64 bit process (and vice versa).

    If possible can you rebuild the 32bit assembly as ‘Any CPU’? This would allow you to load ‘Simple32bitAssembly’ into the 64 bit console application.

    With regard to your comment:

    “There are business constraints where I cannot compile my 32 bit dll as ‘Any CPU’.”

    The only way around this would be to deploy the 32 bit assembly into a separate 32 bit surrogate process. This process could expose functionality via .NET technologies such as:

        WCF
        Remoting
        ASP.NET Web Service
    

    The disadvantages are that cross process calls can be expensive (although you could use named pipes in WCF or Remoting) and increasing the complexity of your application.

    You’d also no longer have the ability to use reflection directly on this component from the consuming 64 application (but you could use reflection in the surrogate).

    Such are the trials of mixed architecture applications.

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

Sidebar

Related Questions

No related questions found

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.