C# .NET AcadDocument.Activate Problem

C# .NET AcadDocument.Activate Problem

Anonymous
Not applicable
1,960 Views
5 Replies
Message 1 of 6

C# .NET AcadDocument.Activate Problem

Anonymous
Not applicable
Hi Everyone,

I think there is a problem with the AcadDocument.Activate event when used in
C#.NET (possibly related to the wrapper). In the object browser, it doesn't
show up like the rest of the events (with a lightning bolt icon next to it)
and for all intents and purposes, appears to be a method. I looked in the
AutoCAD dev help file (that comes with AutoCAD) and lo and behold, there is
a method called Activate() AND an event called Activate.

In VB6 I never had a problem differentiating between the two of these. To
be honest, I never used the Activate() method, only the event. Now, in C#,
I am trying to use the event and I get an error at compile-time:

C:\VSJ\ACADBOM\BOMAX\BomDocument.cs(117): 'AutoCAD.IAcadDocument.Activate()'
denotes a 'method' which is not valid in the given context

This is the code:

// Instantiate the event delegates.
_docActivated = new
_DAcadDocumentEvents_ActivateEventHandler(onDocActivate);
_docDeactivate = new
_DAcadDocumentEvents_DeactivateEventHandler(onDocDeactivate);
_beginClose = new
_DAcadDocumentEvents_BeginCloseEventHandler(onBeginClose);
_beginSave = new
_DAcadDocumentEvents_BeginSaveEventHandler(onBeginSave);
_endSave = new _DAcadDocumentEvents_EndSaveEventHandler(onEndSave);

// Add our event handlers to the document's notify list.
acdDoc.Activate += _docActivate; // PROBLEM IS HERE
acdDoc.Deactivate += _docDeactivate;
acdDoc.BeginClose += _beginClose;
acdDoc.BeginSave += _beginSave;
acdDoc.EndSave += _endSave;

Anyone have any ideas?

Thanks,
Eric
0 Likes
1,961 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Does anyone have a solution to this or a suggestion on what to try?

"Eric Olson" wrote in message
news:9897C22F14BECEE27FE178223DAF61ED@in.WebX.maYIadrTaRb...
> Hi Everyone,
>
> I think there is a problem with the AcadDocument.Activate event when used
in
> C#.NET (possibly related to the wrapper). In the object browser, it
doesn't
> show up like the rest of the events (with a lightning bolt icon next to
it)
> and for all intents and purposes, appears to be a method. I looked in the
> AutoCAD dev help file (that comes with AutoCAD) and lo and behold, there
is
> a method called Activate() AND an event called Activate.
>
> In VB6 I never had a problem differentiating between the two of these. To
> be honest, I never used the Activate() method, only the event. Now, in
C#,
> I am trying to use the event and I get an error at compile-time:
>
> C:\VSJ\ACADBOM\BOMAX\BomDocument.cs(117):
'AutoCAD.IAcadDocument.Activate()'
> denotes a 'method' which is not valid in the given context
>
> This is the code:
>
> // Instantiate the event delegates.
> _docActivated = new
> _DAcadDocumentEvents_ActivateEventHandler(onDocActivate);
> _docDeactivate = new
> _DAcadDocumentEvents_DeactivateEventHandler(onDocDeactivate);
> _beginClose = new
> _DAcadDocumentEvents_BeginCloseEventHandler(onBeginClose);
> _beginSave = new
> _DAcadDocumentEvents_BeginSaveEventHandler(onBeginSave);
> _endSave = new _DAcadDocumentEvents_EndSaveEventHandler(onEndSave);
>
> // Add our event handlers to the document's notify list.
> acdDoc.Activate += _docActivate; // PROBLEM IS HERE
> acdDoc.Deactivate += _docDeactivate;
> acdDoc.BeginClose += _beginClose;
> acdDoc.BeginSave += _beginSave;
> acdDoc.EndSave += _endSave;
>
> Anyone have any ideas?
>
> Thanks,
> Eric
>
>
>
0 Likes
Message 3 of 6

Anonymous
Not applicable
eric,

sorry to say that i missed it also, what i think (out of expirience with
handling voloview with vb.net) is that the change of privilages of the
sinkhelperclasses within the interop.autocad.dll has for document_activate a
handler called "Activate", this name is so global that many other classes will
use it also and so you (and i) don't get it running for autocad.

what happened in voloview: that was a function "Layout" i missed, also a name
used by form-classes..., the interop-file had a function called "CtlLayout"
instead and that worked. so it seems that the translation was done from .net
while creating the interop-file.

the chance i see is if someone with more knowledge than i have could edit the
interop.autocad.il-file and rename the "Activate"-handlings.

i hope that my idea gives a kick to someone and is a help for us.

thanx in advance, - alfred -



In article <759F4E5745D904C3A101A8229331DAEA@in.WebX.maYIadrTaRb>,
edo@rahco.com says...
> Does anyone have a solution to this or a suggestion on what to try?
>
> "Eric Olson" wrote in message
> news:9897C22F14BECEE27FE178223DAF61ED@in.WebX.maYIadrTaRb...
> > Hi Everyone,
> >
> > I think there is a problem with the AcadDocument.Activate event when used
> in
> > C#.NET (possibly related to the wrapper). In the object browser, it
> doesn't
> > show up like the rest of the events (with a lightning bolt icon next to
> it)
> > and for all intents and purposes, appears to be a method. I looked in the
> > AutoCAD dev help file (that comes with AutoCAD) and lo and behold, there
> is
> > a method called Activate() AND an event called Activate.
> >
> > In VB6 I never had a problem differentiating between the two of these. To
> > be honest, I never used the Activate() method, only the event. Now, in
> C#,
> > I am trying to use the event and I get an error at compile-time:
> >
> > C:\VSJ\ACADBOM\BOMAX\BomDocument.cs(117):
> 'AutoCAD.IAcadDocument.Activate()'
> > denotes a 'method' which is not valid in the given context
> >
> > This is the code:
> >
> > // Instantiate the event delegates.
> > _docActivated = new
> > _DAcadDocumentEvents_ActivateEventHandler(onDocActivate);
> > _docDeactivate = new
> > _DAcadDocumentEvents_DeactivateEventHandler(onDocDeactivate);
> > _beginClose = new
> > _DAcadDocumentEvents_BeginCloseEventHandler(onBeginClose);
> > _beginSave = new
> > _DAcadDocumentEvents_BeginSaveEventHandler(onBeginSave);
> > _endSave = new _DAcadDocumentEvents_EndSaveEventHandler(onEndSave);
> >
> > // Add our event handlers to the document's notify list.
0 Likes
Message 4 of 6

Anonymous
Not applicable
I delved into the interop DLL file (I am using AcadX's "fixed" one) and
renamed two instances of Activate to DocActivate, then recompiled the
assembly. For an example on how to decompile an interop DLL and then
recompile it after you are done changing things, go to
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q309336.

In case someone else has this problem, I will post the two lines that I
changed. Be careful though, because there are many other instances of the
word 'Activate' that you want to leave alone:

From:
.event AutoCAD._DAcadDocumentEvents_ActivateEventHandler Activate

To:
.event AutoCAD._DAcadDocumentEvents_ActivateEventHandler DocActivate

From:
.method public virtual instance void

Activate() cil managed

To:
.method public virtual instance void

DocActivate() cil managed


Now I can simply += on AcadDocument.DocActivate instead of
AcadDocument.Activate and it works perfectly. You still refer to the
originally named delegates, however, when assigning your handling method.

Anyway, thanks for the inspiration, Alfred!

Eric

"Eric Olson" wrote in message
news:9897C22F14BECEE27FE178223DAF61ED@in.WebX.maYIadrTaRb...
> Hi Everyone,
>
> I think there is a problem with the AcadDocument.Activate event when used
in
> C#.NET (possibly related to the wrapper). In the object browser, it
doesn't
> show up like the rest of the events (with a lightning bolt icon next to
it)
> and for all intents and purposes, appears to be a method. I looked in the
> AutoCAD dev help file (that comes with AutoCAD) and lo and behold, there
is
> a method called Activate() AND an event called Activate.
>
> In VB6 I never had a problem differentiating between the two of these. To
> be honest, I never used the Activate() method, only the event. Now, in
C#,
> I am trying to use the event and I get an error at compile-time:
>
> C:\VSJ\ACADBOM\BOMAX\BomDocument.cs(117):
'AutoCAD.IAcadDocument.Activate()'
> denotes a 'method' which is not valid in the given context
>
> This is the code:
>
> // Instantiate the event delegates.
> _docActivated = new
> _DAcadDocumentEvents_ActivateEventHandler(onDocActivate);
> _docDeactivate = new
> _DAcadDocumentEvents_DeactivateEventHandler(onDocDeactivate);
> _beginClose = new
> _DAcadDocumentEvents_BeginCloseEventHandler(onBeginClose);
> _beginSave = new
> _DAcadDocumentEvents_BeginSaveEventHandler(onBeginSave);
> _endSave = new _DAcadDocumentEvents_EndSaveEventHandler(onEndSave);
>
> // Add our event handlers to the document's notify list.
> acdDoc.Activate += _docActivate; // PROBLEM IS HERE
> acdDoc.Deactivate += _docDeactivate;
> acdDoc.BeginClose += _beginClose;
> acdDoc.BeginSave += _beginSave;
> acdDoc.EndSave += _endSave;
>
> Anyone have any ideas?
>
> Thanks,
> Eric
>
>
>
0 Likes
Message 5 of 6

Anonymous
Not applicable
eric,

great, thank's a lot, alfred


In article <501C6E5E23A1CF7013495E1ED477E51E@in.WebX.maYIadrTaRb>,
edo@rahco.com says...
> I delved into the interop DLL file (I am using AcadX's "fixed" one) and
> renamed two instances of Activate to DocActivate, then recompiled the
> assembly. For an example on how to decompile an interop DLL and then
> recompile it after you are done changing things, go to
> http://support.microsoft.com/default.aspx?scid=kb;en-us;Q309336.
>
> In case someone else has this problem, I will post the two lines that I
> changed. Be careful though, because there are many other instances of the
> word 'Activate' that you want to leave alone:
>
> From:
> .event AutoCAD._DAcadDocumentEvents_ActivateEventHandler Activate
>
> To:
> .event AutoCAD._DAcadDocumentEvents_ActivateEventHandler DocActivate
>
> From:
> .method public virtual instance void
>
> Activate() cil managed
>
> To:
> .method public virtual instance void
>
> DocActivate() cil managed
>
>
> Now I can simply += on AcadDocument.DocActivate instead of
> AcadDocument.Activate and it works perfectly. You still refer to the
> originally named delegates, however, when assigning your handling method.
>
> Anyway, thanks for the inspiration, Alfred!
>
> Eric
>
> "Eric Olson" wrote in message
> news:9897C22F14BECEE27FE178223DAF61ED@in.WebX.maYIadrTaRb...
> > Hi Everyone,
> >
> > I think there is a problem with the AcadDocument.Activate event when used
0 Likes
Message 6 of 6

Anonymous
Not applicable
Hi Eri,
Could you please answer for following question, I thought you are also working on similar kind problem which am working on. I have embedded AutoCAD Inplace activation control in my C# application and opened a document with the help of control. am trying to get a reference for AutoCAD application and AutoCAD document objects. I have added references to acax16enu.tlb, axdb16enu.tlb ,acmgd.dll, acdbmgd.dll files.

Could you please explain me how Can I get the reference for AutoCAD application object reference with in C# application so that I can get the drawing object reference from it.

I would appreciate your help.
Regards,
Ramesh
0 Likes