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

Dim WithEvents Exception throw

3 REPLIES 3
Reply
Message 1 of 4
rtejada
260 Views, 3 Replies

Dim WithEvents Exception throw

To get all the application and document event handlers in visual studio 2005 I create the following variables at a class level

Dim WithEvents AcadApp As AcadApplication = CType(Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication, AcadApplication)

Dim WithEvents AcadDoc As AcadDocument = CType(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument, AcadDocument)

When I execute the code, It goes fine trought the AcadApps declaration but then it throws a exception at the AcadDoc declaration.
Is there any diference between both objects?
Please advice
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: rtejada

You're confusing COM/ActiveX types with managed types.

There is no AcadApplication or AcadDocument in the
managed API, those are COM objects, not managed types,
so you can't use the MdiActiveDocument property (whose
value is the managed 'Document' type).

You need to use:

Dim WithEvents AcadDoc As AcadDocument = CType(
AcadApp.ActiveDocument, AcadDocument)

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5333442@discussion.autodesk.com...
To get all the application and document event handlers in visual studio 2005 I create the following variables at a class level

Dim WithEvents AcadApp As AcadApplication = CType(Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication, AcadApplication)

Dim WithEvents AcadDoc As AcadDocument = CType(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument, AcadDocument)

When I execute the code, It goes fine trought the AcadApps declaration but then it throws a exception at the AcadDoc declaration.
Is there any diference between both objects?
Please advice
Message 3 of 4
rtejada
in reply to: rtejada

Thank you Tony, I am out of the office, I will try your suggestion ASAP
Message 4 of 4
rtejada
in reply to: rtejada

Thanks again Tony, I was able to test it and it works. It seems that visual 2003 was not sensitive about it, so I just realize it with the visual studio 2005.

Regards

Raul

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