Author Topic: Upgrade VS project to x64 ?  (Read 7387 times)

0 Members and 1 Guest are viewing this topic.

LE3

  • Guest
Upgrade VS project to x64 ?
« on: July 17, 2010, 04:51:08 PM »
I have a visual studio C# project, that runs in win32 AutoCAD 2010 (A2007,8,9) and now got the chance to do the upgrade
to x64 (have now a x64 system with AutoCAD 2010 installed to run my tests).

I do not see anywhere the reference COM "AutoCAD/ObjectDBX/Common XX Type Library" (I have on my project this one: AutoCAD/ObjectDBX/Common 18 Type Library)

I see under: D:\ObjectARX 2010\inc-x64 two .tbl files ( axdb18enu.tlb acax18ENU.tlb) and the same ones here: C:\Program Files\Common Files\Autodesk Shared

Totally confused, have tried to add both tbl files, also these ones: Autodesk.AutoCAD.Interop.dll Autodesk.AutoCAD.Interop.Common.dll (under D:\ObjectARX 2010\inc-x64)

and appear that I don't have any luck...

What do you guys do?

Thanks!

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Upgrade VS project to x64 ?
« Reply #1 on: July 17, 2010, 07:00:21 PM »
Luis wouldn't you need to reference the 64x version of acdbmgd and acmgd.DLL?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

LE3

  • Guest
Re: Upgrade VS project to x64 ?
« Reply #2 on: July 17, 2010, 07:09:29 PM »
Luis wouldn't you need to reference the 64x version of acdbmgd and acmgd.DLL?
Yes, I have those (I assume that those two assemblies are x64, since my laptop is 64 bits... or? )- but my code that works on win32 does not display one of the dialogs....
Here it is a snapshot of my references... if helps in any way:

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8718
  • AKA Daniel
Re: Upgrade VS project to x64 ?
« Reply #3 on: July 17, 2010, 08:38:19 PM »
Luis wouldn't you need to reference the 64x version of acdbmgd and acmgd.DLL?

No, programmers should always reference the managed DLLs that come with the ARX SDK, usually in the \inc folder. These DLLS are specifically designed for this purpose

LE3

  • Guest
Re: Upgrade VS project to x64 ?
« Reply #4 on: July 17, 2010, 08:44:45 PM »
Luis wouldn't you need to reference the 64x version of acdbmgd and acmgd.DLL?

No, programmers should always reference the managed DLLs that come with the ARX SDK, usually in the \inc folder. These DLLS are specifically designed for this purpose
I use those (noticed the capital letters that means were referenced from the sdk...), and also tried the ones from where acad it is installed... no worky in my case.... should I register the x64 tbl's so it can be (maybe) avail in the com tab?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8718
  • AKA Daniel
Re: Upgrade VS project to x64 ?
« Reply #5 on: July 17, 2010, 08:52:28 PM »
Oops sorry, I should have read your post all the way through, you would think those would have been installed with Acad. I'd do a repair of the install

.. let me check mine

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8718
  • AKA Daniel
Re: Upgrade VS project to x64 ?
« Reply #6 on: July 17, 2010, 08:58:10 PM »
Don't know LE, its not on mine either  :-o

LE3

  • Guest
Re: Upgrade VS project to x64 ?
« Reply #7 on: July 17, 2010, 09:05:49 PM »
Don't know LE, its not on mine either  :-o

will try to register the tlb and see what happens (it is inside of ObjectARX 2010\inc-x64).

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Upgrade VS project to x64 ?
« Reply #8 on: July 17, 2010, 09:31:20 PM »

flying past, haven't read the whole thread

does this piccy help



kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LE3

  • Guest
Re: Upgrade VS project to x64 ?
« Reply #9 on: July 17, 2010, 09:44:23 PM »

flying past, haven't read the whole thread

does this piccy help
I have use that one, will double check and try again... have you used that in any of your x64 code?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Upgrade VS project to x64 ?
« Reply #10 on: July 17, 2010, 09:50:40 PM »

Haven't done any COM stuff on 64bit yet Luis
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LE3

  • Guest
Re: Upgrade VS project to x64 ?
« Reply #11 on: July 17, 2010, 09:57:02 PM »

Haven't done any COM stuff on 64bit yet Luis
Thank you Kerry.

I just added the assembly (from SDK 2010) and does not work.... for me.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Upgrade VS project to x64 ?
« Reply #12 on: July 17, 2010, 11:13:45 PM »

