Announcements

Community notifications may experience intermittent interruptions between 10–12 November during scheduled maintenance. We appreciate your patience.

DLL in Plugin Bundle Fail to be Autoloaded

DLL in Plugin Bundle Fail to be Autoloaded

JC_BL
Advocate Advocate
8,490 Views
25 Replies
Message 1 of 26

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
Accepted solutions (1)
8,491 Views
25 Replies
Replies (25)
Message 21 of 26

_gile
Consultant
Consultant

What's strange for me is:

>>>

Run Visual Studio 2010, and use a new-project wizard called "AutoCAD 2015 CSharp plug-in"

>>>

then

>>>

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

>>>

and in the PackageContents file:

>>>

SeriesMin="R19.0"

>>>

which means AutoCAD 2013...

 

IMO a good practice should be:

  1. Determine the older targeted AutoCAD version
  2. Build a project against the .NET Framework version installed by this version of AutoCAD
  3. Reference the libraries corresponding to this version of AutoCAD
  4. Try the generated DLL in later versions of AutoCAD

Most of the time, step 4 works, if not, create a new project in the same solution for the incompatible AutoCAD version (step 2). You can share code between projects by "Adding as link" files from the first project to the new one.

 

You can refer to this table:

AutoCAD_VisualStudio_EN.png

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 22 of 26

JC_BL
Advocate
Advocate

Thanks both for your replies.

 

It should have said Visual Studio 2012, not Visual Studio 2010.  It was a typo.

 

That new project wizard for "AutoCAD 2015 CSharp Plugin" is the only wizard that I can find for AutoCAD targetting .NET Framework 4.5.2.  I am hoping that this doesn't cause any problem.

 

By default, the project created using the new project wizard somehow still refer to AutoCAD DLL files in ObjectARX-2018 that are targetting .NET Framework 4.6.  I have to change the reference folder from ObjectARX-2018 to ObjectARX-2017 in order to correctly refer to AutoCAD DLL files in ObjectARX-2017.

 

As for PackageContents.xml file specifies R19.0 (AutoCAD 2013) as the minimum version.  Actually where I work has standardized on R22.0 (AutoCAD 2018).  I specify R19.0 just to be "more is better".

 

The info in the table that gile has presented is very interesting.  I have never seen this before.  Based on the table, our combination of AutoCAD 2018 / .NET Framework 4.5.2 / Visual Studio 2012 is not one of the combo that is shown in "green".  This makes me concerned.  I am wondering what the effect that may cause?

 

Would you please tell me where I can find that table?  Then I can present it to the system people to see if they can upgrade .NET Framework to 4.6 and upgrade my Visual Studio to 2015.

 

Thanks.

 

 

0 Likes
Message 23 of 26

JC_BL
Advocate
Advocate

Thanks for your copy of a known-good PackageContents.xml file.  I have tried it.  Unfortunately it doesn't have any effect -- meaning that my plugin is still not autoloaded.

 

At this point, I probably need to focus on making my combo of AutoCAD / .NET Framework / Visual Studio to be in one of the Autodesk-approved combination before I do anything else.

 

0 Likes
Message 24 of 26

_gile
Consultant
Consultant

Instead of using a wizard which does not correspond to the targeted AutoCAD version, build your own Visual Studio project templates for AutoCAD (it's an automatic translation from a French tutorial I wrote).

You can get the table here (French version).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 25 of 26

JC_BL
Advocate
Advocate

I greatly appreciate the PDF to create a new project wizard for AutoCAD.  This is a KEEPER.  I wish I had it before I start the project that I am working on.

 

I will present the table to our system people, and I will see how this goes.

 

Many thanks.

0 Likes
Message 26 of 26

JC_BL
Advocate
Advocate
Accepted solution

To All:  This problem has been fixed

 

Somehow the PackageContents.xml file had a binary character in the first line.  It looked like something Visual Studio automatically adds to a source code file.  Autoloader didn't like it and rejected the PackageContents.xml file.  After I have removed that binary character, I have no problem autoloading the plugin.

 

That binary character didn't show up in NotePad.  This was probably the reason why I didn't notice it.

 

Yes, this have been a long time since I posted the original message.  I could not figure this out and put this aside.  Now I take a fresh look and quickly discover where the problem is.  The lesson learnt is:  If someone gets stuck with a problem, he may want to take a long break; when he comes back to take a fresh look, he may find the solution in front of him.