Sign in to follow this  

[.net] Cant call constructor- not a valid Win32 application??

This topic is 4103 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

That's what it says. Unhandled Exception: System.BadImageFormatException: is not a valid Win32 appli cation. (Exception from HRESULT: 0x800700C1) at QuestEngine.Quest..ctor(String dataDirectory, String textureDirectory, Int I JUST installed managed directX. This program which I brought from my old pc requires it. Does this mean something's not right with the way i installed it?

Share this post


Link to post
Share on other sites
Are you sure this is specific to DirectX? Admittedly I'm not the best .NET programmer, but what you've posted doesn't suggest anything DX related.

I'll move this over to the .NET specific forum for you - might well stand a better chance of getting an answer. Let me (or another mod) know if it is indeed DX specific and it can be moved back [smile]

Some further details about your setup might be useful - what software have you got installed, what version(s), what order was it installed, are any other programs having problems?

hth
Jack

Share this post


Link to post
Share on other sites
I've seen that issue in a myriad of cases. I believe the most common was related to having a version of .NET but not the proper one.

So your app requires .NET 2 and you installed 1.1 or something of that nature.

Nothing else really comes to mind immediately though.

Share this post


Link to post
Share on other sites
No, I've been running .Net 2.0 apps for a long time now with no problem. Only the ones that use Managed DX complain.

My system is XP, x64. The x64 dlls are already in the path. I'm not sure what's wrong, but again it's only the DX programs that do this. As soon as the code enters a class that includes DX, it complains. Before the flow reaches that point the program executes fine since it's just standard .Net 2.0 code.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You could have the wrong version of MDX - 1.1 instead of the 2.0 beta, or something...

Share this post


Link to post
Share on other sites
I have the August 2006 SDK. It lists my OS among those supported (Windows XP Pro x64). It also compiles fine, using whatever Managed DirectX objects I want without a single complaint.

Share this post


Link to post
Share on other sites
The issue exists with the fact that there are no x64 assemblies available for Managed DirectX currently. To make a long story short: What happens is that the program is natively compiled apon execution. Therefore the game's main executable is most likely targeting the x64 platform. Since x64 applications cannot link to x86 libraries the 'System.BadImageFormatException'is thrown. To fix the issue, the .NET app will need to be compiled as exclusively x86. This in turn guarentees that the application will target the x86 platform upon execution.

To exclusiely target the x86 platform, open the Configuration Manager. Select the drop down control labeled as Active Solution Platform. Next choose the 'New' option. On the 'New Solution Platform' dialog, select x86 from the drop down control. Make sure 'Copy Settings From' is empty, and check the 'Create new project platforms' checkbox. Finally click the 'OK' button. Make sure all projects within the solution are set as x86 instead of 'Any CPU'. Recompile the source, and run it on the x64 machine. The application should now run correctly via WOW64.

It is safe to compile as 'Any CPU' when the project is entirely .NET. However, once you mix unmanaged and managed code, you must make sure that x86 and x64 versions of the unmanaged code exists.

Post back if you still have trouble. You may want to also search the MSDN forums for this isssue. It's actually pretty common. The answers will be to set the project as x86 as I have mentioned.

Share this post


Link to post
Share on other sites
Quote:
Original post by Billr17
The issue exists with the fact that there are no x64 assemblies available for Managed DirectX currently. To make a long story short: What happens is that the program is natively compiled apon execution. Therefore the game's main executable is most likely targeting the x64 platform. Since x64 applications cannot link to x86 libraries the 'System.BadImageFormatException'is thrown. To fix the issue, the .NET app will need to be compiled as exclusively x86. This in turn guarentees that the application will target the x86 platform upon execution.

To exclusiely target the x86 platform, open the Configuration Manager. Select the drop down control labeled as Active Solution Platform. Next choose the 'New' option. On the 'New Solution Platform' dialog, select x86 from the drop down control. Make sure 'Copy Settings From' is empty, and check the 'Create new project platforms' checkbox. Finally click the 'OK' button. Make sure all projects within the solution are set as x86 instead of 'Any CPU'. Recompile the source, and run it on the x64 machine. The application should now run correctly via WOW64.

It is safe to compile as 'Any CPU' when the project is entirely .NET. However, once you mix unmanaged and managed code, you must make sure that x86 and x64 versions of the unmanaged code exists.

Post back if you still have trouble. You may want to also search the MSDN forums for this isssue. It's actually pretty common. The answers will be to set the project as x86 as I have mentioned.


Yes,this is the first snag I hit when trying to compile my managed dx apps under windows 64 using vs2005. So yeah this is quite common and there have been threads about this posted before somewhere around here.

Share this post


Link to post
Share on other sites
OK, I'm glad to hear that this problem isn't unheard of, but the thing is, I'm not using Visual Studio, I'm using csc on the command prompt. How do I set that to target x86?

Share this post


Link to post
Share on other sites
Quote:
Original post by NexusOne
OK, I'm glad to hear that this problem isn't unheard of, but the thing is, I'm not using Visual Studio, I'm using csc on the command prompt. How do I set that to target x86?


Use the "/platform:x86" flag and you should be all good. :-) See MSDN csc Platform flag for more information.

Share this post


Link to post
Share on other sites

This topic is 4103 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this