Luis,
Can you clarify what you mean by 'does not work' ??

Which OS are you using ?

What ActiveX Types and Methods are you trying to access ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LE3

  • Guest
Re: Upgrade VS project to x64 ?
« Reply #13 on: July 17, 2010, 11:31:17 PM »
Which OS are you using ?
Microsoft Windows NT Version 6.0 (x64)
Acadver: 18.0s (LMS Tech)

Quote
What ActiveX Types and Methods are you trying to access ?

To give you an idea, was thinking to try/move/use simple .net instead of those COM calls/usage... will give it a try

Code: [Select]
public static Node SelectEntityProperty(bool bSelect)
{
try
{

if (CXCELClass.gCReportTemplate != null && CXCELClass.gCReportTemplate.gfrmReport != null &&
!CXCELClass.gCReportTemplate.gfrmReport.IsDisposed)
CXCELClass.gCReportTemplate.gfrmReport.Visible = false;
#if !COM_APP
Document doc = Application.DocumentManager.MdiActiveDocument;
if (doc == null)
{
System.Windows.Forms.MessageBox.Show("No opened drawing found.", "Error finding drawing.",
System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
return null;
}
Editor ed = doc.Editor;
           
           
Object ObjEnt;
AcadApplication acAppCOMObj = Application.AcadApplication as AcadApplication;
//Microsoft.VisualBasic.Interaction.AppActivate(Application.MainWindow.Text);
// Ask the user to select an entity
PromptEntityOptions opt = new PromptEntityOptions("\nSelect entity: ");
PromptEntityResult res;
   
while ((res = ed.GetEntity(opt)).Status != PromptStatus.OK){
if (res.Status == PromptStatus.Cancel)
return(null);
}
ed.WriteMessage("\nCommand: ");
Transaction tr = doc.TransactionManager.StartTransaction();
using (tr)
{
DBObject obj = tr.GetObject(res.ObjectId, OpenMode.ForRead);
ObjEnt = acAppCOMObj.ActiveDocument.HandleToObject(obj.Handle.ToString());

tr.Commit();
}
Node nod = new Node();
frmObjProp frm = new frmObjProp(bSelect);
CadxcelNET.CXCELClass.GetMainForm().frmPropExplorer = frm;
frm.treeObjProp.Nodes.Add(nod);
SetDatPropObj(ObjEnt, nod);
nod.Expand();
frm.ShowDialog();
if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
return frm.treeObjProp.SelectedNode;
else
return null;
#else
AcadApplication acAppCOMObj = Application.AcadApplication as AcadApplication;
AcadDocument acDocCOMObj;
Object objEnt = null;
Object objPoint;
           
string strRes = "Yes";

if (acAppCOMObj != null)
{

acDocCOMObj = acAppCOMObj.ActiveDocument;
               
//Microsoft.VisualBasic.Interaction.AppActivate(acAppCOMObj.Caption);
while (objEnt == null && strRes.CompareTo("Yes") == 0)
{
try
{

acDocCOMObj.Utility.GetEntity(out objEnt, out objPoint, "\nSelect Entity:");
}
catch
{
acDocCOMObj.Utility.InitializeUserInput(1, "Yes No");
strRes = acDocCOMObj.Utility.GetKeyword("Nothing selected. Continue?(Yes/No):");
}
}
if (objEnt == null)
return(null);

Node nod = new Node();
frmObjProp frm = new frmObjProp(true);
frm.treeObjProp.Nodes.Add(nod);
SetDatPropObj(objEnt, nod);
nod.Expand();
frm.ShowDialog();
if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
return frm.treeObjProp.SelectedNode;
else
return null;
               
}

#endif
}
catch{}
finally
{
if (CXCELClass.gCReportTemplate != null && CXCELClass.gCReportTemplate.gfrmReport != null &&
!CXCELClass.gCReportTemplate.gfrmReport.IsDisposed)
CXCELClass.gCReportTemplate.gfrmReport.Visible = true;
}
return null;
        }

sinc

  • Guest
Re: Upgrade VS project to x64 ?
« Reply #14 on: July 18, 2010, 01:50:46 AM »
Luis wouldn't you need to reference the 64x version of acdbmgd and acmgd.DLL?

There is no "64x version" of the managed libraries.

One of the neat things about working with .NET is that the CIL is independent of the underlying architecture.  So as long as you aren't trying to reference the Interops and use COM stuff, and as long as you aren't doing any PInvoke stuff, you can pretty much ignore x86 vs. x64.

LE3

  • Guest
Re: Upgrade VS project to x64 ?
« Reply #15 on: July 18, 2010, 02:13:32 AM »
Luis wouldn't you need to reference the 64x version of acdbmgd and acmgd.DLL?

There is no "64x version" of the managed libraries.

One of the neat things about working with .NET is that the CIL is independent of the underlying architecture.  So as long as you aren't trying to reference the Interops and use COM stuff, and as long as you aren't doing any PInvoke stuff, you can pretty much ignore x86 vs. x64.
now just started to be more confused... I'll check tomorrow...

Hi Sinc,
 any idea why they have two different (if they are) files, have a look in the the x64: and also there is a 32 folder..................................................

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Upgrade VS project to x64 ?
« Reply #16 on: July 18, 2010, 03:03:24 AM »
Luis, this is what I have on my Win7 x64.
Only 2011 Mechanical installed and  SDK's ( 2010, 2011)
Search results for AcMgd* in C:\;  
Quote

AcMgd.dll       c:\ObjectARX 2010\inc-win32                                                                                   727 kB    2009/02/09 00:01  
AcMgd.dll       c:\ObjectARX 2010\inc-x64                                                                                     737 kB    2009/02/09 00:05  
AcMgd.dll       c:\ObjectARX 2011\inc                                                                                         829 kB    2010/02/09 20:10  
acmgd.dll       c:\Program Files\Autodesk\ACADM 2011                                                                          2.55 MB   2010/02/10 14:17  
acmgd           c:\Windows\assembly\NativeImages_v2.0.50727_64                                                                Folder    2010/06/25 13:42  
acmgd.ni.dll    c:\Windows\assembly\NativeImages_v2.0.50727_64\acmgd\87c6ae3a116b3b89b786eb601379bbd7                         7.38 MB   2010/06/25 13:42  


.. and the AcDbMgd
Quote
acdbmgd                 C:\Windows\assembly\NativeImages_v2.0.50727_64                                                                                  Folder      2010/06/25 13:42
AcDbMgd.dll             C:\ObjectARX 2010\inc-win32                                                                                                     1.65 MB     2009/02/08 23:52        
AcDbMgd.dll             C:\ObjectARX 2010\inc-x64                                                                                                       1.67 MB     2009/02/08 23:54        
AcDbMgd.dll             C:\ObjectARX 2011\inc                                                                                                           1.97 MB     2010/02/09 20:03        
acdbmgd.dll             C:\Program Files\Autodesk\ACADM 2011                                                                                            5.69 MB     2010/02/10 14:16        
acdbmgd.lib             C:\Autodesk\AutoCAD_Mechanical_2011_English_Win_64bit\sdk\ObjectARX\lib-win32                                                   5 kB        2010/02/10 11:52        
acdbmgd.lib             C:\Autodesk\AutoCAD_Mechanical_2011_English_Win_64bit\sdk\ObjectARX\lib-x64                                                     5 kB        2010/02/10 12:01        
acdbmgd.lib             C:\ObjectARX 2010\lib-win32                                                                                                     5 kB        2009/02/08 23:50        
acdbmgd.lib             C:\ObjectARX 2010\lib-x64                                                                                                       5 kB        2009/02/08 23:53        
acdbmgd.lib             C:\ObjectARX 2011\lib-win32                                                                                                     5 kB        2010/02/09 19:52        
acdbmgd.lib             C:\ObjectARX 2011\lib-x64                                                                                                       5 kB        2010/02/09 20:01        
acdbmgd.ni.dll          C:\Windows\assembly\NativeImages_v2.0.50727_64\acdbmgd\aa0870e6051189eb524d52e8cf8277c4                                         14.24 MB    2010/06/25 13:42
acdbmgd.resources.dll   C:\Program Files\Autodesk\ACADM 2011\en-US                                                                                      264 kB      2010/02/10 14:16        
  
acdbmgdbrep.dll         C:\ObjectARX 2010\inc-win32                                                                                                     132 kB      2009/02/08 23:57        
acdbmgdbrep.dll         C:\ObjectARX 2010\inc-x64                                                                                                       140 kB      2009/02/09 00:00        
acdbmgdbrep.dll         C:\ObjectARX 2011\inc                                                                                                           140 kB      2010/02/09 20:07        
acdbmgdbrep.dll         C:\Program Files\Autodesk\ACADM 2011                                                                                            144 kB      2010/02/09 22:16    

So It looks like the 32/64 bit versions are different for 2010
« Last Edit: July 18, 2010, 03:26:12 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8718
  • AKA Daniel
Re: Upgrade VS project to x64 ?
« Reply #17 on: July 18, 2010, 06:12:01 AM »
sinc's right...besides the occasional goof, I.e. a function call that returns an Int32 on 32bit machine and an Int64 on x64, it shouldn't matter what version you reference, your code will always be Jitted with the module Acad has loaded.

There are 32bit, 64bit versions of these modules only because of the unmanaged portion, but that's all stuff you can't access anyway.

Now if somewhere in your project, your referencing a 32bit COM and trying to use it in a 64bit process, that will cause things to fail.

LE3

  • Guest
Re: Upgrade VS project to x64 ?
« Reply #18 on: July 18, 2010, 09:59:48 AM »
So It looks like the 32/64 bit versions are different for 2010

Thank you Kerry.

Same conclusion here.

LE3

  • Guest
Re: Upgrade VS project to x64 ?
« Reply #19 on: July 19, 2010, 12:50:13 AM »
...so, have to become more familiar with x64 that it is somehow new to me, was using xp win32 for a long time...
got this laptop with windows vista home premium

downloaded from here some x64 files, and will tried to see how they load or work... (did not found a dbx/arx x64 from a custom object build, anyone have one?)

one interesting part, that i found out, is that did a test with one of my custom objects that also have a com wrapper (for the properties palette)
build it for x64 - no errors - and once it is loaded an error it is shown on the line command: Failed to register COM server (admin privileges, needed? Regsvr32.exe?)
but still all works, the arx companion it is loaded and all the commands works..... :?
« Last Edit: July 19, 2010, 12:56:25 AM by LE3 »

LE3

  • Guest
Re: Upgrade VS project to x64 ?
« Reply #20 on: July 22, 2010, 11:55:31 AM »
I have been able to resolved most of my issues.

OS Win.Vista.Home.Premium.x64

1. For the COM wrapper(DBX) to be register it is required to disable the: User Account Control (UAC) (a tip I got from the adesk arx forum, and that I have no idea at all, was for so many years in the win32 arena...).

2. Make sure to use the assemblies from the ARX SDK and target to x64!, and for the Autodesk.AutoCAD.Interop.Common.dll and Autodesk.AutoCAD.Interop.dll
use the 'browse' when doing the reference, not the COM tab.

3. For COM calls in your solution like:
Code: [Select]
AcadApplication acAppCOMObj = Application.AcadApplication as AcadApplication;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
    DBObject obj = tr.GetObject(res.ObjectId, OpenMode.ForRead);
    ObjEnt = acAppCOMObj.ActiveDocument.HandleToObject(obj.Handle.ToString());
    tr.Commit();
}
Can be replace by:
Code: [Select]
using (Transaction tr = db.TransactionManager.StartTransaction())
{
      DBObject obj = tr.GetObject(res.ObjectId, OpenMode.ForRead, false) as DBObject;
      if (obj != null)
      {
           ObjEnt = obj.AcadObject; //<<=
     }
      tr.Commit();
}

4. There were some other calls in my code, that work in win32 but not in x64, I will try to document that, and once I get the chance to posted here, when possible.

5. Still I have the issue to focus to AutoCAD drawing area, after clicking a button from a modeless form, to make a selection (via GetEntity), when you get the cross hairs, instead of the pick box, so you have to make a click first to make the focus and then be able to do the selection, what it is interesting is that if you do this from a debug session, you don't see this issue... hmm

Have tried, with - no success:
Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView();
SetFocus(Autodesk.AutoCAD.ApplicationServices.Application.MainWindow.Handle);
SetForegroundWindow(Autodesk.AutoCAD.ApplicationServices.Application.MainWindow.Handle);

mwrfdot

  • Guest
Re: Upgrade VS project to x64 ?
« Reply #21 on: July 23, 2010, 01:40:24 PM »
You may also need to set your Advanced Compile Settings to target "AnyCPU" (the default is 32bit), if you are progamming only in .NET this will allow your app on either 32bit or 64bit ACad/Windows.