.NET

Reply
Valued Contributor
61 Posts
0 Kudos
Registered: ‎06-19-2002
Post 1 of 4

Dim WithEvents Exception throw

74 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
Post 2 of 4

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
61 Posts
0 Kudos
Registered: ‎06-19-2002
Post 3 of 4

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
61 Posts
0 Kudos
Registered: ‎06-19-2002
Post 4 of 4

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 interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!