2

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

enter image description here

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

CAD bloke
  • 8,578
  • 7
  • 65
  • 114
Jatin
  • 4,023
  • 10
  • 60
  • 107
  • Why would you want to do that? If your assembly is platform agnostic (as is EntityFramework since it's pure IL) it can ran in both 64-bit and 32-bit processes. Since IL is compiled at runtime when the code is first executed it behaves as if it was written for this platform. Again, I Wonder what setting the platform to x64 will buy you. – Pawel Dec 01 '12 at 17:48
  • I have edited the question to include the reason why I am being specific about targeting platform. – Jatin Dec 02 '12 at 06:12

1 Answers1

2

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.

Jatin
  • 4,023
  • 10
  • 60
  • 107
  • 1
    This is because on windows that 64-bit processors can emulate 32-bit processors (so-called Windows on Windows) but 32-bit processors obviously cannot emulate 64-bit processors. Therefore you can run 32-bit apps on 64-bit processors. Any CPU works for pure IL since it is compiled at runtime depending on what architecture you are using. Once you have PInvoke or mixed code (native and managed) in a single assembly you need to compile it for a specific platform. – Pawel Dec 02 '12 at 21:18