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

  • Home
  • SEARCH
  • 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 7683381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:46:44+00:00 2026-05-31T18:46:44+00:00

I’m using Unity 2.1 in my application and receive the error in the title

  • 0

I’m using Unity 2.1 in my application and receive the error in the title for one resolving scenario. I have no idea on where to look.

  • I’m running Windows 7 64bit
  • 32-bit applications are enabled
  • Tried building against “Any CPU” and “x64”

The problem doesn’t seem to be related to the 64bit architecture. Any assistance would be greatly appreciated!

Scenario’s

//works: class = "ProductManager<Product>
Container.Resolve<IProductManager<Product>>()

//works: class = "OrderManager"
Container.Resolve<IOrderManager()

//works: class="OrderManager" 
Container.Resolve<IOrderManager("OrderManager")

//DOESN'T WORK: EXCEPTION: BadImageFormatException
Container.Resolve<IOrderManager("OrderManager") 

//works: class="GenericOrderManager<Order>" (obviously)
var manager = new GenericOrderManager<Order>();

Code

Unity.config

<alias name="IProductManager" type="Assembly1.Namespace.IProductManager`1" />
<alias name="ProductManager" type="Assembly2.Namespace.ProductManager`1" />

<alias name="IOrderManager" type="Assembly1.Namespace.IOrderManager" />
<alias name="OrderManager" 
       type="Assembly1.Namespace.OrderManager" />
<alias name="OrderManager" 
       type="Assembly1.Namespace.OrderManager" 
       name="OrderManager" />
<alias name="GenericOrderManager" 
       type="Assembly2.Namespace.GenericOrderManager`1"
       name="GenericOrderManager" />

ProductManager + Interface

public interface IProductManager<TProduct> where TProduct : Product
{
}

public class ProductManager<TProduct> : IProductManager<TProduct> where TProduct : Product
{
}

OrderManager + Interface

public interface IOrderManager
{
}

public class OrderManager : IOrderManager
{
}

public class OrderManager<TOrder> : OrderManager where TOrder : Order
{
}

Update with StackTrace:

at
System.Runtime.CompilerServices.RuntimeHelpers._CompileMethod(IRuntimeMethodInfo
method) at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type
delegateType) at
Microsoft.Practices.ObjectBuilder2.DynamicBuildPlanGenerationContext.GetBuildMethod()
at
Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlanCreatorPolicy.CreatePlan(IBuilderContext
context, NamedTypeBuildKey buildKey) at
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext
context) at
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext
context) at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type
t, Object existing, String name, IEnumerable`1 resolverOverrides)

  • 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-31T18:46:45+00:00Added an answer on May 31, 2026 at 6:46 pm

    The Unity version you have is x32. Your project assemblies are being built as x64, but have the 32-bit Unity assemblies as references. Unfortunately, the compile will go fine. You will get a nasty surprise at run-time, though. Bottom line: compile with platform target of x86.

    64-bit assemblies calling 32-bit assemblies is one of the most common reasons for BadImageFormatException.

    MSDN notes:

    A DLL or executable is loaded as a 64-bit assembly, but it contains
    32-bit features or resources. For example, it relies on COM interop or
    calls methods in a 32-bit dynamic link library.

    To address this exception, set the project’s Platform target property
    to x86 (instead of x64 or AnyCPU) and recompile.

    More information here.

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

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.