Author Topic: Netload and run dll at startup  (Read 14842 times)

0 Members and 1 Guest are viewing this topic.

Peter Guappa

  • Guest
Netload and run dll at startup
« on: July 27, 2012, 09:52:17 AM »
I'm completly stuck  :-(

I have a dll (mytest.dll) with a commandmethod ("cmdtest")

When I paste (command "_netload" "C:\\Test\\mytest.dll") and (command "cmdtest") in the commandline it works!

When I create a lisp , appload and run it , it works!
(defun c:test ()
  (command "_netload" "C:\\Test\\mytest.dll")
  (command "cmdtest")
)


But when I copy these 2 lines into my S::STARTUP, it doesn't work !!! (everything else in my startup works just fine)

Offcourse I can use the lisp, but I want the dll to be loaded and RUN AT STARTUP without an extra command


I've been surfing theswamp whole night, tried almost everything I could find, but nothing seems to work.

Any suggestions? (did I do something wrong building it???)

Thanks !!!!!

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England

Peter Guappa

  • Guest
Re: Netload and run dll at startup
« Reply #2 on: July 27, 2012, 10:54:59 AM »
Thx Lee,

Tried it, but I just can't manage to get it to work, maybe I'm just to tired and not thinking clearly.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Netload and run dll at startup
« Reply #3 on: July 27, 2012, 11:00:08 AM »
Another way to check the files lying in a folder and run them all.
Includes menu lisp. Net arx

Peter Guappa

  • Guest
Re: Netload and run dll at startup
« Reply #4 on: July 27, 2012, 11:10:29 AM »
I used the lisp from Lee's link, and everything is imported into the registry.

When I run 'cmdtest' in the commandline it works, so I would think adding (command "cmdtest") in my startup, the dll would run automatically, but it doesn't. Or am I confused?


BlackBox

  • King Gator
  • Posts: 3770
Re: Netload and run dll at startup
« Reply #5 on: July 27, 2012, 11:20:01 AM »
Peter,

DLL's need only be NETLOADed once per session.

If you're not going to demand load assemblies, you can do so manually using ACAD.lsp... Following your stated assembly location:

Code - Auto/Visual Lisp: [Select]
  1. ;;;--------------------------------------------------------------------;
  2. ;;; Load multiple .NET assemblies from ACAD.lsp
  3. ((lambda (loadList)
  4.    (terpri)
  5.    (foreach dll loadList
  6.      (if (findfile dll)
  7.        (command "._netload" dll)
  8.      )
  9.    )
  10.    (terpri)
  11.  )
  12.   '(
  13.     "Test\\mytest.dll"
  14.  
  15.     ;; <- Other assemblies here
  16.  
  17.    )
  18. )
  19. ;;;--------------------------------------------------------------------;
  20.  

** Code assumes "C:\\" is included in Support File Search Path (SFSP).

Not sure what your .NET CommandMethod does, but if it needs to run on each drawing opened, consider adding your (command "cmdtest") call to your ACADDOC.lsp file.

HTH
"How we think determines what we do, and what we do determines what we get."

Peter Guappa

  • Guest
Re: Netload and run dll at startup
« Reply #6 on: July 27, 2012, 11:47:32 AM »
Thx RenderMan,

but no luck.

I still have to launch it by typing cmdtest or (command "cmdtest")

BlackBox

  • King Gator
  • Posts: 3770
Re: Netload and run dll at startup
« Reply #7 on: July 27, 2012, 11:51:39 AM »
Thx RenderMan

You're welcome.  :-)

... if it needs to run on each drawing opened, consider adding your (command "cmdtest") call to your ACADDOC.lsp file.

but no luck.

I still have to launch it by typing cmdtest or (command "cmdtest")

 :wink:
"How we think determines what we do, and what we do determines what we get."

Peter Guappa

  • Guest
