.NET

Reply
*PeterG
Message 1 of 5 (112 Views)

Losing Active Document

112 Views, 4 Replies
11-13-2007 04:20 AM
Hi.

I have a problem with implemented interfaces that race events in my code.

Everytime I call a referenced assembly and that assembly races en event in
my code, then it seems that I have lost connection to the MdiActiveDocument.
When I try to create an instance of Editor ed =
acadApp.DocumentManager.MdiActiveDocument.Editor;
Then I get the following error : "Object reference not set to an instance of
an object".

If I before calling the referenced assembly sets the MdiActiveDocument to a
local variable and then use that variable to create an instance of Editor
ed = acadApp.DocumentManager.MdiActiveDocument.Editor; then it works.
But when I am trying to use Editor ed, I get an error "eNotApplicable".

Is there a known problem using imlemented interfaces and their events?

Best regards
Peter
*Tony Tanzillo
Message 2 of 5 (112 Views)

Re: Losing Active Document

11-13-2007 07:38 AM in reply to: *PeterG
You can't get much help without showing the
code that has the problem, and giving more
info on what exactly is firing the event.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"PeterG" wrote in message news:5776033@discussion.autodesk.com...
Hi.

I have a problem with implemented interfaces that race events in my code.

Everytime I call a referenced assembly and that assembly races en event in
my code, then it seems that I have lost connection to the MdiActiveDocument.
When I try to create an instance of Editor ed =
acadApp.DocumentManager.MdiActiveDocument.Editor;
Then I get the following error : "Object reference not set to an instance of
an object".

If I before calling the referenced assembly sets the MdiActiveDocument to a
local variable and then use that variable to create an instance of Editor
ed = acadApp.DocumentManager.MdiActiveDocument.Editor; then it works.
But when I am trying to use Editor ed, I get an error "eNotApplicable".

Is there a known problem using imlemented interfaces and their events?

Best regards
Peter
*PeterG
Message 3 of 5 (112 Views)

Re: Losing Active Document

11-14-2007 06:05 AM in reply to: *PeterG
Hi Tony.

There is no code to show that can explain what migth go wrong.
But I can try to explain it a little better.

I have an assembly that runs in Autodesk.
The assembly implements a couple of Interfaces with Events that I listen to.
The assembly also have a reference to another assembly that triggers the
implemented Events in my assembly.

The workfloow is like this.
1. The user selects a tool in Autodesk to Move a point.
2. In my assembly I raise an event SelectionChangedEvent in the referenced
assembly.
3. The referenced assembly then raises an event back in my assembly
MovePointEvent.

The problem here is when this event triggers in my assembly I seem to have
lost the MdiActiveDocument. When I try to lock the document or try to create
an Editor object like this :

ApplicationServices.DocumentLock dLock =
ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();

I get an error that tells me to create an new instance of the object. The
problem is that I no longer has an active document.

If I create a static object of the ActiveDocument before step 2, and then
uses it in step 3, then I can create a DocumentLock object and an Editor
object from the static ActiveDocument, but I can't use any of the Editor
object methodes.

Is there something speficic I have to do to not lose the Document every time
an referenced assembly triggers an event in my assembly?

Regards Peter


"Tony Tanzillo" wrote in message
news:5776274@discussion.autodesk.com...
You can't get much help without showing the
code that has the problem, and giving more
info on what exactly is firing the event.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"PeterG" wrote in message
news:5776033@discussion.autodesk.com...
Hi.

I have a problem with implemented interfaces that race events in my code.

Everytime I call a referenced assembly and that assembly races en event in
my code, then it seems that I have lost connection to the MdiActiveDocument.
When I try to create an instance of Editor ed =
acadApp.DocumentManager.MdiActiveDocument.Editor;
Then I get the following error : "Object reference not set to an instance of
an object".

If I before calling the referenced assembly sets the MdiActiveDocument to a
local variable and then use that variable to create an instance of Editor
ed = acadApp.DocumentManager.MdiActiveDocument.Editor; then it works.
But when I am trying to use Editor ed, I get an error "eNotApplicable".

Is there a known problem using imlemented interfaces and their events?

Best regards
Peter
*Tony Tanzillo
Message 4 of 5 (112 Views)

Re: Losing Active Document

11-14-2007 02:57 PM in reply to: *PeterG
Sorry, Your explaination is extremely vague and attempts
to describe a failure in your code. I can't see how there
can be no code to show that can explain it, that's just
not the case.

Don't make assumptions that there is nothing wrong
with your code, and use that as the reason for not
posting it.

Without seeing that code, no one here can help you.

BTW, it's 'AutoCAD' not 'Autodesk'


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"PeterG" wrote in message news:5777261@discussion.autodesk.com...
Hi Tony.

There is no code to show that can explain what migth go wrong.
But I can try to explain it a little better.

I have an assembly that runs in Autodesk.
The assembly implements a couple of Interfaces with Events that I listen to.
The assembly also have a reference to another assembly that triggers the
implemented Events in my assembly.

The workfloow is like this.
1. The user selects a tool in Autodesk to Move a point.
2. In my assembly I raise an event SelectionChangedEvent in the referenced
assembly.
3. The referenced assembly then raises an event back in my assembly
MovePointEvent.

The problem here is when this event triggers in my assembly I seem to have
lost the MdiActiveDocument. When I try to lock the document or try to create
an Editor object like this :

ApplicationServices.DocumentLock dLock =
ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();

I get an error that tells me to create an new instance of the object. The
problem is that I no longer has an active document.

If I create a static object of the ActiveDocument before step 2, and then
uses it in step 3, then I can create a DocumentLock object and an Editor
object from the static ActiveDocument, but I can't use any of the Editor
object methodes.

Is there something speficic I have to do to not lose the Document every time
an referenced assembly triggers an event in my assembly?

Regards Peter


"Tony Tanzillo" wrote in message
news:5776274@discussion.autodesk.com...
You can't get much help without showing the
code that has the problem, and giving more
info on what exactly is firing the event.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"PeterG" wrote in message
news:5776033@discussion.autodesk.com...
Hi.

I have a problem with implemented interfaces that race events in my code.

Everytime I call a referenced assembly and that assembly races en event in
my code, then it seems that I have lost connection to the MdiActiveDocument.
When I try to create an instance of Editor ed =
acadApp.DocumentManager.MdiActiveDocument.Editor;
Then I get the following error : "Object reference not set to an instance of
an object".

If I before calling the referenced assembly sets the MdiActiveDocument to a
local variable and then use that variable to create an instance of Editor
ed = acadApp.DocumentManager.MdiActiveDocument.Editor; then it works.
But when I am trying to use Editor ed, I get an error "eNotApplicable".

Is there a known problem using imlemented interfaces and their events?

Best regards
Peter
*PeterG
Message 5 of 5 (112 Views)

Re: Losing Active Document

11-16-2007 04:29 AM in reply to: *PeterG
Hi Tony.

The problem was in the code when I Raised the Event.
That code started a new thread. So I have changed that code and it works
fine now.

Regards
Peter

"Tony Tanzillo" wrote in message
news:5778071@discussion.autodesk.com...
Sorry, Your explaination is extremely vague and attempts
to describe a failure in your code. I can't see how there
can be no code to show that can explain it, that's just
not the case.

Don't make assumptions that there is nothing wrong
with your code, and use that as the reason for not
posting it.

Without seeing that code, no one here can help you.

BTW, it's 'AutoCAD' not 'Autodesk'


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"PeterG" wrote in message
news:5777261@discussion.autodesk.com...
Hi Tony.

There is no code to show that can explain what migth go wrong.
But I can try to explain it a little better.

I have an assembly that runs in Autodesk.
The assembly implements a couple of Interfaces with Events that I listen to.
The assembly also have a reference to another assembly that triggers the
implemented Events in my assembly.

The workfloow is like this.
1. The user selects a tool in Autodesk to Move a point.
2. In my assembly I raise an event SelectionChangedEvent in the referenced
assembly.
3. The referenced assembly then raises an event back in my assembly
MovePointEvent.

The problem here is when this event triggers in my assembly I seem to have
lost the MdiActiveDocument. When I try to lock the document or try to create
an Editor object like this :

ApplicationServices.DocumentLock dLock =
ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();

I get an error that tells me to create an new instance of the object. The
problem is that I no longer has an active document.

If I create a static object of the ActiveDocument before step 2, and then
uses it in step 3, then I can create a DocumentLock object and an Editor
object from the static ActiveDocument, but I can't use any of the Editor
object methodes.

Is there something speficic I have to do to not lose the Document every time
an referenced assembly triggers an event in my assembly?

Regards Peter


"Tony Tanzillo" wrote in message
news:5776274@discussion.autodesk.com...
You can't get much help without showing the
code that has the problem, and giving more
info on what exactly is firing the event.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"PeterG" wrote in message
news:5776033@discussion.autodesk.com...
Hi.

I have a problem with implemented interfaces that race events in my code.

Everytime I call a referenced assembly and that assembly races en event in
my code, then it seems that I have lost connection to the MdiActiveDocument.
When I try to create an instance of Editor ed =
acadApp.DocumentManager.MdiActiveDocument.Editor;
Then I get the following error : "Object reference not set to an instance of
an object".

If I before calling the referenced assembly sets the MdiActiveDocument to a
local variable and then use that variable to create an instance of Editor
ed = acadApp.DocumentManager.MdiActiveDocument.Editor; then it works.
But when I am trying to use Editor ed, I get an error "eNotApplicable".

Is there a known problem using imlemented interfaces and their events?

Best regards
Peter
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 or visit the Installation and Licensing Forum to get help installing your software.