netload command

netload command

Anonymous
Not applicable
8,705 Views
12 Replies
Message 1 of 13

netload command

Anonymous
Not applicable

I want to load a DLL without selecting path in explorer.

I tried passing arguments like "netload" "D:\addin1.dll" in command prompt, I tried similarly on macro of a button command.

Is their a way to Load DLL automatically given its path?

 

Our actual Requirement:

We don't want to load DLL in every session automatically. We want to load it when user clicks a button.

0 Likes
Accepted solutions (2)
8,706 Views
12 Replies
Replies (12)
Message 2 of 13

_gile
Consultant
Consultant

Hi,

You can enter a LISP expression directly at command line:

(command "netload" "D:\\addin1.dll")

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 13

Anonymous
Not applicable

Hello @_gile 

Thank you very much. It's Working but it's not meeting our requirement, I need a macro also working like that not just lisp command.

0 Likes
Message 4 of 13

_gile
Consultant
Consultant
Accepted solution

A macro can contain LISP expressions:

^C^C(command "netload" "D:\\addin1.dll");


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 13

Anonymous
Not applicable

Its working but i need to keep the dll file in same directory. Because when i do D:\%path it is getting terminated on :(colon)

0 Likes
Message 6 of 13

_gile
Consultant
Consultant

@Anonymous  a écrit :

Its working but i need to keep the dll file in same directory. Because when i do D:\%path it is getting terminated on :(colon)


Sorry I do not understand what you mean.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 7 of 13

miguelmachadoecosta
Advocate
Advocate
Accepted solution

Are you using either "/" or "\\" as path delimiters? It seems you are always writing a single "\", hence not reading the rest of the path.

0 Likes
Message 8 of 13

Anonymous
Not applicable

Not directly what you're looking for, but should serve the purpose well: look into demand loading using the registry.  Set the load flag to load on command, with the command being called by the specified button.

 

From your other comments, it's unclear as where you are trying to load from, or how you are specifying that folder location.  If you are trying to load directly from the root of a local drive that's... somewhere between 'interesting' and 'not a great idea'.  You should know *exactly* where the DLL will be located on users computers, and it should be the same on each of them.  Preferably this would be a naturally secure location such as a subfolder under ProgramFiles, although not necessarily in an Autodesk/AutoCAD provided one.

 

If you are trying to load a DLL from anywhere other than the computer's system drive, then you may be running into security restrictions (which is a good thing, as it protects against malicious code).

0 Likes
Message 9 of 13

RomuloMagalhaes
Participant
Participant

I have :

 

Folder: "C:\MyFolder", that is part of TRUSTED PATHS on AUTOCAD.

Inside "c:\MyFolder", I have:

 

"MYADDIN.DLL" : main DLL of my project,

 

that have dependencies, for example (all managed .net dlls):

. DEPENDENCE1.DLL

. DEPENDENCE2.DLL

 

When I type "NETLOAD" via command line, and select  'MYADDIN.DLL'  when form is opened, all is loaded ok, and all commands that are inside this DLL are executed normally.

 

but...

 

When I use :

 

(COMMAND "NETLOAD" "c:\\MyFolder\\MYADDIN.dll" )

 

I receive, in determinated command, that depends on, for example, of "DEPENDENCE1.DLL" a exception, like this:

 

' System.TypeInitializationException: The type initializer for 'modulexxxxxx' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'DEPENDENCE1, Version=x.x.x.x, Culture=neutral,
PublicKeyToken=1488e028ca7ab535'

 

I don't understand which difference between...

 

_NETLOAD + enter + select file MYADDIN.DLL on form Choose .NET Assemply ===> ALL OK, fine.


and...

 

(COMMAND "NETLOAD"  "C:\\MyFolder\\MYADDIN.DLL") ==> Launched exception : Not found dll dependence file.

 

Anybody can help me?

 

My Environment:

. Windows 10 64 bits : original;

. AutoCAD 2017 64 bits : original;

 

0 Likes
Message 10 of 13

_gile
Consultant
Consultant

@RomuloMagalhaes 

Did you try to add "C:\MyFolder" to the AutoCAD search path or to set LEGACYCODESEARCH system variable to 1.

You can read this topic.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 11 of 13

RomuloMagalhaes
Participant
Participant

@_gile THANK YOU very much for your attention.

 

1) Did you try to add "C:\MyFolder" to the AutoCAD search path?

YES, previous added.

 

2) Set LEGACYCODESEARCH system variable to 1?

YES, too.

 

3) You can read this topic

Yes, I just read this topic, that contains (COMMAND "NETLOAD" "my.dll") too! ==> my problem.

 

I would like to discover how and why :

 

_NETLOAD + select my.dll on form

 

is different of:

 

(COMMAND "NETLOAD" "my.dll")

 

Because the SAME FOLDER, SAME ENVIRONMENT VARIABLES, and SAME DLL, with different behavior, on the SAME AUTOCAD.

 

 

0 Likes
Message 12 of 13

_gile
Consultant
Consultant

Are the Dependance1.dll and Dependance2.dll in the same "C:\MyFolder" as the plugin one?

 

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 13 of 13

APRR_SITE_DIJON
Participant
Participant

@_gile @RomuloMagalhaes 

Hi, i'm having the same trouble here.

I have a DLL with several routines that depends on a PG database.

I used to integrate npgsql.dll as a standalone dependency and this worked well with the plugin autoload (LoadOnAutoCADStartup= true).

 

I'm trying to migrate our library to AUTOCAD MAP 2024 (VS2022 and .NET framework 4.8) but the Npgsql is now interegated as a nuget package only.

So I dowloaded all the dependencies (very much some system DLLs), and It still works well when I run NetLOAD manually.

 

The issue is when I try to autoload on startup my plugin. It loads well and I have no error. But when I use a command that requires the PG DB and npgsql.DLL dependency, I get an error saying : 

"Message d'erreur : Une exception a été levée par l'initialiseur de type pour 'Npgsql.TypeMapping.BuiltInTypeHandlerResolver'. "

 

All the dependencies are in the Contents folder and a manual "NETLOAD" + pick manually my DLL works well without error.

 

What am I missing ?

 

@RomuloMagalhaes have you finally find an answer to your question ?

0 Likes