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

Losing Active Document

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
375 Views, 4 Replies

Losing Active Document

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
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

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
Message 3 of 5
Anonymous
in reply to: Anonymous

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
Message 4 of 5
Anonymous
in reply to: Anonymous

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
Message 5 of 5
Anonymous
in reply to: Anonymous

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

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