.NET

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

Dim WithEvents Exception throw

73 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 (73 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 (73 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 (73 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!