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

AutoLoad the dll on AutoCAD startup

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
prem_kumar8SXZJ
1211 Views, 11 Replies

AutoLoad the dll on AutoCAD startup

Hi everyone,

I have created a small plugin in AutoCAD using c# and right now I am using netload to load my dll into AutoCAD.

But I want that when I start my AutoCAD the DLL will automatically load. I tried to create a bundle file including the PackageContents.xml file and place my dll into the bundle folder. But the DLL is not loading automatically.

If anyone has any idea then please help me.

Tags (2)
11 REPLIES 11
Message 2 of 12
Ed.Jobe
in reply to: prem_kumar8SXZJ

Where do you have the bundle folder stored? In one of the areas that AutoCAD looks for them? Your personal area is located at %AppData%\Autodesk\ApplicationPlugins

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 3 of 12
_gile
in reply to: prem_kumar8SXZJ

Hi,

In this reply, an example of minimalist PackageContents.xml file for autoloading a .NET DLL.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 4 of 12
prem_kumar8SXZJ
in reply to: _gile

Hi, Where I can find this product code and upgrade code? So that I can include them in the PackageContents.xml file?

 

ProductCode="{83F90232-3CEB-40F0-88BE-2638C843CEA5}"
UpgradeCode="{B31D4C65-464B-4460-9E9F-B36D7B1C453A}"
Message 5 of 12
_gile
in reply to: prem_kumar8SXZJ


@prem_kumar8SXZJ wrote:

Hi, Where I can find this product code and upgrade code? So that I can include them in the PackageContents.xml file?

 

ProductCode="{83F90232-3CEB-40F0-88BE-2638C843CEA5}"
UpgradeCode="{B31D4C65-464B-4460-9E9F-B36D7B1C453A}"

You do not "find" them, you create them (there's a "Create GUID" in the Visual Studio Tools menu and many other on the web).

ProductCode shoud be changed a each new version. UpgradeCode should never be changed.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 12

Hi I have created a product code using GUID and Created a folder with a .bundle file and also created all the sub folders and PackageContents.xml file and Paste that bundle folder in C:\Program Files (x86)\Autodesk\ApplicationPlugins\Trapeze.bundle this directory, But still, my dll is not loading why?

Message 7 of 12
_gile
in reply to: prem_kumar8SXZJ

The 'Trapeze.bundle' was just an example you have to adapt to suit your needs.

Name the .bundle as you need (typically as you project), create new GUIDs for both the ProductCode and the UpgradeCode, change the application Name, Set the SeriesMin and SeriesMax value to the AutoCAD releases you want your app to run on, change the AppName and, for sure, the ModuleName.

You should read this topic and the related references.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 8 of 12

Hi, I have made all the changes and when I open AutoCAD it also shows the message "Stretch Utility has been successfully loaded" where Stretch Utility is my Application name. But then again when I give the command to run some functionality that I written in the Dll, It is saying Unknown command. If I use Netload and then use the command everything is working fine. I don't understand what is going on with the bundle file.

 

<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage
  SchemaVersion="1.0"
  AppVersion="1.0.0"
  ProductCode="{04A0B285-1593-4604-B4B1-714A231770CD}"
  Name="Stretch Utility"
  AutodeskProduct="AutoCAD"
  ProductType="Application">
  <Components>
    <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R24.3" SeriesMax="R24.3" />
    <ComponentEntry
      AppName="Stretch Utility"
      Version="1.0.0"
      ModuleName="./Contents/AutoCAD_3DProject.dll"
      LoadOnAutoCADStartup="True">
    </ComponentEntry>
  </Components>
</ApplicationPackage>
Message 9 of 12
_gile
in reply to: prem_kumar8SXZJ

Do not care about your application Status is "Unknown App" in the application manager dialog. This is due to the fact you application is not one from the Autodesk Application Store.

Does your application contains a class which implements IExtensionApplication? If so, your issue may be due to what does the Initialize method because this method is not called in the same context when the application is autoloaded or when it is netloaded.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 10 of 12
prem_kumar8SXZJ
in reply to: _gile

Yes, my class does implement IExtensionApplication because I am creating a ribbon tab and some buttons. I just removed the code for the ribbon tab and now it is loading perfectly. Thanks.
One more question is If I don't use the IExtensionApplication then how I am going to create a ribbon tab and some buttons? Is it through cuix file or there is any other way?

Message 11 of 12
_gile
in reply to: prem_kumar8SXZJ

You can use IExtensionApplication, but you have to take care of the context the Initialize() method is run.

Typically, you just subscribe to the Application.Idle event in the Initialize method and do your stuff in the event handler to ensure the code is not run before AutoCAD completed its own initialization.

Here's a example:

 

internal class ExtensionApplication : IExtensionApplication
{
    public void Initialize()
    {
        Application.Idle += OnIdle;
    }

    private void OnIdle(object? sender, EventArgs e)
    {
        var doc = Application.DocumentManager.MdiActiveDocument;
        if (doc != null)
        {
            Application.Idle -= OnIdle;
            try
            {
                // Do the initialization stuff here.
            }
            catch (System.Exception ex)
            {
                doc.Editor.WriteMessage($"\nInitilization error: {ex.Message}");
            }
        }
    }

    public void Terminate()
    { }
}

 

You can also use this ExtensionApplicationAsync abstract class from @ActivistInvestor.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 12 of 12
prem_kumar8SXZJ
in reply to: _gile

Okay, Thanks for this 😀

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report