.NET

.NET

Reply
*Maksim Sestic
Message 1 of 10 (239 Views)

Externally loading an assembly into running ACAD app. namespace

239 Views, 9 Replies
09-21-2005 11:33 PM


I need to load .NET DLL into running ACAD
application namespace, but externally - out of another process (Startup module,
source excerpt below). How possibly can I get it working?

 

Startup module (that fires ACAD up) references
following libs found in GAC:

- Autodesk.AutoCAD.Interop.dll

-
Autodesk.AutoCAD.Interop.Common.dll


size=2>
 


size=2>Imports

Autodesk.AutoCAD.Interop

 

''' Startup
module that fires up ACAD
 


size=2>Module
Startup

 
Sub
Main()

 

   
color=#008080>''' Start ACAD the easy way... No error
checking...
 


size=2>    Dim
oACAD
color=#0000ff size=2>As

Autodesk.AutoCAD.Interop.AcadApplication

    oACAD =
New
Autodesk.AutoCAD.Interop.AcadApplication

 


   
color=#008080>''' >>> I simply don't want to load assembly
via Lisp here.

    '''
>>> I've been thinking of using P/Invoke, still don't know what
set of

    ''' >>>
acad.exe functions is responsible for netload-ing an assembly.

    ''' >>>
Using a bit more managed approach is even more welcome
:-)
   
oACAD.ActiveDocument.SendCommand( _

    "(command "
+ Chr(34) + _

    "NETLOAD" +
Chr(34) + " " + Chr(34) + _

   
"TCGDotNet16.dll" + Chr(34) + ")" + vbLf)

 
End

size=2>Sub


color=#0000ff size=2>End

color=#0000ff size=2>Module


color=#0000ff size=2>
 


color=#0000ff size=2>Thanks for any
suggestion on that matter.


color=#0000ff size=2>
 


color=#0000ff size=2>
color=#000000>Regards,


color=#0000ff size=2>Maksim
Sestic
 

 
*Tony Tanzillo
Message 2 of 10 (239 Views)

Re: Externally loading an assembly into running ACAD app. namespace

09-22-2005 05:48 AM in reply to: *Maksim Sestic
Didn't you read my previous reply on this?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Maksim Sestic" wrote in message news:4963788@discussion.autodesk.com...
I need to load .NET DLL into running ACAD application namespace, but externally - out of another process.......
*Tony Tanzillo
Message 3 of 10 (239 Views)

Re: Externally loading an assembly into running ACAD app. namespace

09-22-2005 05:54 AM in reply to: *Maksim Sestic
Sorry, my previous reply doesn't explain much.

Are you sure you understand what P/Invoke is?

I ask because it is of no use to do what you need.
You can do it by creating a simple COM server in
.NET, and loading that via the GetInterfaceObject
method of AcadApplication. Once the COM server
is loaded, it can then load any assemblies using
the Assembly.Load method. Or, you can just make
the main application that you need to load into
AutoCAD a COM server as well. If you do that, and
use IExtensionApplication, the Initialize() member
will still be called.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Maksim Sestic" wrote in message news:4963788@discussion.autodesk.com...
I need to load .NET DLL into running ACAD application namespace, but externally - out of another process (Startup module, source excerpt below). How possibly can I get it working?

Startup module (that fires ACAD up) references following libs found in GAC:
- Autodesk.AutoCAD.Interop.dll
- Autodesk.AutoCAD.Interop.Common.dll

Imports Autodesk.AutoCAD.Interop

''' Startup module that fires up ACAD
Module Startup
Sub Main()

''' Start ACAD the easy way... No error checking...
Dim oACAD As Autodesk.AutoCAD.Interop.AcadApplication
oACAD = New Autodesk.AutoCAD.Interop.AcadApplication

''' >>> I simply don't want to load assembly via Lisp here.
''' >>> I've been thinking of using P/Invoke, still don't know what set of
''' >>> acad.exe functions is responsible for netload-ing an assembly.
''' >>> Using a bit more managed approach is even more welcome :-)
oACAD.ActiveDocument.SendCommand( _
"(command " + Chr(34) + _
"NETLOAD" + Chr(34) + " " + Chr(34) + _
"TCGDotNet16.dll" + Chr(34) + ")" + vbLf)
End Sub
End Module

Thanks for any suggestion on that matter.

Regards,
Maksim Sestic
*Maksim Sestic
Message 4 of 10 (239 Views)

Re: Externally loading an assembly into running ACAD app. namespace

09-24-2005 06:48 AM in reply to: *Maksim Sestic

Tony,

 

I'm trying with COM server and GetInterfaceObject
as you suggested, but I still can't make it work. Here's what I do
(presumably wrong):

 

1) COM server component named "LoaderServer" -
consists of a public class LoaderClass with Initialize() method that actually
loads .NET assembly named "DotNet.dll":

 

Imports
size=2> System.Reflection

 

<ComClass(LoaderClass.ClassId,
LoaderClass.InterfaceId, LoaderClass.EventsId)> _

Public
size=2>
Class
LoaderClass

 

#
size=2>Region
"COM GUIDs"

 
Public
Const
size=2> ClassId
As
String =
"5B5EBDA2-7A4E-45F8-9CA1-CE61435197CA"

 
Public
Const
size=2> InterfaceId
As
String =
"A3747BA4-DC24-4239-BF8C-7005272AA365"

 
Public
Const
size=2> EventsId
As
String =
"A9EB5F72-B513-4EE3-9A0E-5BBA2CB29BCB"

#
size=2>End

size=2>Region

 

Public
size=2>
Sub
color=#0000ff size=2>New
()

 
MyBase
.New()

End
Sub

 

Public
size=2>
Sub
Initialize()

 
[Assembly].Load("D:\Test\DotNet.dll")

End
Sub

 

End
Class

 

2) There is also a Startup application
called "Startup.exe" that fires ACAD up and initializes COM server via
GetInterfaceObject() call:

 


size=2>Imports

Autodesk.AutoCAD.Interop

 


size=2>Module
Startup

 
color=#0000ff size=2>Sub

Main()

 


color=#0000ff>   

size=2>Dim
oACAD
size=2>As

Autodesk.AutoCAD.Interop.AcadApplication

   
size=2>oACAD = New
size=2>
Autodesk.AutoCAD.Interop.AcadApplication


size=2>
 

 
color=#0000ff>  

size=2>Dim
o
size=2>As

size=2>Object


face="Courier New"> 
color=#000000>   o =
oACAD.Application.GetInterfaceObject("LoaderServer.LoaderClass")


face="Courier New" size=2>
 


face="Courier New">  End

size=2>Sub


color=#0000ff size=2>
size=2>End

size=2>Module

 

Now, everything runs OK (no errors reported) but
DotNet.dll assembly doesn't get loaded into ACAD.

 

Regards,

Maksim Sestic

 

 


size=2>
 

Sorry, my previous
reply doesn't explain much.

Are you sure you understand what P/Invoke
is?

I ask because it is of no use to do what you need.
You can do it
by creating a simple COM server in
.NET, and loading that via the
GetInterfaceObject
method of AcadApplication. Once the COM server
is
loaded, it can then load any assemblies using
the Assembly.Load
method.  Or, you can just make
the main application that you need to
load into
AutoCAD a COM server as well. If you do that, and
use
IExtensionApplication, the Initialize() member
will still be
called.

--

face=Verdana size=2>http://www.caddzone.com



size=2>AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006

href="http://www.acadxtabs.com">
size=2>http://www.acadxtabs.com



size=2>"Maksim Sestic" <

face=Verdana size=2>info@geoinova.com
>
wrote in message

face=Verdana size=2>news:4963788@discussion.autodesk.com

face=Verdana size=2>...
I need to load .NET DLL into running ACAD application
namespace, but externally - out of another process (Startup module, source
excerpt below). How possibly can I get it working?
 
Startup module
(that fires ACAD up) references following libs found in GAC:
-
Autodesk.AutoCAD.Interop.dll
-
Autodesk.AutoCAD.Interop.Common.dll
 
Imports
Autodesk.AutoCAD.Interop
 
''' Startup module that fires up ACAD

Module Startup
  Sub Main()
 
    '''
Start ACAD the easy way... No error checking...
    Dim oACAD
As Autodesk.AutoCAD.Interop.AcadApplication
    oACAD = New
Autodesk.AutoCAD.Interop.AcadApplication
 
    '''
>>> I simply don't want to load assembly via Lisp
here.
    ''' >>> I've been thinking of using
P/Invoke, still don't know what set of
    ''' >>>
acad.exe functions is responsible for netload-ing an
assembly.
    ''' >>> Using a bit more managed
approach is even more welcome :-)
   
oACAD.ActiveDocument.SendCommand( _
    "(command " + Chr(34)
+ _
    "NETLOAD" + Chr(34) + " " + Chr(34) +
_
    "TCGDotNet16.dll" + Chr(34) + ")" + vbLf)
  End
Sub
End Module
 
Thanks for any suggestion on that
matter.
 
Regards,
Maksim Sestic
*Tony Tanzillo
Message 5 of 10 (239 Views)

Re: Externally loading an assembly into running ACAD app. namespace

09-24-2005 02:13 PM in reply to: *Maksim Sestic
Assembly.Load() does not take a filename. Please look
at the docs.

You need to reference the assembly that you're going to
load, from the COM server assembly that loads it, and
then pass the Display name of the assembly to Load().

Look at the properties of the referenced assembly to
find its display name.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Maksim Sestic" wrote in message news:4966241@discussion.autodesk.com...
Tony,

I'm trying with COM server and GetInterfaceObject as you suggested, but I still can't make it work. Here's what I do (presumably wrong):

1) COM server component named "LoaderServer" - consists of a public class LoaderClass with Initialize() method that actually loads .NET assembly named "DotNet.dll":

Imports System.Reflection

_
Public Class LoaderClass

#Region "COM GUIDs"
Public Const ClassId As String = "5B5EBDA2-7A4E-45F8-9CA1-CE61435197CA"
Public Const InterfaceId As String = "A3747BA4-DC24-4239-BF8C-7005272AA365"
Public Const EventsId As String = "A9EB5F72-B513-4EE3-9A0E-5BBA2CB29BCB"
#End Region

Public Sub New()
MyBase.New()
End Sub

Public Sub Initialize()
[Assembly].Load("D:\Test\DotNet.dll")
End Sub

End Class

2) There is also a Startup application called "Startup.exe" that fires ACAD up and initializes COM server via GetInterfaceObject() call:

Imports Autodesk.AutoCAD.Interop

Module Startup
Sub Main()

Dim oACAD As Autodesk.AutoCAD.Interop.AcadApplication
oACAD = New Autodesk.AutoCAD.Interop.AcadApplication

Dim o As Object
o = oACAD.Application.GetInterfaceObject("LoaderServer.LoaderClass")

End Sub
End Module

Now, everything runs OK (no errors reported) but DotNet.dll assembly doesn't get loaded into ACAD.

Regards,
Maksim Sestic



"Tony Tanzillo" wrote in message news:4963921@discussion.autodesk.com...
Sorry, my previous reply doesn't explain much.

Are you sure you understand what P/Invoke is?

I ask because it is of no use to do what you need.
You can do it by creating a simple COM server in
.NET, and loading that via the GetInterfaceObject
method of AcadApplication. Once the COM server
is loaded, it can then load any assemblies using
the Assembly.Load method. Or, you can just make
the main application that you need to load into
AutoCAD a COM server as well. If you do that, and
use IExtensionApplication, the Initialize() member
will still be called.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Maksim Sestic" wrote in message news:4963788@discussion.autodesk.com...
I need to load .NET DLL into running ACAD application namespace, but externally - out of another process (Startup module, source excerpt below). How possibly can I get it working?

Startup module (that fires ACAD up) references following libs found in GAC:
- Autodesk.AutoCAD.Interop.dll
- Autodesk.AutoCAD.Interop.Common.dll

Imports Autodesk.AutoCAD.Interop

''' Startup module that fires up ACAD
Module Startup
Sub Main()

''' Start ACAD the easy way... No error checking...
Dim oACAD As Autodesk.AutoCAD.Interop.AcadApplication
oACAD = New Autodesk.AutoCAD.Interop.AcadApplication

''' >>> I simply don't want to load assembly via Lisp here.
''' >>> I've been thinking of using P/Invoke, still don't know what set of
''' >>> acad.exe functions is responsible for netload-ing an assembly.
''' >>> Using a bit more managed approach is even more welcome :-)
oACAD.ActiveDocument.SendCommand( _
"(command " + Chr(34) + _
"NETLOAD" + Chr(34) + " " + Chr(34) + _
"TCGDotNet16.dll" + Chr(34) + ")" + vbLf)
End Sub
End Module

Thanks for any suggestion on that matter.

Regards,
Maksim Sestic
*Maksim Sestic
Message 6 of 10 (239 Views)

Re: Externally loading an assembly into running ACAD app. namespace

09-25-2005 05:20 AM in reply to: *Maksim Sestic

Hi Tony,

 

I just did what you've suggested and still
nothing happens (assembly doesn't get loaded into ACAD). I suspect that
Initialize() part of COM server never gets executed, as it would certainly
return either success or an error. Here's the code:

 


1) COM server component named "LoaderServer" -
consists of a public class LoaderClass with Initialize() method that actually
loads .NET assembly named "DotNet". I additionally referenced an
assembly file "DotNet.dll", as per your suggestion, and changed parameter of
[Assembly].Load method to assembly display name:

 

Imports
size=2> System.Reflection

 

<ComClass(LoaderClass.ClassId,
LoaderClass.InterfaceId, LoaderClass.EventsId)> _

Public
size=2>
Class
LoaderClass

 

#
size=2>Region
"COM GUIDs"

 
Public
Const
size=2> ClassId
As
String =
"5B5EBDA2-7A4E-45F8-9CA1-CE61435197CA"

 
Public
Const
size=2> InterfaceId
As
String =
"A3747BA4-DC24-4239-BF8C-7005272AA365"

 
Public
Const
size=2> EventsId
As
String =
"A9EB5F72-B513-4EE3-9A0E-5BBA2CB29BCB"

#
size=2>End

size=2>Region

 

Public
size=2>
Sub
color=#0000ff size=2>New
()

 
MyBase
.New()

End
Sub

 

Public
size=2>
Sub
Initialize()

 
[Assembly].Load("DotNet")

End
Sub

 

End
Class

 

2) There is also a Startup application
called "Startup.exe" that fires ACAD up and initializes COM server via
GetInterfaceObject() call:

 


size=2>Imports

Autodesk.AutoCAD.Interop

 


size=2>Module
Startup

 
color=#0000ff size=2>Sub

Main()

 


color=#0000ff>   

size=2>Dim
oACAD
size=2>As

Autodesk.AutoCAD.Interop.AcadApplication

   
size=2>oACAD = New
size=2>
Autodesk.AutoCAD.Interop.AcadApplication


size=2>
 

 
color=#0000ff>  

size=2>Dim
o
size=2>As

size=2>Object


face="Courier New"> 
color=#000000>   o =
oACAD.Application.GetInterfaceObject("LoaderServer.LoaderClass")


face="Courier New" size=2>
 


face="Courier New">  End

size=2>Sub


color=#0000ff size=2>
size=2>End

size=2>Module

 

 

Regards,

Maksim Sestic

 

 

Assembly.Load()
does not take a filename. Please look
at the docs.

You need to
reference the assembly that you're going to
load, from the COM server
assembly that loads it, and
then pass the Display name of the assembly to
Load().

Look at the properties of the referenced assembly to
find its
display name.


--

face=Verdana size=2>http://www.caddzone.com



size=2>AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006

href="http://www.acadxtabs.com">
size=2>http://www.acadxtabs.com



size=2>"Maksim Sestic" <

face=Verdana size=2>info@geoinova.com
>
wrote in message

face=Verdana size=2>news:4966241@discussion.autodesk.com

face=Verdana size=2>...
Tony,
 
I'm trying with COM server and
GetInterfaceObject as you suggested, but I still can't make it work. Here's what
I do (presumably wrong):
 
1) COM server component named
"LoaderServer" - consists of a public class LoaderClass with Initialize() method
that actually loads .NET assembly named "DotNet.dll":
 
Imports
System.Reflection
 
<ComClass(LoaderClass.ClassId,
LoaderClass.InterfaceId, LoaderClass.EventsId)> _
Public Class
LoaderClass
 
#Region "COM GUIDs"
  Public Const ClassId As
String = "5B5EBDA2-7A4E-45F8-9CA1-CE61435197CA"
  Public Const
InterfaceId As String = "A3747BA4-DC24-4239-BF8C-7005272AA365"
  Public
Const EventsId As String = "A9EB5F72-B513-4EE3-9A0E-5BBA2CB29BCB"
#End
Region
 
Public Sub New()
  MyBase.New()
End
Sub
 
Public Sub Initialize()
 
[Assembly].Load("D:\Test\DotNet.dll")
End Sub
 
End
Class
 
2) There is also a Startup application called "Startup.exe"
that fires ACAD up and initializes COM server via GetInterfaceObject()
call:
 
Imports Autodesk.AutoCAD.Interop
 
Module
Startup
  Sub Main()
 
    Dim oACAD As
Autodesk.AutoCAD.Interop.AcadApplication
    oACAD = New
Autodesk.AutoCAD.Interop.AcadApplication
 
    Dim o
As Object
    o =
oACAD.Application.GetInterfaceObject("LoaderServer.LoaderClass")
 
 
End Sub
End Module
 
Now, everything runs OK (no errors reported)
but DotNet.dll assembly doesn't get loaded into
ACAD.
 
Regards,
Maksim
Sestic
 
 
 
"Tony Tanzillo" <

href="mailto:tony.tanzillo@U_KNOW_WHERE.com">
size=2>tony.tanzillo@U_KNOW_WHERE.com
>
wrote in message

face=Verdana size=2>news:4963921@discussion.autodesk.com

face=Verdana size=2>...
Sorry, my previous reply doesn't explain
much.

Are you sure you understand what P/Invoke is?

I ask because
it is of no use to do what you need.
You can do it by creating a simple COM
server in
.NET, and loading that via the GetInterfaceObject
method of
AcadApplication. Once the COM server
is loaded, it can then load any
assemblies using
the Assembly.Load method.  Or, you can just
make
the main application that you need to load into
AutoCAD a COM server
as well. If you do that, and
use IExtensionApplication, the Initialize()
member
will still be called.

--

href="http://www.caddzone.com">
size=2>http://www.caddzone.com



size=2>AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006

href="http://www.acadxtabs.com">
size=2>http://www.acadxtabs.com



size=2>"Maksim Sestic" <

face=Verdana size=2>info@geoinova.com
>
wrote in message

face=Verdana size=2>news:4963788@discussion.autodesk.com

face=Verdana size=2>...
I need to load .NET DLL into running ACAD application
namespace, but externally - out of another process (Startup module, source
excerpt below). How possibly can I get it working?
 
Startup module
(that fires ACAD up) references following libs found in GAC:
-
Autodesk.AutoCAD.Interop.dll
-
Autodesk.AutoCAD.Interop.Common.dll
 
Imports
Autodesk.AutoCAD.Interop
 
''' Startup module that fires up ACAD

Module Startup
  Sub Main()
 
    '''
Start ACAD the easy way... No error checking...
    Dim oACAD
As Autodesk.AutoCAD.Interop.AcadApplication
    oACAD = New
Autodesk.AutoCAD.Interop.AcadApplication
 
    '''
>>> I simply don't want to load assembly via Lisp
here.
    ''' >>> I've been thinking of using
P/Invoke, still don't know what set of
    ''' >>>
acad.exe functions is responsible for netload-ing an
assembly.
    ''' >>> Using a bit more managed
approach is even more welcome :-)
   
oACAD.ActiveDocument.SendCommand( _
    "(command " + Chr(34)
+ _
    "NETLOAD" + Chr(34) + " " + Chr(34) +
_
    "TCGDotNet16.dll" + Chr(34) + ")" + vbLf)
  End
Sub
End Module
 
Thanks for any suggestion on that
matter.
 
Regards,
Maksim Sestic
*Tony Tanzillo
Message 7 of 10 (239 Views)

Re: Externally loading an assembly into running ACAD app. namespace

09-25-2005 08:35 PM in reply to: *Maksim Sestic
If you suspect your Initialize() method is not being
called, then why don't you just run it in the debugger
or place a call to Editor.WriteMessage() in it, to find out?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Maksim Sestic" wrote in message news:4966390@discussion.autodesk.com...
Hi Tony,

I just did what you've suggested and still nothing happens (assembly doesn't get loaded into ACAD). I suspect that Initialize() part of COM server never gets executed, as it would certainly return either success or an error. Here's the code:

1) COM server component named "LoaderServer" - consists of a public class LoaderClass with Initialize() method that actually loads .NET assembly named "DotNet". I additionally referenced an assembly file "DotNet.dll", as per your suggestion, and changed parameter of [Assembly].Load method to assembly display name:

Imports System.Reflection

_
Public Class LoaderClass

#Region "COM GUIDs"
Public Const ClassId As String = "5B5EBDA2-7A4E-45F8-9CA1-CE61435197CA"
Public Const InterfaceId As String = "A3747BA4-DC24-4239-BF8C-7005272AA365"
Public Const EventsId As String = "A9EB5F72-B513-4EE3-9A0E-5BBA2CB29BCB"
#End Region

Public Sub New()
MyBase.New()
End Sub

Public Sub Initialize()
[Assembly].Load("DotNet")
End Sub

End Class

2) There is also a Startup application called "Startup.exe" that fires ACAD up and initializes COM server via GetInterfaceObject() call:

Imports Autodesk.AutoCAD.Interop

Module Startup
Sub Main()

Dim oACAD As Autodesk.AutoCAD.Interop.AcadApplication
oACAD = New Autodesk.AutoCAD.Interop.AcadApplication

Dim o As Object
o = oACAD.Application.GetInterfaceObject("LoaderServer.LoaderClass")

End Sub
End Module


Regards,
Maksim Sestic


"Tony Tanzillo" wrote in message news:4966307@discussion.autodesk.com...
Assembly.Load() does not take a filename. Please look
at the docs.

You need to reference the assembly that you're going to
load, from the COM server assembly that loads it, and
then pass the Display name of the assembly to Load().

Look at the properties of the referenced assembly to
find its display name.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Maksim Sestic" wrote in message news:4966241@discussion.autodesk.com...
Tony,

I'm trying with COM server and GetInterfaceObject as you suggested, but I still can't make it work. Here's what I do (presumably wrong):

1) COM server component named "LoaderServer" - consists of a public class LoaderClass with Initialize() method that actually loads .NET assembly named "DotNet.dll":

Imports System.Reflection

_
Public Class LoaderClass

#Region "COM GUIDs"
Public Const ClassId As String = "5B5EBDA2-7A4E-45F8-9CA1-CE61435197CA"
Public Const InterfaceId As String = "A3747BA4-DC24-4239-BF8C-7005272AA365"
Public Const EventsId As String = "A9EB5F72-B513-4EE3-9A0E-5BBA2CB29BCB"
#End Region

Public Sub New()
MyBase.New()
End Sub

Public Sub Initialize()
[Assembly].Load("D:\Test\DotNet.dll")
End Sub

End Class

2) There is also a Startup application called "Startup.exe" that fires ACAD up and initializes COM server via GetInterfaceObject() call:

Imports Autodesk.AutoCAD.Interop

Module Startup
Sub Main()

Dim oACAD As Autodesk.AutoCAD.Interop.AcadApplication
oACAD = New Autodesk.AutoCAD.Interop.AcadApplication

Dim o As Object
o = oACAD.Application.GetInterfaceObject("LoaderServer.LoaderClass")

End Sub
End Module

Now, everything runs OK (no errors reported) but DotNet.dll assembly doesn't get loaded into ACAD.

Regards,
Maksim Sestic



"Tony Tanzillo" wrote in message news:4963921@discussion.autodesk.com...
Sorry, my previous reply doesn't explain much.

Are you sure you understand what P/Invoke is?

I ask because it is of no use to do what you need.
You can do it by creating a simple COM server in
.NET, and loading that via the GetInterfaceObject
method of AcadApplication. Once the COM server
is loaded, it can then load any assemblies using
the Assembly.Load method. Or, you can just make
the main application that you need to load into
AutoCAD a COM server as well. If you do that, and
use IExtensionApplication, the Initialize() member
will still be called.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Maksim Sestic" wrote in message news:4963788@discussion.autodesk.com...
I need to load .NET DLL into running ACAD application namespace, but externally - out of another process (Startup module, source excerpt below). How possibly can I get it working?

Startup module (that fires ACAD up) references following libs found in GAC:
- Autodesk.AutoCAD.Interop.dll
- Autodesk.AutoCAD.Interop.Common.dll

Imports Autodesk.AutoCAD.Interop

''' Startup module that fires up ACAD
Module Startup
Sub Main()

''' Start ACAD the easy way... No error checking...
Dim oACAD As Autodesk.AutoCAD.Interop.AcadApplication
oACAD = New Autodesk.AutoCAD.Interop.AcadApplication

''' >>> I simply don't want to load assembly via Lisp here.
''' >>> I've been thinking of using P/Invoke, still don't know what set of
''' >>> acad.exe functions is responsible for netload-ing an assembly.
''' >>> Using a bit more managed approach is even more welcome :-)
oACAD.ActiveDocument.SendCommand( _
"(command " + Chr(34) + _
"NETLOAD" + Chr(34) + " " + Chr(34) + _
"TCGDotNet16.dll" + Chr(34) + ")" + vbLf)
End Sub
End Module

Thanks for any suggestion on that matter.

Regards,
Maksim Sestic
*Tony Tanzillo
Message 8 of 10 (239 Views)

Re: Externally loading an assembly into running ACAD app. namespace

09-25-2005 08:35 PM in reply to: *Maksim Sestic
"Maksim Sestic" wrote

>> I suspect that Initialize() part of COM server never gets executed

Sorry, I don't follow you. If you suspect that, why don't you
just run it in the debugger and find out for sure?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
*Maksim Sestic
Message 9 of 10 (239 Views)

Re: Externally loading an assembly into running ACAD app. namespace

09-26-2005 12:36 PM in reply to: *Maksim Sestic


size=2>Tony,

 

I'm sorry for not being precise - it definately
never executes COM server's Initialize() sub. On the other hand,
[Assembly].Load GETS executed within Sub New() of called COM's class. Alas,
referenced assembly still doesn't get loaded into ACAD (?)... and NO errors
were generated.

 

Regards,

Maksim Sestic

 

"Maksim Sestic"
<

size=2>info@geoinova.com
>
wrote

 >> I suspect that Initialize() part of COM server never
gets executed

Sorry, I don't follow you. If you suspect that, why don't
you
just run it in the debugger and find out for sure?

--


size=2>http://www.caddzone.com



size=2>AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006

href="http://www.acadxtabs.com">
size=2>http://www.acadxtabs.com
*Tony Tanzillo
Message 10 of 10 (239 Views)

Re: Externally loading an assembly into running ACAD app. namespace

09-26-2005 02:28 PM in reply to: *Maksim Sestic
How do you know the assembly doesn't get loaded?

Have you tried creating an instance of a class from
the loaded assembly, in the loading COM server?

Define a simple class in the assembly that's loaded
by the COM server, then rather than explicitly loading
the assembly, simply create an instance of the class
from the COM server.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Maksim Sestic" wrote in message news:4967312@discussion.autodesk.com...
Tony,

I'm sorry for not being precise - it definately never executes COM server's Initialize() sub. On the other hand, [Assembly].Load GETS executed within Sub New() of called COM's class. Alas, referenced assembly still doesn't get loaded into ACAD (?)... and NO errors were generated.

Regards,
Maksim Sestic

"Tony Tanzillo" wrote in message news:4966574@discussion.autodesk.com...
"Maksim Sestic" wrote

>> I suspect that Initialize() part of COM server never gets executed

Sorry, I don't follow you. If you suspect that, why don't you
just run it in the debugger and find out for sure?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.