Re: Netload and run dll at startup
« Reply #8 on: July 27, 2012, 07:17:25 PM »
....... I give up   :-(

BlackBox

  • King Gator
  • Posts: 3770
Re: Netload and run dll at startup
« Reply #9 on: July 27, 2012, 07:38:44 PM »
Peter,

Either add your Command call to ACADDOC.lsp, or append it to S::Startup. Note the differences in the startup sequence:


Consider the load order at startup:
linky

Quote
A. CUI files loaded:
1. Enterprise
2. Main
3. Partials to Main
4. Partials to Enterprise

B. acad*.* files loaded:
1. Files listed in acad.rx
2. acad2009.lsp
3. acad.lsp  <--
4. acad2009doc.lsp
5. acaddoc.lsp
6. acad.dvb

C. CUI-associated MNL and LSP files loaded:
1. Enterprise named MNL
2. Enterprise loaded LSP and MNL
3. Main named MNL
4. Main loaded LSP and MNL
5. Partials to Main named MNLs
6. Partials to Main loaded LSPs and MNLs
7. Partials to Enterprise named MNLs
8. Partials to Enterprise loaded LSPs and MNLs

D. Startup suite files loaded

E. Startup routines run:
1. AcadStartup() called (AutoCAD startup)
2. AcadDocument_Activate() called (Drawing startup)
3. (S::STARTUP) called
4. SCR loaded from /b switch

I don't know how better to assist you, without more information.

"How we think determines what we do, and what we do determines what we get."

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Netload and run dll at startup
« Reply #10 on: July 27, 2012, 07:46:21 PM »

Peter,
Is your command meant to run in the Application once at startup
or
run in each document.
??

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.

Peter Guappa

  • Guest
Re: Netload and run dll at startup
« Reply #11 on: July 27, 2012, 08:10:38 PM »
Thx for trying to help me out.

I tried everything, erased everything, rewritten everything,rebuid dll, renamed dll,.........

I also build different dll's for AutoCad 2010,2011,2012,2013 32bit/64bit and every dll loads just fine.

When I launch these dll's from the commandline (with cmdtest or (command "cmdtest"))  on different Autocad versions.... no problem.

But adding it to acad.lsp or acaddoc.lsp or S::startup or a lisp that is being loaded from a *.mnl file with the same name as my cui(x), AutoCad just won't run it automatically.

And what is very strange: everything I try in AutoCad, I also try in Bricscad (of course with other refferences in the dll), and it works 100% in BC.

I don't think there's is much more you can do for me,

Thanks for your help and time, I really appreciate it.


If I ever find the solution, I will post it.



Peter Guappa

  • Guest
Re: Netload and run dll at startup
« Reply #12 on: July 27, 2012, 08:13:06 PM »
@ Kerry,

Run in each document.

The dll I'm using is a tooltip that shows extended data, attached to points, when hovering the mouse.

BlackBox

  • King Gator
  • Posts: 3770
Re: Netload and run dll at startup
« Reply #13 on: July 27, 2012, 08:39:53 PM »
I'm not sure that I know enough about .NET to help more at this time.

As I understand it, once the assembly has been loaded into the application, it is available for the life of the session. However, to the best I my limited experience, for the CommandMethod call to not work with either AcadDoc.lsp, *.mnl, or S::Startup, that suggests to me that something about the document object hasn't been instantiated, that the code requires to execute.

Perhaps additional Exception handling is needed? Again, more information (the source code that's been rewritten?) is needed.

Sorry I cannot be of further assistance.
"How we think determines what we do, and what we do determines what we get."

Peter Guappa

  • Guest
Re: Netload and run dll at startup
« Reply #14 on: July 30, 2012, 08:07:08 AM »
FIXED

I encountered another problem and noticed that QAFLAGS was allways set to 1.

A 3th party lisp-routine we use on all our pc's running Autocad was causing this.

Removed it, set qaflags to 0 and now everything runs smoothly.  :-) :-) :-)