WIth 2013's move to allow the use of Embed Interop Types, I thought it was going to help with different versions so we no longer had to reference the Interops in the ObjectARX folders (vs those listed in the GAC) when working with multiple versions. However, it appears when doing so I can no longer build a project on a 64 bit machine and have it run on a 32 bit machine. All calls to Acad* objects (AcadApplication, AcadDocument, etc.) fail with messages similar to this:
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
Nope, nor does it work in the 64 bit version. All I did was copy the project to my VS2010 projects and build it. I will have to check the code to see if it's even trying to run correctly tonight.
Thanks for the idea! I had been planning to create a small test project, this should save some time.
Here's an excerpt from the C3D 2013 Readme:
**********************************
COM Interop Changes
Interop DLLs are no longer registered as Primary Interop Assemblies (PIAs), and are deployed in the AutoCAD Civil 3D installation folder rather than the Global Assembly Cache (GAC). This means that these assemblies must now be added to Visual Studio projects using the Browse tab of the Add Reference dialog box, rather than from the COM tab as was done previously.
To compile previously written projects against AutoCAD Civil 3D 2013, you will need to remove references to all interop assemblies from your project, and then re-add them using the Browse tab.
The assemblies required for COM interop are:
•Autodesk.AEC.Interop.Base
•Autodesk.AEC.Interop.UiBase
•Autodesk.AutoCAD.Interop
•Autodesk.AutoCAD.Interop.Common
•Autodesk.AECC.Interop.<domain>
•Autodesk.AECC.Interop.Ui<domain>
**********************************
These 6 interop assemblies are referenced in the CSharpClientSample app. Remove them and re-reference using the Browse tab (C3D installation folder). The runtime version for each is 4.0.xxxxx. On my machine it's 4.0.30319. Also, on my machine, none of these assemblies are in th GAC.
.NET 4.0 allows com assemblies to be embeded in the .NET application. Therefore the Embed Interop Types property should be set to True.
The CSharpClientSample Readme should have been rewritten to get rid of references to VC8 and VS2005. All you need is VS2010 set for C#. Also, the comment at the end of Form1.cs warning about closing AutoCAD while the app is still active does not seem to be true on my machine.
I've found a really great book (1712 pages):
Pro C# 2010 and the .NET 4 Platform by Andrew Troelsen.
It's a great reference for C# and the .NET 4 framework.The Index starts on page 1583 and runs to page 1712 which means you should be able to zero on any topic of interest. Best 40 bucks I ever spent.
Tom
Thanks, Tom. I have followed those instruction to the letter, and it works fine on a 64 bit install when the dll is also built on a 64 bit machine. But it fails to work on a 32 bit install. I can take the same exact project, copy it to the 32 bit machine, rebuild it, and it works fine in the 32 bit C3D. But take THAT dll to a 64 bit machine and it fails in the exact same manner. Leading me to think we now need 2 separate builds for 32 & 64 bit machines....which is not what I wanted to hear.
For anyone wanting to check this out, I've attached a VS2010 C# project which demonstrates this issue. Built in Win7x64 it runs fine in C3D2013x64. Copy this dll to a 32bit machine and run C3D2013 there, it fails. Copy the project to the 32bit machine, open in VS, rebuild, run C3D2013 and the command runs fine. Copy that dll to the x64 machine, run in C3D, failure.
This is the all that I have executing in this test:
public class Class1 { [CommandMethod("COMTest")] public void conmtest() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage("\nAttempting to set AcadApplication object...."); try { AcadApplication acadapp = (AcadApplication)Application.AcadApplication; ed.WriteMessage("\n....Success!"); } catch (System.Exception e) { ed.WriteMessage("\n.....FAILED! \n" + e.Message); } } }
Jeff,
Look at:
In there you will find the following:
*****************************************************
Reply April 16, 2012 at 05:44 PM
Jeff,
My feeling all along was that you had to compile either to 32 bit or to 64 bit. I'm just getting iinto .NET. Was'nt sure if the .NET guys could produce a JIT compiler that could compile to either bitness base upon reading the machine OS info.
Good luck,
Tom
Can't find what you're looking for? Ask the community or share your knowledge.
This is the same approach we take, although we have it worse as we support 2010, 2011, 2012 and now 2013. Oh and we have switches to build 64-bit and 32-bit versions of out plugin to suit the two versions
*****************************************************
What are the switches?
Tom