问题
I have a database application that references Entity Framework 4.1. In the properties window of the project both the Configuration as well as Platform selection options are disabled. I wan't to target this application only for x64 systems.
Also there are some other projects in the same Solution and they have only x86 option avaliable as platform.
I don't get the idea why I couldn't target x64 systems specifically. I have windows 7 64 bit running on my pc.
Any clues how to target specifically to x64 based systems. All projects reference .Net Framework 4.
Screen shot of the project showing only "Any CPU" option
Edit 1: Why I need to target x64 systems.
Actually, the dlls that I am developing will have to load in Autocad x64 systems. But when I am trying to load the dll into Autocad it is rejecting the dll with the following error
NETLOAD Cannot load assembly. Error details: System.BadImageFormatException:
Could not load file or assembly
'file:///D:\RailwayProjects\RelayAnalysis_New\RelayAnalysis_Autocad\bin\Debug\Gl
obalArea.dll' or one of its dependencies. An attempt was made to load a program
with an incorrect format.
File name:
'file:///D:\RailwayProjects\RelayAnalysis_New\RelayAnalysis_Autocad\bin\Debug\Gl
obalArea.dll'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean
forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName
assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean
forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile,
Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm
hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks,
StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Autodesk.AutoCAD.Runtime.ExtensionLoader.Load(String fileName)
at loadmgd()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure
logging.
To turn this feature off, remove the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog].
I have a strong suspicion that Autocad x64 is rejecting the dll because it not in x64 format, although I may be wrong here. So now I expand the scope of my question to include AutoCAD, as the root of the problem is loading the dll in autocad. I have searched the web and found that AutoCAD is very picky about x32 and x64 types. The native developement environment AutoCAD.net for developing the Autocad plugins is also available separately under x32 and x64 types and I don't think that plugins developed with x32 will run in x64 type Autocad versions, and vice-versa. So, I need to be specific about the target platform for Autocad plugins
回答1:
In the Configuration Manager, there is an option to create new Configuration where we can select x64 as target platform.
Regarding the AutoCAD 2012, its very strict about the platform type. A 64 bit AutoCAD 2012 will accept "Any CPU" and x64 targeted plugins but not x86. That's a little off from the convention where we can run x86 applications on x64 systems. I targeted all my projects to x64 and loaded them in AutoCAD without any errors.
So my question is resolved.
来源:https://stackoverflow.com/questions/13660652/targetting-x64-platform-with-entity-framework-4-1-in-visual-studio-2010