Jump to content

Problem with Automatic Loading of .NET DLLs in AutoCAD Architecture


Recommended Posts

Posted (edited)

I created a dll and wanted to auto netload it upon launch of AutoCAD Arch.

 

I have used the following instructions in

 

http://http://through-the-interface.typepad.com/through_the_interface/2006/09/automatic_loadi.html

 

"DESCRIPTION"="AutoNetloadDLL"

"LOADCTRLS"=dword:00000002

"MANAGED"=dword:00000001

"LOADER"="C:\MyApp\bin\Release\MyApp.dll"

 

However, when i typed in my commands for the dll, AutoCAD displayed Unknown Command "". Press F1 for help.

I have tried suggestions by people comments in the above link (i.e. setting acdbmgd.dll and acmgd.dll to Copy Local = False, restarting computer) , but I have done so, and the error still persists.

 

I also have used the method as suggested by writing a STARTUP lisp function to auto netload the dll file in http://www.cadtutor.net/forum/showthread.php?42633-Automatic-Loading-of-.DLL-files-etc&highlight=netload

But the same error persists.

 

Would like to ask if anyone has encountered the same issue before, and can enlighten me on how to solve this problem?

 

I have used Process Explorer to check if acad.exe has loaded the DLL, and it did!

But the commands are not found.

 

When I manually netload the dll by typing the netload command and selecting the dll, there is no such issue. This only occurs to me when I tried the auto methods.

The methods only works so far if I launch acad.exe through Debug mode in VS2008.

 

Definitely need to auto netload the DLL for my application, when AutoCAD Arch startups.

Edited by zetazee
Posted

You need to somehow netload it manuly or have lisp do it and put code in the Intialize method or commands like below to set registery values.

Is "LOADER"="C:\MyApp\bin\Release\MyApp.dll" the full path?

 

 

<CommandMethod("RegisterApp")> _
  Public Sub RegisterApp()

      Dim prodKey As String = HostApplicationServices.Current.RegistryProductRootKey
      Dim appName As String = "WhatEverNameYouWantToUse"
      Dim regAcadProdKey As RegistryKey = Registry.CurrentUser.OpenSubKey(prodKey)
      Dim regAcadAppKey As RegistryKey = regAcadProdKey.OpenSubKey("Applications", True)
      Dim subKeys() As String = regAcadAppKey.GetSubKeyNames()
      For Each subKey As String In subKeys

          If (subKey.Equals(appName)) Then
              regAcadAppKey.Close()
              Exit Sub
          End If
      Next
      Dim assemblyPath As String = Assembly.GetExecutingAssembly().Location
      Dim regAppAddInKey As RegistryKey = regAcadAppKey.CreateSubKey(appName)
      regAppAddInKey.SetValue("DESCRIPTION", appName, RegistryValueKind.String)
      regAppAddInKey.SetValue("LOADCTRLS", 14, RegistryValueKind.DWord)
      regAppAddInKey.SetValue("LOADER", assemblyPath, RegistryValueKind.String)
      regAppAddInKey.SetValue("MANAGED", 1, RegistryValueKind.DWord)
      regAcadAppKey.Close()
  End Sub

  <CommandMethod("UnregisterApp")> _
  Public Sub UnregisterApp()
      Dim prodKey As String = HostApplicationServices.Current.RegistryProductRootKey
      Dim appName As String = "WhatEverNameYouWantToUse"
      Dim regAcadProdKey As RegistryKey = Registry.CurrentUser.OpenSubKey(prodKey)
      Dim regAcadAppKey As RegistryKey = regAcadProdKey.OpenSubKey("Applications", True)   ' 
      regAcadAppKey.DeleteSubKeyTree(appName)
      regAcadAppKey.Close()
  End Sub

Posted

Hi Jeff,

 

manual netload method is working fine, but I want my DLL app to be loaded automatically when AutoCAD launches.

I have used the registry and LISP method. But the DLL app though is loaded, the commands didn't get recognized.

 

I do see some difference with registry values set. I will try to set "LOADCTRLS" to 14 Dword value to see whether it helps.

Posted

Hey zetazee,

 

Sorry I meant Netload manually the first time. Hopefully that change works

Posted

Hi Jeff,

 

Thanks for the assistance.

 

I managed to solve my problem. It's to do with my dll reading the app.config file which confuses with the acad.exe.config file settings. Hence my intended settings were not loaded, and causing the commands to not be recognized.

Posted

may be a slash issue

 

you use

 

"LOADER"="C:\MyApp\bin\Release\MyApp.dll"

 

try

 

"LOADER"="C:\\MyApp\\bin\\Release\\MyApp.dll"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...