.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DLL in Plugin Bundle Fail to be Autoloaded

25 REPLIES 25
SOLVED
Reply
Message 1 of 26
JC_BL
5902 Views, 25 Replies

DLL in Plugin Bundle Fail to be Autoloaded

JC_BL
Advocate
Advocate

I have developed a plugin in a form of a DLL written in C# .NET.  Let call it MyLib.dll.  It has several commands available for our users.  The commands work fine when I manually load the DLL using NETLOAD.  I want the DLL to be autoloaded.  I follow a "known good" sample program to create a bundle folder for the plugin.  I have also created a cuix file to add the plugin to the Ribbon.  The cuix works fine.  Unfortunately, the DLL somehow is not autoloaded.  Please help me to find out what goes wrong.

 

The bundle folder structure is like this:

 

C:\ProgramData\Autodesk\ApplicationPlugins\MyLib.bundle
|
|--> PackageContents.xml
|
|--> Contents
     |
     |--> MyLib.dll
     |
     |--> MyLib.cuix

And the PackageContents.xml file is like this:

 

<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage
   SchemaVersion="1.0"
   AppVersion="1.0.0"
   Name="MyLib"
   Description="My library of programs"
   ProductCode="{...GUID...}">

   <CompanyDetails Name="XYZ Company" />

   <Components>
      <RuntimeRequirements SupportPath="./Contents"
                           OS="Win64"
                           Platform="AutoCAD*"
                           SeriesMin="R19.0" />
      <ComponentEntry AppName="MyLib"
                      AppDescription="My Library"
                      ModuleName="./Contents/MyLib.dll"
                      LoadOnAutoCADStartup="True" />
      <ComponentEntry AppName="MyLib"
                      AppDescription="My Library"
                      ModuleName="./Contents/MyLib.cuix" />
   </Components>
</ApplicationPackage>

 

There is no error message during startup.  But the commands doesn't work (because the DLL is not loaded).  And I also find that the DLL is not registered in the registry.  I am under the impression that the Autoloader in AutoCAD will automatically load the DLL and register the DLL for me.

 

I have also tried replacing the LoadOnAutoCADStartup option with LoadOnCommandInvocation.  But that doesn't work either.

 

Is there a way to see any hidden warning message or error message from AutoCAD startup process to show me what AutoCAD doesn't autoload the DLL?

 

Can someone give me a suggestion as of why this plugin bundle cannot be autoloaded into AuotCAD?

 

Thanks.

 

JC

0 Likes

DLL in Plugin Bundle Fail to be Autoloaded

I have developed a plugin in a form of a DLL written in C# .NET.  Let call it MyLib.dll.  It has several commands available for our users.  The commands work fine when I manually load the DLL using NETLOAD.  I want the DLL to be autoloaded.  I follow a "known good" sample program to create a bundle folder for the plugin.  I have also created a cuix file to add the plugin to the Ribbon.  The cuix works fine.  Unfortunately, the DLL somehow is not autoloaded.  Please help me to find out what goes wrong.

 

The bundle folder structure is like this:

 

C:\ProgramData\Autodesk\ApplicationPlugins\MyLib.bundle
|
|--> PackageContents.xml
|
|--> Contents
     |
     |--> MyLib.dll
     |
     |--> MyLib.cuix

And the PackageContents.xml file is like this:

 

<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage
   SchemaVersion="1.0"
   AppVersion="1.0.0"
   Name="MyLib"
   Description="My library of programs"
   ProductCode="{...GUID...}">

   <CompanyDetails Name="XYZ Company" />

   <Components>
      <RuntimeRequirements SupportPath="./Contents"
                           OS="Win64"
                           Platform="AutoCAD*"
                           SeriesMin="R19.0" />
      <ComponentEntry AppName="MyLib"
                      AppDescription="My Library"
                      ModuleName="./Contents/MyLib.dll"
                      LoadOnAutoCADStartup="True" />
      <ComponentEntry AppName="MyLib"
                      AppDescription="My Library"
                      ModuleName="./Contents/MyLib.cuix" />
   </Components>
</ApplicationPackage>

 

There is no error message during startup.  But the commands doesn't work (because the DLL is not loaded).  And I also find that the DLL is not registered in the registry.  I am under the impression that the Autoloader in AutoCAD will automatically load the DLL and register the DLL for me.

 

