SilverbackNet
SilverbackNet

Reputation: 2074

Force C# app to compile as x64 instead of AnyCpu

I've being driven up the wall trying to reference native x64 dlls in a C# app, using C# 2010 Express. I have a demo project that was converted from a 2008 project that has configuration and platform options in its properties, but the new projects that I've created don't! The dropdowns just don't exist - in fact I can't even switch from Debug to Release. Both of them use .Net Framework 4 and everything else seems the same between them.

In C++ and the converted C# project it's simple, you just open the solution's Configuration Manager and go, but my new C# project doesn't have that in the context menu.

I need to be able to reference the x64 dlls under x64 and the x86 dlls under x86, due to massive memory requirements. Can anyone explain why the option is missing or point me to how to fix it?

Upvotes: 5

Views: 6312

Answers (2)

jvdbogae
jvdbogae

Reputation: 1229

To make the project runtime configurable, first learn how to load an assembly at runtime, as in: http://support.microsoft.com/kb/837908

Use IntPtr.Size to determine which platform you are using, as in: http://msdn.microsoft.com/en-us/library/ms973190.aspx

Use a factory with the IntPtr.size parameter to obtain the correct dll, as in: http://www.go4expert.com/forums/showthread.php?t=5127#abfactory

Upvotes: -3

Pieter
Pieter

Reputation: 2239

Select Build - Configuration Manager. Under the Platform select new, then select x64 there.

Upvotes: 6

Related Questions