.NET

.NET

Reply
Distinguished Contributor spu
Distinguished Contributor
spu
Posts: 141
Registered: ‎02-21-2007
Message 1 of 8 (509 Views)
Accepted Solution

DLL loading But no commands available not initialized as well

509 Views, 7 Replies
11-28-2012 11:32 PM

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

 

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

 

 

 

 

 

 

Moderator
Alexander.Rivilis
Posts: 1,450
Registered: ‎04-09-2008
Message 2 of 8 (497 Views)

Re: DLL loading But no commands available not initialized as well

11-29-2012 02:41 AM 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


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Distinguished Contributor spu
Distinguished Contributor
spu
Posts: 141
Registered: ‎02-21-2007
Message 3 of 8 (493 Views)

Re: DLL loading But no commands available not initialized as well

11-29-2012 03:04 AM 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

 

*Expert Elite*
norman.yuan
Posts: 1,063
Registered: ‎04-27-2009
Message 4 of 8 (481 Views)

Re: DLL loading But no commands available not initialized as well

11-29-2012 06:36 AM 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.

Distinguished Contributor spu
Distinguished Contributor
spu
Posts: 141
Registered: ‎02-21-2007
Message 5 of 8 (438 Views)

Re: DLL loading But no commands available not initialized as well

12-01-2012 10:26 PM 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

Distinguished Mentor
gasty1001
Posts: 582
Registered: ‎04-11-2010
Message 6 of 8 (425 Views)

Re: DLL loading But no commands available not initialized as well

12-02-2012 08:03 AM 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

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 7 of 8 (410 Views)

Re: DLL loading But no commands available not initialized as well

12-02-2012 03:03 PM 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.

Distinguished Contributor spu
Distinguished Contributor
spu
Posts: 141
Registered: ‎02-21-2007
Message 8 of 8 (396 Views)

Re: DLL loading But no commands available not initialized as well

12-02-2012 09:47 PM 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

 

 

 

 

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.