I have also tried replacing the LoadOnAutoCADStartup option with LoadOnCommandInvocation.  But that doesn't work either.

 

Is there a way to see any hidden warning message or error message from AutoCAD startup process to show me what AutoCAD doesn't autoload the DLL?

 

Can someone give me a suggestion as of why this plugin bundle cannot be autoloaded into AuotCAD?

 

Thanks.

 

JC

Tags (2)
25 REPLIES 25
Message 2 of 26
JC_BL
in reply to: JC_BL

JC_BL
Advocate
Advocate

I also create another plugin bundle that has a LSP file instead of a DLL file.  Unfortunately, the LSP file is also NOT autoloaded.  This means the problem has nothing to do with the DLL.  I am also sure that the autoloader in my AutoCAD (AutoCAD 2018) should work because the plug-in bundle of the "known good" sample program can be autoloaded.  This means there must be something in my plug-in bundle that is causing the problem.  But I cannot tell where the problem is.

 

Please help.  Thanks.

 

JC

0 Likes

I also create another plugin bundle that has a LSP file instead of a DLL file.  Unfortunately, the LSP file is also NOT autoloaded.  This means the problem has nothing to do with the DLL.  I am also sure that the autoloader in my AutoCAD (AutoCAD 2018) should work because the plug-in bundle of the "known good" sample program can be autoloaded.  This means there must be something in my plug-in bundle that is causing the problem.  But I cannot tell where the problem is.

 

Please help.  Thanks.

 

JC

Message 3 of 26
JC_BL
in reply to: JC_BL

JC_BL
Advocate
Advocate

Seem like the problem may have to do with the fact that I don't have a publisher ID and the DLL is not signed.  Not sure.  The easiest way out is to place a LISP file in Startup Suite in AutoCAD, and add a (command "_netload" ...) statement in the LISP file to load the DLL.  This is not really a solution to this problem.  This is just a workaround.  Actually I still cannot be sure if missing publisher ID is really the cause of this problem.

 

JC_BL

0 Likes

Seem like the problem may have to do with the fact that I don't have a publisher ID and the DLL is not signed.  Not sure.  The easiest way out is to place a LISP file in Startup Suite in AutoCAD, and add a (command "_netload" ...) statement in the LISP file to load the DLL.  This is not really a solution to this problem.  This is just a workaround.  Actually I still cannot be sure if missing publisher ID is really the cause of this problem.

 

JC_BL

Message 4 of 26
_gile
in reply to: JC_BL

_gile
Mentor
Mentor

Hi,

 

You should set the ProductCode attribute value with a GUID (from Visual Studio, Tools > Create GUID) and add an UpgradeCode attribute with a different GUID.

You shoud also have a look at the  APPAUTOLOAD system variable.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes

Hi,

 

You should set the ProductCode attribute value with a GUID (from Visual Studio, Tools > Create GUID) and add an UpgradeCode attribute with a different GUID.

You shoud also have a look at the  APPAUTOLOAD system variable.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 26
JC_BL
in reply to: _gile

JC_BL
Advocate
Advocate

Thanks for your reply.  The APPAUTOLOAD system variable is already set at 2 (that is to load the plugin during Startup).  The PackageContents.xml file already has a ProductCode.  And I have tried adding a UpgradeCode to PackageContents.xml file.  But that doesn't make any difference.  Based on the documentation on PackageContents.xml, UpgradeCode is optional for in-house application (that is what I am working on).

 

As of now, I believe the problem has to do with the fact that I don't have a publisher-ID.  Currently I get around with the problem by using the Startup Suite mechanism.  Not perfect.  But is acceptable for an in-house application.

0 Likes

Thanks for your reply.  The APPAUTOLOAD system variable is already set at 2 (that is to load the plugin during Startup).  The PackageContents.xml file already has a ProductCode.  And I have tried adding a UpgradeCode to PackageContents.xml file.  But that doesn't make any difference.  Based on the documentation on PackageContents.xml, UpgradeCode is optional for in-house application (that is what I am working on).

 

As of now, I believe the problem has to do with the fact that I don't have a publisher-ID.  Currently I get around with the problem by using the Startup Suite mechanism.  Not perfect.  But is acceptable for an in-house application.

Message 6 of 26
_gile
in reply to: JC_BL

_gile
Mentor
Mentor

I cannot see anything wrong with your PackageContents.xml file but I'm pretty sure it has nothing to do with any "publisher-ID", I don't have one and I can extensively use bundles.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes

I cannot see anything wrong with your PackageContents.xml file but I'm pretty sure it has nothing to do with any "publisher-ID", I don't have one and I can extensively use bundles.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 7 of 26
JC_BL
in reply to: _gile

JC_BL
Advocate
Advocate

I am glad that you share your experience.  This means publisher-ID is not always required.  Having said this, I cannot totally rule out the publisher-ID may be the "trigger" of this problem.  Although missing publisher-ID may not "cause" of the problem, this may "trigger" the problem.  What I mean is that the network security in where I work may have a setting that says that a plugin must have a valid publisher-ID.  On the other hand, in another network, it may not have turned ON that security setting, and a plugin will never encounter this problem.  I will need to ask the network administrator to see if he knows anything about this.

 

0 Likes

I am glad that you share your experience.  This means publisher-ID is not always required.  Having said this, I cannot totally rule out the publisher-ID may be the "trigger" of this problem.  Although missing publisher-ID may not "cause" of the problem, this may "trigger" the problem.  What I mean is that the network security in where I work may have a setting that says that a plugin must have a valid publisher-ID.  On the other hand, in another network, it may not have turned ON that security setting, and a plugin will never encounter this problem.  I will need to ask the network administrator to see if he knows anything about this.

 

Message 8 of 26
dgorsman
in reply to: JC_BL

dgorsman
Consultant
Consultant

Stupid question time: are you getting hoisted by your AutoCAD Trusted Path/security settings?

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes

Stupid question time: are you getting hoisted by your AutoCAD Trusted Path/security settings?

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 9 of 26
Anonymous
in reply to: JC_BL
Message 10 of 26
JC_BL
in reply to: dgorsman

JC_BL
Advocate
Advocate

All the plugin bundle (including mine and another sample program) are stored under C:\ProgramData\Autodesk\ApplicationPlugnis folder, and that folder is in the list of Trusted Location in AutoCAD.

 

But this is still a good question.  The reason is that when I manually NETLOAD my DLL (for the first time) from that location, somehow I still get a warning message about the location is not in a trusted location (it also complains that the DLL is not from a valid a publisher).  Therefore, I still have a question in the back of my head wondering if that "Trusted Location" setting is really working or not.  By the way, I answer the warning message and ask it to "Always Load" the DLL, and that prevents the warning message from popping up -- that is until I rebuild the DLL.  Anyway I doubt this has anything to do with this problem because I have already asked it to "Always Load"; therefore, this should not prevent the DLL from being autoloaded.  Something else is causing the problem.

 

0 Likes

All the plugin bundle (including mine and another sample program) are stored under C:\ProgramData\Autodesk\ApplicationPlugnis folder, and that folder is in the list of Trusted Location in AutoCAD.

 

But this is still a good question.  The reason is that when I manually NETLOAD my DLL (for the first time) from that location, somehow I still get a warning message about the location is not in a trusted location (it also complains that the DLL is not from a valid a publisher).  Therefore, I still have a question in the back of my head wondering if that "Trusted Location" setting is really working or not.  By the way, I answer the warning message and ask it to "Always Load" the DLL, and that prevents the warning message from popping up -- that is until I rebuild the DLL.  Anyway I doubt this has anything to do with this problem because I have already asked it to "Always Load"; therefore, this should not prevent the DLL from being autoloaded.  Something else is causing the problem.

 

Message 11 of 26
JC_BL
in reply to: Anonymous

JC_BL
Advocate
Advocate

Hello przemek_2000, as mentioned in one of my previous message, the APPAUTOLOAD system variable is already set at 2 (that is to autoload at startup).  Therefore, this is not what causes the problem.

 

Thanks for your reply.

 

0 Likes

Hello przemek_2000, as mentioned in one of my previous message, the APPAUTOLOAD system variable is already set at 2 (that is to autoload at startup).  Therefore, this is not what causes the problem.

 

Thanks for your reply.

 

Message 12 of 26
JC_BL
in reply to: JC_BL

JC_BL
Advocate
Advocate

I asked our network administrator about this.  The answer is a "may be".  Their is Group Policy that says that we should only allow running EXE/DLL that is third party certified or our own certified.  But we have many in-house applications (EXE/DLL) that runs fine for many years and they are not certified in any way.  Therefore, we have one policy that says one thing, and we have real life experience that says a different thing.

 

At this point, this thing is outside my domain.  I will have to move on to other tasks.

0 Likes

I asked our network administrator about this.  The answer is a "may be".  Their is Group Policy that says that we should only allow running EXE/DLL that is third party certified or our own certified.  But we have many in-house applications (EXE/DLL) that runs fine for many years and they are not certified in any way.  Therefore, we have one policy that says one thing, and we have real life experience that says a different thing.

 

At this point, this thing is outside my domain.  I will have to move on to other tasks.

Message 13 of 26
_gile
in reply to: JC_BL

_gile
Mentor
Mentor

What if you download and install some plugin on the app store?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes

What if you download and install some plugin on the app store?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 14 of 26
JC_BL
in reply to: _gile

JC_BL
Advocate
Advocate

That plugin "Incerment" that I downloaded from App Store works fine.

 

I notice that it installs itself in C:\Users\...\AppData\Roaming\Autodesk\ApplicationPlugins folder.  On the other hand, I installed mine in C:\ProgramData\Autodesk\ApplicationPlugins folder.  I tried installing mine in C:\Users\...\AppData\Roaming\Autodesk\ApplicationPlugins folder.  Unfortunately this doesn't make any difference.

 

I also notice that it comes with an installation program (.msi file).  The installation program adds a registry entry to autoload itself (HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R22.0\ACAD-1001:409\Applications\Increment).  And this is probably the reason why AutoCAD has no problem autoloading this plugin.  If I use this plugin as the guide, the trick to autoload a plugin seems to be to write an installation program to add a bundle folder and to register the plugin.

0 Likes

That plugin "Incerment" that I downloaded from App Store works fine.

 

I notice that it installs itself in C:\Users\...\AppData\Roaming\Autodesk\ApplicationPlugins folder.  On the other hand, I installed mine in C:\ProgramData\Autodesk\ApplicationPlugins folder.  I tried installing mine in C:\Users\...\AppData\Roaming\Autodesk\ApplicationPlugins folder.  Unfortunately this doesn't make any difference.

 

I also notice that it comes with an installation program (.msi file).  The installation program adds a registry entry to autoload itself (HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R22.0\ACAD-1001:409\Applications\Increment).  And this is probably the reason why AutoCAD has no problem autoloading this plugin.  If I use this plugin as the guide, the trick to autoload a plugin seems to be to write an installation program to add a bundle folder and to register the plugin.

Message 15 of 26
_gile
in reply to: JC_BL

_gile
Mentor
Mentor

@JC_BL  a écrit :
I also notice that it comes with an installation program (.msi file).  The installation program adds a registry entry to autoload itself (HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R22.0\ACAD-1001:409\Applications\Increment).  And this is probably the reason why AutoCAD has no problem autoloading this plugin.  If I use this plugin as the guide, the trick to autoload a plugin seems to be to write an installation program to add a bundle folder and to register the plugin.

The installer does not create the registry entry, it only deploy the bundle folder in %appdata%\Autodesk\ApplicationPlugins. This is the autoloader mechanism which creates the registry entry the first time the application is (auto)loaded.

I often build installers which use this mechanism without doing anything than deploying the bundle folder. I also often directy paste a bundle into an autoloader folder.

Maybe you can get some inspiration from the Increment PackageContents.xml file and try again with a new ProductCode GUID.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes


@JC_BL  a écrit :
I also notice that it comes with an installation program (.msi file).  The installation program adds a registry entry to autoload itself (HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R22.0\ACAD-1001:409\Applications\Increment).  And this is probably the reason why AutoCAD has no problem autoloading this plugin.  If I use this plugin as the guide, the trick to autoload a plugin seems to be to write an installation program to add a bundle folder and to register the plugin.

The installer does not create the registry entry, it only deploy the bundle folder in %appdata%\Autodesk\ApplicationPlugins. This is the autoloader mechanism which creates the registry entry the first time the application is (auto)loaded.

I often build installers which use this mechanism without doing anything than deploying the bundle folder. I also often directy paste a bundle into an autoloader folder.

Maybe you can get some inspiration from the Increment PackageContents.xml file and try again with a new ProductCode GUID.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 16 of 26
JC_BL
in reply to: _gile

JC_BL
Advocate
Advocate

Thanks for the additional details of the .msi.

 

I have just tried using InstallShield Limited Edition for Visual Studio to create a .msi to deploy the plugin bundle.  The .msi can copy the bundle to C:\Program Files\Autodesk\ApplicationPlugins folder.  Unfortunately, AutoCAD still cannot autoload the plugin bundle from that location, and AutoCAD doesn't register the plugin either.  Seems to me that the problem has nothing to do with the use of .msi or not.  And I have no idea why AutoCAD cannot autoload my plugin.  I will have to stick with loading the plugin through a LISP file in Startup Suite in AutoCAD.

 

I really hope that the autoloading plugin bundle mechanism will work because this not only will autoload the DLL, but also the mechanism will load the CUIX into the ribbon.  As of now, users not only need to use the Startup Suite to get around with this problem, they also need to load the CUIX into ribbon.  This is "OK".  Still...

 

This is very strange.  To install a sample plugin (called FabricationSample for CADmep), all I need to do is to copy the bundle folder to C:\ProgramData\Autodesk\ApplicationPlugins and AutoCAD will automatically load it, register it, and load the CUIX into ribbon.  On the other hand, AutoCAD cannot do any of those things for my bundle.

0 Likes

Thanks for the additional details of the .msi.

 

I have just tried using InstallShield Limited Edition for Visual Studio to create a .msi to deploy the plugin bundle.  The .msi can copy the bundle to C:\Program Files\Autodesk\ApplicationPlugins folder.  Unfortunately, AutoCAD still cannot autoload the plugin bundle from that location, and AutoCAD doesn't register the plugin either.  Seems to me that the problem has nothing to do with the use of .msi or not.  And I have no idea why AutoCAD cannot autoload my plugin.  I will have to stick with loading the plugin through a LISP file in Startup Suite in AutoCAD.

 

I really hope that the autoloading plugin bundle mechanism will work because this not only will autoload the DLL, but also the mechanism will load the CUIX into the ribbon.  As of now, users not only need to use the Startup Suite to get around with this problem, they also need to load the CUIX into ribbon.  This is "OK".  Still...

 

This is very strange.  To install a sample plugin (called FabricationSample for CADmep), all I need to do is to copy the bundle folder to C:\ProgramData\Autodesk\ApplicationPlugins and AutoCAD will automatically load it, register it, and load the CUIX into ribbon.  On the other hand, AutoCAD cannot do any of those things for my bundle.

Message 17 of 26
_gile
in reply to: JC_BL

_gile
Mentor
Mentor

This is what I tried to explain you (with my poor English).

When you put your bundle in one of the Autodesk\ApplicationPlugins, are you able to NETLOAD it from the bundle and run it in AutoCAD ?

If not, the problem probably come from the DLL in this folder.

If yes, the problem probably come from the PackageContents.xml file.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes

This is what I tried to explain you (with my poor English).

When you put your bundle in one of the Autodesk\ApplicationPlugins, are you able to NETLOAD it from the bundle and run it in AutoCAD ?

If not, the problem probably come from the DLL in this folder.

If yes, the problem probably come from the PackageContents.xml file.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 18 of 26
JC_BL
in reply to: _gile

JC_BL
Advocate
Advocate

Yes, I have no problem using NETLOAD to load the DLL from my plugin bundle from C:\ProgramData\Autodesk\ApplicationPlugins folder.  After loading it, the commands from the DLL in the plugin are readily available, and they run fine.

 

The following is the PackageContents.xml file:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage SchemaVersion="1.0"
                    AppVersion="1.0.0"
                    Author="JC_BL"
                    Name="MyLib"
                    Description="My library"
                    ProductCode="{6F82B046-BFA0-4E41-A388-DA023EC29DFF}"
                    AutodeskProduct="AutoCAD" ProductType="Application">

   <CompanyDetails Name="XYZ Company" />
   <Components>
      <RuntimeRequirements SupportPath="./Contents" OS="Win64" Platform="AutoCAD*" SeriesMin="R19.0" />
		<ComponentEntry AppName="MyLib"
		                AppDescription="My Program Library"
		                ModuleName="./Contents/MyLib.dll"
                      LoadOnAutoCADStartup="True" />
   </Components>
</ApplicationPackage>

This is how I create the plugin:

Run Visual Studio 2010, and use a new-project wizard called "AutoCAD 2015 CSharp plug-in" to create a skeleton project called MyLib.  The skeleton project should have a program file myCommands.cs in it.  The file has a class called "MyCommands".  Add a simply "command" in it, like this:

 

[CommandMethod("MyCommandForTest")]
public void MyCommandForTest()
   {
   Document doc = Application.DocumentManager.MdiActiveDocument;
   Editor ed;
   if (doc != null)
      {
      ed = doc.Editor;
      ed.WriteMessage("This is just a test");
      }
   }

 

Because my project is targeted at .NET Framework 4.5.2, I need to adjust the references to point to ObjectARX-2017 to match.

 

Build the DLL to make sure it has no error.

 

Manually issue the NETLOAD command to load the DLL from the Debug/bin folder.  AutoCAD complains about "The publisher of this executable file could not be verified and the file is not located in a trusted folder."  I choose "Always Load" to by pass this message.  Enter MYCOMMANDFORTEST, and it shows up in the command line.  Run MYCOMMANDFORTEST, and it shows "This is just a test".  So far so good.

 

Manually create the plugin bundle.  Use the PackageContents.xml file shown above.  Create a folder called "Contents" under the MyLib.bundle folder.  And copy the MyLib.dll into the "Contents" folder.

 

Copy the entire MyLib.bundle folder into C:\ProgramData\Autodesk\ApplicationPlugins.  Launch AutoCAD and hope for the best.  Unfortunately, AutoCAD doesn't autoload MyLib.dll.  There is no error message; but none of the "My..." commands shows up in the command line.

 

Use NETLOAD to manually load the DLL from MyLib.bundle folder in C:\ProgramData\....  It shows the same warning message as before.  I understand the part of the message about the DLL doesn't have a verified publisher ID.  But I don't understand why it complains that the DLL is not in a trusted location.  The fact is that C:\ProgramData\Autodesk\ApplicationPlugins and all its sub folders are trusted location.  I choose "Always Load" just like the last time.  And the DLL is loaded without any problem.  And I can see all the My* commands showing up.

 

I cannot spot where the cause of the "not autoload" problem is, other than the fact that I don't have a verified publisher ID.

 

Can anyone help me to spot where the cause of the problem?

 

0 Likes

Yes, I have no problem using NETLOAD to load the DLL from my plugin bundle from C:\ProgramData\Autodesk\ApplicationPlugins folder.  After loading it, the commands from the DLL in the plugin are readily available, and they run fine.

 

The following is the PackageContents.xml file:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage SchemaVersion="1.0"
                    AppVersion="1.0.0"
                    Author="JC_BL"
                    Name="MyLib"
                    Description="My library"
                    ProductCode="{6F82B046-BFA0-4E41-A388-DA023EC29DFF}"
                    AutodeskProduct="AutoCAD" ProductType="Application">

   <CompanyDetails Name="XYZ Company" />
   <Components>
      <RuntimeRequirements SupportPath="./Contents" OS="Win64" Platform="AutoCAD*" SeriesMin="R19.0" />
		<ComponentEntry AppName="MyLib"
		                AppDescription="My Program Library"
		                ModuleName="./Contents/MyLib.dll"
                      LoadOnAutoCADStartup="True" />
   </Components>
</ApplicationPackage>

This is how I create the plugin:

Run Visual Studio 2010, and use a new-project wizard called "AutoCAD 2015 CSharp plug-in" to create a skeleton project called MyLib.  The skeleton project should have a program file myCommands.cs in it.  The file has a class called "MyCommands".  Add a simply "command" in it, like this:

 

[CommandMethod("MyCommandForTest")]
public void MyCommandForTest()
   {
   Document doc = Application.DocumentManager.MdiActiveDocument;
   Editor ed;
   if (doc != null)
      {
      ed = doc.Editor;
      ed.WriteMessage("This is just a test");
      }
   }

 

Because my project is targeted at .NET Framework 4.5.2, I need to adjust the references to point to ObjectARX-2017 to match.

 

Build the DLL to make sure it has no error.

 

Manually issue the NETLOAD command to load the DLL from the Debug/bin folder.  AutoCAD complains about "The publisher of this executable file could not be verified and the file is not located in a trusted folder."  I choose "Always Load" to by pass this message.  Enter MYCOMMANDFORTEST, and it shows up in the command line.  Run MYCOMMANDFORTEST, and it shows "This is just a test".  So far so good.

 

Manually create the plugin bundle.  Use the PackageContents.xml file shown above.  Create a folder called "Contents" under the MyLib.bundle folder.  And copy the MyLib.dll into the "Contents" folder.

 

Copy the entire MyLib.bundle folder into C:\ProgramData\Autodesk\ApplicationPlugins.  Launch AutoCAD and hope for the best.  Unfortunately, AutoCAD doesn't autoload MyLib.dll.  There is no error message; but none of the "My..." commands shows up in the command line.

 

Use NETLOAD to manually load the DLL from MyLib.bundle folder in C:\ProgramData\....  It shows the same warning message as before.  I understand the part of the message about the DLL doesn't have a verified publisher ID.  But I don't understand why it complains that the DLL is not in a trusted location.  The fact is that C:\ProgramData\Autodesk\ApplicationPlugins and all its sub folders are trusted location.  I choose "Always Load" just like the last time.  And the DLL is loaded without any problem.  And I can see all the My* commands showing up.

 

I cannot spot where the cause of the "not autoload" problem is, other than the fact that I don't have a verified publisher ID.

 

Can anyone help me to spot where the cause of the problem?

 

Message 19 of 26
_gile
in reply to: JC_BL

_gile
Mentor
Mentor

Try with the following code (simply copy/paste it as is), it's based on the minimal PackageContents.xml file i use.

 

<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage
  SchemaVersion="1.0"
  AppVersion="1.0.0"
  Author="JC_BL"
  ProductCode="{98E0DDE2-7450-4F87-A06F-012DC03B6FA7}"
  UpgradeCode="{96360609-B605-48E3-84E8-318008E53D7D}"
  Name="MyLib"
  Description="My library"
  AutodeskProduct="AutoCAD"
  ProductType="Application">
  <CompanyDetails
    Name="XYZ Company" />
  <Components>
    <RuntimeRequirements
      OS="Win32|Win64"
      Platform="AutoCAD*"
      SeriesMin="R19.0"
      SeriesMax="R23.0" />
    <ComponentEntry
      AppName="MyLib"
      Version="1.0.0"
      ModuleName="./Contents/MyLib.dll"
      AppDescription="My Program Library"
      LoadOnAutoCADStartup="True">
    </ComponentEntry>
  </Components>
</ApplicationPackage>


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes

Try with the following code (simply copy/paste it as is), it's based on the minimal PackageContents.xml file i use.

 

<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage
  SchemaVersion="1.0"
  AppVersion="1.0.0"
  Author="JC_BL"
  ProductCode="{98E0DDE2-7450-4F87-A06F-012DC03B6FA7}"
  UpgradeCode="{96360609-B605-48E3-84E8-318008E53D7D}"
  Name="MyLib"
  Description="My library"
  AutodeskProduct="AutoCAD"
  ProductType="Application">
  <CompanyDetails
    Name="XYZ Company" />
  <Components>
    <RuntimeRequirements
      OS="Win32|Win64"
      Platform="AutoCAD*"
      SeriesMin="R19.0"
      SeriesMax="R23.0" />
    <ComponentEntry
      AppName="MyLib"
      Version="1.0.0"
      ModuleName="./Contents/MyLib.dll"
      AppDescription="My Program Library"
      LoadOnAutoCADStartup="True">
    </ComponentEntry>
  </Components>
</ApplicationPackage>


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 20 of 26
kdub_nz
in reply to: _gile

kdub_nz
Advisor
Advisor

Hi Gilles,

 

>>> 

This is how I create the plugin:

Run Visual Studio 2010, and use a new-project wizard called "AutoCAD 2015 CSharp plug-in" to create a skeleton project called MyLib.  ...

 

>>>

I haven't read the complete thread, but please confirm the Visual Studio version you used ..

 

Regards,

 


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.
Sometimes the question is more important than the answer.

class keyThumper<T> : Lazy<T>;      another  Swamper

0 Likes

Hi Gilles,

 

>>> 

This is how I create the plugin:

Run Visual Studio 2010, and use a new-project wizard called "AutoCAD 2015 CSharp plug-in" to create a skeleton project called MyLib.  ...

 

>>>

I haven't read the complete thread, but please confirm the Visual Studio version you used ..

 

Regards,

 


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.
Sometimes the question is more important than the answer.

class keyThumper<T> : Lazy<T>;      another  Swamper

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report