In my C3D 2012 .Net project, I reference the AecBaseMgd.dll from the Civil 3D 2012 installation folder. When I build the 32 bit version of this project, on my 64 bit machine, I get a warning saying that the AecBaseMgd.dll references a different platform. Do I need to copy this dll from the C3D 2012 installation folder on a 32 bit machine, to my computer for build purposes?
For each of the three references AeccXUiLand, AecXUIBase and AutoCAD.Interop, I get a compile warning saying that a reference to the embedded interop assembly stdole.dll (found in the GAC) was created, because each of them references stdole.dll indirectly. The warning suggests I should consider changing the Embed Interop Types property of the references (it is now set to False). Do you also get this build-warning?
If I build my 32 bit version as we have discussed, on my Win7x64, I get runtime errors on 32 bit machine, e.g.: Method not found: 'Int64 Autodesk.AECC.Interop.Land.IAeccTinSurface.get_ObjectID()'.
This is what I have done for my C3D2012 addon projects:
.NET 3.5, add the AutoCAD Interop references from the ObjectARX\inc-x64 folder, add the Aec* Interop references from the "Autodesk Shared\" and "Autodesk Shared\Civil Engineering 90" folders, all Interops set to NOT be embedded, all of the *mgd.dll's are referenced from the C3D install folder. The resulting dll can then be loaded in either 32 or 64 bit C3D and it works. There ARE a couple of Aecc objects that required special handling, creating Featurelines is one of these...here's what I've done to work around that:
//AeccLandFeatureLine fline = site.FeatureLines.AddFromPolyline(acadObj.ObjectID, flStyle); //this fails when mixing 32/64 bit builds, use the following 5 lines of code instead object[] oArgs = new object[2]; oArgs[0] = acadObj.GetType().InvokeMember("ObjectID", System.Reflection.BindingFlags.GetProperty, null, acadObj, null); oArgs[1] = flStyle; AeccLandFeatureLines flines = site.FeatureLines; AeccLandFeatureLine fline = flines.GetType().InvokeMember("AddFromPolyline", System.Reflection.BindingFlags.InvokeMethod, null, flines, oArgs) as AeccLandFeatureLine;
For the C3D2013 projects it was much different. First, all Aec* interop dll files from each of the 32 & 64 bit installs were copied into the respective ObjectARX\inc-* folders. I setup my project to allow x64 & x86 builds, no AnyCPU option. I added the required references, with the interops pointing to the inc-x64 folder and set the Embedded option to True. I then built the project to insure that part built correctly. Next I closed the solution, opened the .csproj file in notepad and added this just before the first ItemGroup:
<PropertyGroup Condition=" '$(Platform)' == 'x86' "> <InteropPath>C:\ObjectARX 2013\inc-win32</InteropPath> </PropertyGroup> <PropertyGroup Condition=" '$(Platform)' == 'x64' "> <InteropPath>C:\ObjectARX 2013\inc-x64</InteropPath> </PropertyGroup>
Next I changed the Hintpaths for all of the Interops listed in the csproj file from "C:\Program Files\Autodesk\AutoCAD Civil 3D\*" & "C:\ObjectARX\inc-x64" to "$(InteropPath)\*". This makes it so the references auto change when switching between the x86 & x64 platforms. Make sure the build options Output paths are different for x64 & x86. Now the dll's created in their respective folders work in their intended environment.
I hope that helps! It took me hours to figure all that out.
Thank you so much for your replies! However, the 32 bit version, built on my 64 bit machine, fails during runtime even if I follow your "recipe". Also, with the changes on the 2013 version, I think I'll continue to build the two version on different machines.