.NET

Reply
Valued Contributor
rtejada
Posts: 61
Registered: ‎06-19-2002
Message 1 of 4 (68 Views)

Dim WithEvents Exception throw

68 Views, 3 Replies
09-18-2006 07:51 PM
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
*Tony Tanzillo
Message 2 of 4 (68 Views)

Re: Dim WithEvents Exception throw

09-19-2006 01:02 AM 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
Valued Contributor
rtejada
Posts: 61
Registered: ‎06-19-2002
Message 3 of 4 (68 Views)

Re: Dim WithEvents Exception throw

09-19-2006 06:46 AM in reply to: rtejada
Thank you Tony, I am out of the office, I will try your suggestion ASAP
Valued Contributor
rtejada
Posts: 61
Registered: ‎06-19-2002
Message 4 of 4 (68 Views)

Re: Dim WithEvents Exception throw

09-19-2006 11:10 AM 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

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