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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:54:04+00:00 2026-06-11T11:54:04+00:00

I have an application and a dll it depends upon, which, in their csproj

  • 0

I have an application and a dll it depends upon, which, in their csproj files have been set to target .NET 3.5. We are trying to build these two projects to target .NET 4.0 by passing in /p:TargetFrameworkVersion=v4.0 as a command line parameter to msbuild (using NAnt). The build is succeeding, but running the program crashes immediately with a BadImageFormatException – “This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded”

Using .NET reflector, I have checked all references of the output exe and dll – everything references .NET 4.0 dlls; nothing references .NET 2; and yet my debugger is telling me that mscorlib 2.0.50727.4971 has been loaded.

Changing the projects themselves to target .NET 4, and then building in Visual Studio works fine – no issues.

I’m a bit stuck here, as I don’t know what the next investigation step could be. I don’t know why it is loading that version of mscorlib.

  • 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-11T11:54:06+00:00Added an answer on June 11, 2026 at 11:54 am

    Check if the <supportedRuntime> element is present in your application’s app.config. This must specify all versions of the Common Language Runtime the application supports.
    See http://msdn.microsoft.com/en-us/library/w4atty68.aspx for a full description of the <supportedRuntime> element.

    In your case, since the application was previously targeting .NET 3.5, the app.config will most likely have an entry for “v2.0.50727” of the CLR, but I suspect there is not a corresponding entry for “v4.0”.

    As mentioned in the above article, if the entry is removed entirely, the version of the runtime used to build the application used. I believe it’s recommended each supported version is explicitly specified in app.config.

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

Sidebar

Related Questions

I have application which needs to use a dll (also written by me) which
i have a doubt when we run the application (dot net application) dll or
I have Java application which sends pointer to function (callback) to some native dll
I have a Java Application which has to load an DLL with a few
I have an application written in C# which depends on sqlite managed provider. The
I have an application which depends on PyGTK, PyGobject, and PyCairo that I built
I have an application that uses a DLL to generate fastReports files. When I
I have an application which uses a .dll which is full of gui application
I have an application written in .NET 4.0 that i compile into a DLL
I am trying to build an old version of an application which consists of

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.