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

DLL loading But no commands available not initialized as well

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
spu
Advocate
1182 Views, 7 Replies

DLL loading But no commands available not initialized as well

Hi,

 

Our application DLL works fine in development PC but not loads in other PCs. There are no error messages. We where using AutoCAD 2012 & Visual studio 2010. The project is a class library and it contains a class implementing initilize and terminate methods. Also it contains many autocad commands and some .NET forms which will be invoked from the commands.

 

Netlod completes without any message. But the commands are not available, neither the initilize method runs.....

 

Other details:

AutoCAD : 2012

OS : windows 7 both 32 & 64bit [we tried both]

.NET framework targeted: 3.5

Type: Class lib

Reference : Acdbmgd.dll & acmgd.dll  from ObjectARX >> inc

 

Please help.

 

Regards,

Shijith

 

7 REPLIES 7
Message 2 of 8
Alexander.Rivilis
in reply to: spu


@spu wrote:
...

Reference : Acdbmgd.dll & acmgd.dll  from ObjectARX >> inc

...


Reference settings must be Copy Local = False

Also build solution to Release configuration (not to Debug)

AutoCAD 2012 request .NET 4.0

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 3 of 8
spu
Advocate
in reply to: spu

Hi,

 

Thanks for the advice. But still I am not able to run it.

All the mentioned settings are already presend other than NET version 4.

 

When i changed the targeted framework to .NET 4,100's of build errors ike the following is generated. Code is not building, if chaged to target 3.5 everything builds correctly. 

 

"Type or namespace name 'EditorInput' does not exist in the namespace 'Autodesk.AutoCAD' (are you missing an assembly reference?"

 

We have some other .NET dlls which lods on this machines fine. Which is older and refered to AutoCAD 2010 dlls while building.

 

 

Please advice how to use the .NET 4 autocad dlls reference .r  did I had to use the reference to old version reference...

 

Regards,

shijith

 

Message 4 of 8
norman.yuan
in reply to: spu

Did you enclosed the code in IExtensionApplication.Initialize() in a try{...}catch{...} block? any exception occured in Initialize() fails the assembly loading, hence make the command methods in it unavailable.

Message 5 of 8
spu
Advocate
in reply to: norman.yuan

Hi,

 

I added the try catch and targeted to version 4 of framework still neither any message nor any commands available.

 

Regards,

Shijith

Message 6 of 8
hgasty1001
in reply to: spu

Hi,

 

Some things to check:

 

  • Acdbmgd.dll  and Acmgd.dll referenced from ARX\Inc no matter you are in x32 o x64
  • Set Copy Local to False for both dlls, and any other referenced from ARX
  • Target  CPU in VS to Any CPU, no matter you are in x32 o x64
  • Eliminate Framework 3.5 from your vocabulary (think it does not exists)
  • Target Framework in VS to 4.0 (not 4.0 Client Profile)
  • Acad.exe.config to 4.0<supportedRuntime version="v4.0"/>
  • For testing: Output to Debug\Bin
  • Clean the project: In VS Build Menu, Clean Solution
  • Manually clean the output directory if necessary
  • What happen if you comment out the Initialize method
  • What happen if you comment out all the other methods & subs  in the class, and left just one minimal command to test
  • Put something in the Initialize method in order to know that was loaded ok
  • Check the attribute flags of your commands, just try with <CommandClass("SomeCommand")> and nothing else, after that it's ok, you can test with other flags and their implicances.

 

 

Finally, post your code here, specially the Initialize/terminate method

 

Gaston Nunez

Message 7 of 8
DiningPhilosopher
in reply to: spu


@spu wrote:

Hi,

 

I added the try catch and targeted to version 4 of framework still neither any message nor any commands available.

 

Regards,

Shijith


Per chance, was the catch{} block displaying any message when it was hit?  An empty catch{} block is the same as no catch{} block (or try{} block).  If your commands are not being registered, it could be an exception being raised inside of your Initialize() method or some code called from there, or it could also be a static field or variable initialization which will happend when AutoCAD creates the instance of the class that implements IExtensionApplication, which is before it calls Initialize(). Unfortunately, those exceptions can't be caught by your code unless you use a static constructor to do all initialization, rather thah doing it directly in the static member/variable declaration.

 

In otherwords:

 

public class MyApp : IExtensionApplication
{
   public void Intiialize()
   {
      try
      {
         // do all initialization here
      }
      catch( System.Exception ex )
      {
         Console.Beep();
         Application.DocumentManager.MdiActiveDocument
            .Editor.WriteMessage( "\nException in Initialize(): {0}",
               ex.ToString() );
      }
   }

   /// the call to GetMyString() runs before Initialize() 
   /// is called and you can't easily catch an exception
   /// thown by the called API, so rather than do this:
   
   static string MyString = GetMyString(); 

   /// Use a static constructor instead:

   static MyApp()
   {
      try
      {
         MyString = GetMyString();
      }
      catch( System.Exception ex )
      {
         Console.Beep();
         Application.DocumentManager.MdiActiveDocument
            .Editor.WriteMessage( "\nException in Initialize(): {0}",
               ex.ToString() );
      }
   }
}

 The other thing I don't think anyone mentioned, is whether you have any CommandClass attributes in your assembly. IF you do, you must have one for every class that has command methods.

Message 8 of 8
spu
Advocate
in reply to: DiningPhilosopher

Hi,

 

Thanks for gasty1001 & DiningPhilosopher for their very valuable comments. Finally I solved it.

 

I tried all the suggestions by both of you and still there was no error message and it loads but nothing happens.

This is how I solved it.

 

I created another project and added a initial routine and tested on the PC that have problem. It works fine then

added a test command ...works fine

added a pallet.....works fine

added a form ....works fine

added a Crystal report and viewer....BANG got the error message.....Please see the attached

 

In the error message it show me to added a Reg Key for meore info and to log it.

set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.

 

I done it. I loaded my real dll still no error message or not running....

I installed CR  64bit redistribution for VS2010....

Thats it; the test as well as the original starts working .....

 

 

We where converting one of our legacy VBA application to .Net and it is a huge application which includes Commands, Forms, Crystal Reports, Pallets, Calling web services & other custum objects and toolbars. It is started with AutoCAD 2008 so code was huge. I commented many part but still i don't know why it don't shown any error message while Crystal reports where not present. May be it not loads at startup. But there should be some error message.........

 

I hope these steps and this entire post will helpful to somebody.

 

Thank you all .....gasty1001 DiningPhilosopher Alexander.Rivilis  norman.yuan.....

 

Regards,

Shijith

 

 

 

 

 

 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost