Force C# app to compile as x64 instead of AnyCpu

拈花ヽ惹草 提交于 2019-12-12 10:48:43

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/4414567/force-c-sharp-app-to-compile-as-x64-instead-of-anycpu

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!