I have a 32-bit .NET class library that has a simple public class and a simple public method. I have a 64-bit .NET console application where I use reflection, I want to load a 32-bit assembly and use 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:
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 shell for this 32-bit dll and load this shell using the overboot in my 64-bit console application? Is it so? Any sample code would be very helpful.
source
share