.NET

Reply
Valued Contributor
tanerpro
Posts: 83
Registered: ‎10-07-2005
Message 1 of 4 (357 Views)

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

357 Views, 3 Replies
08-07-2013 08:21 AM

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,

Windows 7 (x64)
AutoCAD 2012 (x64)
Valued Contributor
tanerpro
Posts: 83
Registered: ‎10-07-2005
Message 2 of 4 (315 Views)

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

08-13-2013 10:23 AM 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)

 

 

Windows 7 (x64)
AutoCAD 2012 (x64)
Valued Mentor
gasty1001
Posts: 450
Registered: ‎04-11-2010
Message 3 of 4 (309 Views)

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

08-13-2013 11:21 AM 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

 

 

 

 

Member
Alex'89
Posts: 4
Registered: ‎11-13-2013
Message 4 of 4 (183 Views)

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

12-05-2013 05:55 AM 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.)

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community