.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Method not found: 'Int64 Autodesk.AutoCAD.Interop.IAcadApplication.get_HWND()'.

3 REPLIES 3
Reply
Message 1 of 4
tanerpro
1053 Views, 3 Replies

Method not found: 'Int64 Autodesk.AutoCAD.Interop.IAcadApplication.get_HWND()'.

Hello,

When I build my application in 32 bit windows, I got this error in 64 bit windows

System.MissingMethodException: Method not found: 'Int32 Autodesk.AutoCAD.Interop.IAcadApplication.get_HWND()'.

 

And when I build it in 64 bit windows, I got

System.MissingMethodException: Method not found: 'Int64 Autodesk.AutoCAD.Interop.IAcadApplication.get_HWND()'.

 

What can I do?

Thanks,

3 REPLIES 3
Message 2 of 4
tanerpro
in reply to: tanerpro

I think it is due to the getting hwnd of autocad. I am using this hwnd to show the userforms owner.

If anybody has a different suggestion, I can change my code.

 

Regards,

AcadHwnd = Acad.HWND

.

.

.

owner = New WindowWrapper(CType(AcadHwnd, IntPtr))

.

.

.

Dim form1 As New Form1

form1.Show(owner)

 

 

Message 3 of 4
hgasty1001
in reply to: tanerpro

Hi,

 

Not sure about your use case, but the standar way to show a modal dialog in AutoCAD is via Application.ShowModalDialog(DialogInstance).

 

Gaston Nunez

 

 

 

 

Message 4 of 4
Alex'89
in reply to: tanerpro

As I understood, the HWND property in IAcadApplication is declared as int in 32-bit AutoCAD installation. In 64-bit AutoCAD installation, however, it's declared as LONG_PTR. So when you compile your project in 32-bit platform, the compiler uses int, and when you compile in 64-bit, is uses LONG_PTR.

It is possible, however, to use .NET InvokeMember() function. I DO NOT KNOW whether it is safe or not; but it works for me.

Getting HWND:

acadApp.GetType().InvokeMember("HWND", System.Reflection.BindingFlags.GetProperty, null, acadApp, null)

Use HWND in program:

BringWindowToTop((IntPtr)System.Convert.ToInt64( acadApp.GetType().InvokeMember("HWND", System.Reflection.BindingFlags.GetProperty, null, acadApp, null)));

In the second example, we use System.Convert.ToInt64() at first (to ensure we can use the 64-bit AutoCAD return value), and then convert the result to IntPtr (handle type).

I don't know whether it is good or bad; I just hope it is correct.)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost