Author Topic: Demand Loading of .net dll's without using netload  (Read 18739 times)

0 Members and 1 Guest are viewing this topic.

Peter Jamtgaard

  • Guest
Demand Loading of .net dll's without using netload
« on: May 29, 2010, 08:45:57 AM »
I hope this isn't a stupid question.

Do any of you know of a way to demand load .net assemblies
into AutoCAD without using the command line netload?

Thanks


gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Demand Loading of .net dll's without using netload
« Reply #1 on: May 29, 2010, 09:11:14 AM »
Hi,

You can register your application for demand loading.
I posted here some little LISP routines to (un)register .NET application for auto or demand loading.
Speaking English as a French Frog

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Demand Loading of .net dll's without using netload
« Reply #2 on: May 29, 2010, 10:38:23 AM »
or manually edit the registry with these values
Quote
[HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R17.0\ACAD-5001:409\Applications\MyTestApplication]

"DESCRIPTION"="Kean's test application"

"LOADCTRLS"=dword:00000002

"MANAGED"=dword:00000001

"LOADER"="C:\\My Path\\MyTestApp.dll"
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ReneRam

  • Guest
Re: Demand Loading of .net dll's without using netload
« Reply #3 on: May 29, 2010, 10:42:22 AM »
I have some source code download from the pluin of the month and there is a demandloading routine inside that's pretty cool. I don't have it by hand now, but I will try to post it on monday when I go back to work. By th way, I think the author is Kean Walmsley so take a look at this link, it may help:

http://through-the-interface.typepad.com/through_the_interface/2009/05/creating-demand-loading-entries-automatically-for-your-autocad-application-using-net.html

I have inseted the code in my apps not long ago and after the first netload after the installation it's just a regular command.
René

Peter Jamtgaard

  • Guest
Re: Demand Loading of .net dll's without using netload
« Reply #4 on: May 29, 2010, 05:23:24 PM »
Thanks for your responses.

What I was hoping was to load a .net application DURING an Autocad session without using netload or the registry method mentioned above.

Are there ANY other possible ways to netload an assembly?

Peter

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Demand Loading of .net dll's without using netload
« Reply #5 on: May 29, 2010, 08:51:38 PM »

What I was hoping was to load a .net application DURING an Autocad session without using netload or the registry method mentioned above.

Are there ANY other possible ways to netload an assembly?


Not that I'm aware of.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

jgr

  • Guest
Re: Demand Loading of .net dll's without using netload
« Reply #6 on: May 29, 2010, 09:07:34 PM »
without using netload or the registry method, I think it is impossible. (try with .Net Reflector with acmgd.dll )

One question:

If the (.net) application is registered using kOnLoadRequest (LOADCTRLS = &H8). How I can use DynamicLinker?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Demand Loading of .net dll's without using netload
« Reply #7 on: May 29, 2010, 09:19:03 PM »
try using System::Reflection::Assembly::LoadFrom(fileName);
it ought to fire off acads reactors and reg the commands

tony bombata

  • Newt
  • Posts: 45
Re: Demand Loading of .net dll's without using netload
« Reply #8 on: May 29, 2010, 09:33:52 PM »
i think you can do it in a roundabout way


i have a lisp file i use to automatically load net apps during every autocad sesion

something like this


Quote
(command "NETLOAD" "C:/Program Files/Design Applications/CAD Applications/AutoCAD Addons/.NET/OsnapzBG2010x86.dll")

(command "NETLOAD" "C:/Program Files/Design Applications/CAD Applications/AutoCAD Addons/.NET/PL2MPG.dll")

(command "NETLOAD" "C:/Program Files/Design Applications/CAD Applications/AutoCAD Addons/.NET/PolylineEdit.dll")

(command "NETLOAD" "C:/Program Files/Design Applications/CAD Applications/AutoCAD Addons/.NET/Purge Tool.dll")

(command "NETLOAD" "C:/Program Files/Design Applications/CAD Applications/AutoCAD Addons/.NET/QuickSaveAs.dll")

(command "NETLOAD" "C:/Program Files/Design Applications/CAD Applications/AutoCAD Addons/.NET/ret.dll")

in my config, this lisp file is named netloader.lsp


in my acad.lsp, i have a line that loads the file

Quote
Command ( Load "C:/Program Files/Design Applications/CAD Applications/AutoCAD Addons/.NET/netloader.lsp")


neither of these files has a command, but i think its the same basic idea

if you were to write a lisp/script file that loads the net assembly, then another file with a command that loads the er loader , i think that should do the trick

not sure if this is what you'e looking for, since it still incorporates netload. . .


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Demand Loading of .net dll's without using netload
« Reply #9 on: May 29, 2010, 09:57:41 PM »
System::Reflection::Assembly::LoadFrom is the mechanism that acad uses at the netload command.
there is an 'onload' reactor just waiting for your module to be loaded. but when in doubt sendstringtoexecute   :laugh:

Peter Jamtgaard

  • Guest
Re: Demand Loading of .net dll's without using netload
« Reply #10 on: May 30, 2010, 06:06:53 PM »
Thanks for the tip.
Code: [Select]
System::Reflection::Assembly::LoadFrom is the mechanism that acad uses at the netload command.

Could you point me towards any code examples that would help me understand how to call this mechanism?

Peter

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Demand Loading of .net dll's without using netload
« Reply #11 on: May 30, 2010, 08:57:39 PM »
its static,  just call it in a command method  :-)

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
Re: Demand Loading of .net dll's without using netload
« Reply #12 on: June 01, 2010, 01:15:28 PM »
I hope this isn't a stupid question.

Do any of you know of a way to demand load .net assemblies
into AutoCAD without using the command line netload?

Thanks

If you don't mind using your acad.lsp or other auto-loading lisp file here is the method I use.

Create a lisp command in your auto-loading lisp file.
Give the command the same name as your .NET command.
The lisp command should NETLOAD then send the command name.
Note that both the LISP command and the .NET command in this example are the same. "plotw"

(defun c:plotw()
   (SETVAR "CMDECHO" 0)
   (command "netload" "C:/Program Files/AutoCAD 2010/PlotNET2010.dll" "plotw")
   (SETVAR "CMDECHO" 1)
   (princ)
)

The first time a user executes the "plotw" command the lisp routine is run which netloads the .NET dll and executes the "plotw" command. (demand load)
The next time a user executes the "plotw" command it goes straight to the .NET dll.
« Last Edit: June 01, 2010, 01:19:26 PM by mohnston »
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

Peter Jamtgaard

  • Guest
Re: Demand Loading of .net dll's without using netload
« Reply #13 on: June 01, 2010, 02:23:43 PM »
Thanks for your response.

I would consider the  (command "netload" ...) expression as using the command line method.
In lisp that would preclude its use when having a function called from a lisp reactor.
(one of the limitations of reactors)

After Keiths suggestion.

I came up with this.

Peter

Code: [Select]
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime
Imports System.Runtime.InteropServices 'for DllImport()
Imports System.Reflection.Assembly

' Lisp function for loading a .net dll

Public Class vbvlClass
    <LispFunction("Netload")> _
    Public Function Netload(ByVal rbfNetAssemblyFile As ResultBuffer) As ResultBuffer
        Dim rbfReturn As New ResultBuffer
        Try
            Dim arrNetAssemblyFile As TypedValue() = rbfNetAssemblyFile.AsArray()
            System.Reflection.Assembly.LoadFrom(arrNetAssemblyFile(0).Value.ToString)
            rbfReturn.Add(New TypedValue(&H138D, "OK"))
        Catch
            rbfReturn.Add(New TypedValue(&H138D, "Catch Error"))
        End Try
        Return rbfReturn
    End Function

End Class


Peter Jamtgaard

  • Guest
Re: Demand Loading of .net dll's without using netload
« Reply #14 on: June 01, 2010, 02:26:14 PM »
SORRY, I ment Daniels (fronkensteins) suggestion.

(netload "mynetassmebly.dll")

Peter