Author Topic: NETLOAD not loading DLL on certain computers  (Read 15894 times)

0 Members and 1 Guest are viewing this topic.

FRaccie

  • Guest
NETLOAD not loading DLL on certain computers
« on: January 30, 2012, 09:22:04 AM »
So I've created a AutoCAD 2012 using VS Studio 2012 in Visual Basic. (Object ARX 2012/.NET 4.0 Framework FULL)

When I run it on my 2 test computers (x86/x64) everything loads fine.

So I sent the file to one of our external CAD designers to load the dll but nothing happens.
No error message of some sort. The toolbar doesn't load at all.
Full 4.0 Framework is installed as well as the ObjectARX files.

Everything was built using the USING and TRY CATCH statements to get as much error info as possible but nothing returns.

The only difference is that my Version is the Retail AutoCAD and the one externally is the Product Design Suite.
This seems to be more of a licensing difference and not a difference in the AutoCAD software.
Visual Studio is not installed so I can't debug on the remote machine.

Is there anyone who has experience with errors of this kind?
Is there a way to debug NETLOAD using AutoCAD?

Greetz FRaccie


Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: NETLOAD not loading DLL on certain computers
« Reply #1 on: January 30, 2012, 09:30:48 AM »
Show the code.

In my practice similar was, when the program at loading read the data from xml file. On different computers in regional settings there were different separators of a decimal part (at one - a comma, at others - a point). I have added check on a separator and the problem has disappeared. There can be at you a same situation?
« Last Edit: January 30, 2012, 09:36:18 AM by Andrey »

n.yuan

  • Bull Frog
  • Posts: 348
Re: NETLOAD not loading DLL on certain computers
« Reply #2 on: January 30, 2012, 10:13:17 AM »
You may look into 2 possible causes first:

1. It looks like your code implements IExtensionApplication interface (because you expect something like toolbar being load after NETLOAD command). Are you sure absolutely the code in Intialize() is entirely wrapped in Try...Catch End Try block? That is:

Public Sub Initialize()
    Try
        'Do some initializing action here, such as loading your toolbar
    Catch
        Application.DocumentManager.MdiDocument.Ediotr.WriteMessage(vbCr & "Initializing failed")
    EndTry
End Sun

As you may or may not know, if an unhandled exception occurs in Initialize(), AutoCAD would silently drop the NETLOADed assembly without indicating anything to users.

With a Try...Catch in Initialize(), your assembly would remain loaded, however, it may not work as expected (very likely), depending on when the execption happens during the initialization and how you handled it.

2. Since you target .NET 4.0. You need to make sure all Acad's acad.exe.config has "<supportedRuntime version="v4.0" />" underneath the <startup.../> section. If this line is commented out or does not exist in acad.exe.config, AutoCAD2012 will actually uses .NET3.X to run its .NET code. However, usually in this case, Acad will show some loading error at command line.

Since you say nothing happens after NETLOAD, you probably want to look into 1 carefully first.


FRaccie

  • Guest
Re: NETLOAD not loading DLL on certain computers
« Reply #3 on: January 30, 2012, 12:04:20 PM »
Code of MyPlugin.vb on request
Code - Visual Basic: [Select]
  1.  ' (C) Copyright 2012 - FRaccie
  2.  
  3. Imports System
  4. Imports Autodesk.AutoCAD.Runtime
  5. Imports Autodesk.AutoCAD.ApplicationServices
  6. Imports Autodesk.AutoCAD.DatabaseServices
  7. Imports Autodesk.AutoCAD.Geometry
  8. Imports Autodesk.AutoCAD.EditorInput
  9.  
  10.  
  11. ' This line is not mandatory, but improves loading performances
  12. <Assembly: ExtensionApplication(GetType(AutoCAD_Tools.MyPlugin))>
  13.  
  14. Namespace AutoCAD_Tools
  15.  
  16.     Public Class MyPlugin
  17.         Implements IExtensionApplication
  18.  
  19.         Public Sub Initialize() Implements IExtensionApplication.Initialize
  20.             Try
  21.                 ' Create an AutoCAD toolbar with buttons
  22.  
  23.                 Dim callensModule As System.Reflection.Module = System.Reflection.Assembly.GetExecutingAssembly().GetModules()(0)
  24.                 Dim callensModulePath As String = callensModule.FullyQualifiedName
  25.  
  26.                 callensModulePath = callensModulePath.Substring(0, callensModulePath.LastIndexOf("\"))
  27.  
  28.                 Dim acadApp As Autodesk.AutoCAD.Interop.AcadApplication _
  29.                = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
  30.  
  31.                 Dim hwTb As Autodesk.AutoCAD.Interop.AcadToolbar _
  32.                     = acadApp.MenuGroups.Item(0).Toolbars.Add("Callens & EMK - AutoCAD Toolbar")
  33.  
  34.                 Dim tbBut0 As Autodesk.AutoCAD.Interop.AcadToolbarItem _
  35.                 = hwTb.AddToolbarButton(0, "Hello", "Hello My Makers", "_HELLO ")
  36.                 'tbBut0.SetBitmaps(callensModulePath + "\tbBut0.bmp", callensModulePath + "\tbBut0.bmp")
  37.  
  38.                 'Dim tbBut1 As Autodesk.AutoCAD.Interop.AcadToolbarItem _
  39.                 '= hwTb.AddToolbarButton(1, "About", "About My Makers", "_SHOWABOUT ")
  40.                'tbBut1.SetBitmaps(callensModulePath + "\dwg2excel.bmp", callensModulePath + "\dwg2excel.bmp")
  41.  
  42.                 Dim tbBut2 As Autodesk.AutoCAD.Interop.AcadToolbarItem _
  43.                 = hwTb.AddToolbarButton(2, "DWG2EXCEL", "DWG2EXCEL", "_DWG2EXCEL ")
  44.                 tbBut2.SetBitmaps(callensModulePath + "\dwg2excel.bmp", callensModulePath + "\dwg2excel.bmp")
  45.                 ' MsgBox(callensModulePath + "\dwg2excel.bmp")
  46.  
  47.                 Dim tbBut3 As Autodesk.AutoCAD.Interop.AcadToolbarItem _
  48.                     = hwTb.AddToolbarButton(3, "EXCEL2DWG", "EXCEL2DWG", "_EXCEL2DWG ")
  49.                 tbBut3.SetBitmaps(callensModulePath + "\excel2dwg.bmp", callensModulePath + "\excel2dwg.bmp")
  50.  
  51.                 hwTb.Dock(Autodesk.AutoCAD.Interop.Common.AcToolbarDockStatus.acToolbarDockLeft)
  52.             Catch
  53.                 Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(vbCr & "Initializing failed")
  54.             End Try
  55.  
  56.         End Sub
  57.  
  58.         Public Sub Terminate() Implements IExtensionApplication.Terminate
  59.             ' Do plug-in application clean up here
  60.        End Sub
  61.     End Class
  62.  
  63. End Namespace
  64.  
- Everything in Try and Catch.

This code works on all my test computers in x86 and x64.

- Checked the acad.exe.config file and 4.0 framework is set.

Code - XML: [Select]
  1. <configuration>
  2.  
  3.   <startup useLegacyV2RuntimeActivationPolicy="true">
  4.     <supportedRuntime version="v4.0"/>
  5.   </startup>
  6.  
  7. <!--All assemblies in AutoCAD are fully trusted so there's no point generating publisher evidence-->
  8.    <runtime>        
  9.         <generatePublisherEvidence enabled="false"/>    
  10.    </runtime>
  11. </configuration>
  12.  
  13.  
« Last Edit: January 30, 2012, 12:08:34 PM by FRaccie »

n.yuan

  • Bull Frog
  • Posts: 348
Re: NETLOAD not loading DLL on certain computers
« Reply #4 on: January 30, 2012, 01:21:02 PM »
You may want to add a few

Editor.WriteMessage("....")

within Try...Catch block, at lease after all your initializing code and before Catch, so that when the code NETLOADED into an Acad session where you could not debug, you can tell, from the message printed at command line, if the code in the Try...Catch block is actually run and, if break occur, where the break could be. Then you can tell if your initializing code is all executed correctly or not.

BlackBox

  • King Gator
  • Posts: 3770
Re: NETLOAD not loading DLL on certain computers
« Reply #5 on: January 30, 2012, 01:47:54 PM »
I would think that with the DLL successfully loading on some computers, an not others that this is not an Initialization issue, and instead a file issue. Specifically the properties of the DLL once copied to the problem users' machines.

Where is the DLL located, one a server, or locally?

When the user right clicks -> Properties, is everything as it should be, or does the file need to be 'unblocked'?

I'm sure there are other potential causes, but hopefully these may be of use to you.
"How we think determines what we do, and what we do determines what we get."

huiz

  • Swamp Rat
  • Posts: 917
  • Certified Prof C3D
Re: NETLOAD not loading DLL on certain computers
« Reply #6 on: January 30, 2012, 02:39:21 PM »
I would think that with the DLL successfully loading on some computers, an not others that this is not an Initialization issue, and instead a file issue. Specifically the properties of the DLL once copied to the problem users' machines.

Where is the DLL located, one a server, or locally?

When the user right clicks -> Properties, is everything as it should be, or does the file need to be 'unblocked'?

I'm sure there are other potential causes, but hopefully these may be of use to you.

I'm not sure that is the problem. I see the same problem with some software I've developed. On most computers it runs without trouble, and very few the dll seems to load but won't run. In the installer there are dlls with dialog applications and one dll with a custom palette. The dialog applications always run, everywhere, but the palette application won't run everywhere. Just one out of hundred computers or so.

The trouble is, I don't have computers where the application won't run, only a very few customers. But I can't ask them to debug my applications :-)
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

BlackBox

  • King Gator
  • Posts: 3770
Re: NETLOAD not loading DLL on certain computers
« Reply #7 on: January 30, 2012, 05:46:34 PM »
That would then suggest that there is a difference in user environment, no?

Are you by chance using Windows Presentation Foundation (WPF) for your tool palette(s)? If so, then you probably already know that the default XAML reference needs to be removed for compiled projects .NET 3.5 & older. LoL

In any event, sorry I could not be of more help.
"How we think determines what we do, and what we do determines what we get."

huiz

  • Swamp Rat
  • Posts: 917
  • Certified Prof C3D
Re: NETLOAD not loading DLL on certain computers
« Reply #8 on: January 31, 2012, 05:53:06 AM »
I don't use WPF, just User Controls (Windows forms). Good tip though about XAML, when I will use it I keep this in mind :-)


About differences in user environments, I really don't know what causes trouble. One customer has tried to run my application inside AutoCAD 2012 but it won't run. It does not show errors, the new commands in the dll are not available, just nothing. After that he tried to run the application in AutoCAD 2010 and it runs like it should be. No problem at all, Palette pops up, everything. On the same computer.

It is not something between different AutoCAD versions, my application runs from 2010 to 2012 in AutoCAD, Map3D and Civil3D, and about one of hundred installations seems to do nothing. The other 99 of hundred installations work fine. And on those computers where it can't run in 2012, it can run in 2010 (also on other computers it might run in 2012 and not in 2010 or 2011).

The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

FRaccie

  • Guest
Re: NETLOAD not loading DLL on certain computers
« Reply #9 on: January 31, 2012, 07:02:47 AM »
That would then suggest that there is a difference in user environment, no?

Are you by chance using Windows Presentation Foundation (WPF) for your tool palette(s)? If so, then you probably already know that the default XAML reference needs to be removed for compiled projects .NET 3.5 & older. LoL

In any event, sorry I could not be of more help.

No WPF, XAML reference are not to be removed when using 4.0 framework.

tnx anyway
« Last Edit: January 31, 2012, 08:13:20 AM by FRaccie »

FRaccie

  • Guest
Re: NETLOAD not loading DLL on certain computers
« Reply #10 on: January 31, 2012, 07:43:23 AM »
Show the code.

In my practice similar was, when the program at loading read the data from xml file. On different computers in regional settings there were different separators of a decimal part (at one - a comma, at others - a point). I have added check on a separator and the problem has disappeared. There can be at you a same situation?

Owkey,
So I think I found what you meant -> "AutoCAD2012Toolsx64"
This should be "AutoCAD_2012_Tools_x64" in my config.xml

I can only test this tomorrow so I will post a follow up.

Greetz FRaccie

BlackBox

  • King Gator
  • Posts: 3770
Re: NETLOAD not loading DLL on certain computers
« Reply #11 on: January 31, 2012, 12:30:36 PM »
That would then suggest that there is a difference in user environment, no?

Are you by chance using Windows Presentation Foundation (WPF) for your tool palette(s)? If so, then you probably already know that the default XAML reference needs to be removed for compiled projects .NET 3.5 & older. LoL

In any event, sorry I could not be of more help.

No WPF, XAML reference are not to be removed when using 4.0 framework.

tnx anyway

Same difference... You say 'Tomato', and I say 'Tomato'.

^^ LoL, it's even funnier when written and not spoken.  :lol:
"How we think determines what we do, and what we do determines what we get."

FRaccie

  • Guest
Re: NETLOAD not loading DLL on certain computers
« Reply #12 on: February 01, 2012, 06:28:36 AM »
So I tested the fixed XML -> No Go

Still can't seem to find the error.

FRaccie

  • Guest
Re: NETLOAD not loading DLL on certain computers
« Reply #13 on: February 02, 2012, 08:51:54 AM »
I've tested the toolbar code on a dozen of computers and only the ones with the Design Suite installed could not create it.
All my other code works because of the try...catch around the toolbar creation code.

If anyone has a better way of creating a toolbar, plz don't hesitate to point something out.

Greetz FRaccie and tnx for the help

BlackBox

  • King Gator
  • Posts: 3770
Re: NETLOAD not loading DLL on certain computers
« Reply #14 on: February 02, 2012, 09:00:32 AM »
If anyone has a better way of creating a toolbar, plz don't hesitate to point something out.

Have you considered simply using a CUI(x) file instead?  :?
"How we think determines what we do, and what we do determines what we get."

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
Re: NETLOAD not loading DLL on certain computers
« Reply #15 on: February 02, 2012, 12:18:52 PM »
I've tested the toolbar code on a dozen of computers and only the ones with the Design Suite installed could not create it.
All my other code works because of the try...catch around the toolbar creation code.

If anyone has a better way of creating a toolbar, plz don't hesitate to point something out.

Greetz FRaccie and tnx for the help

Maybe take the toolbar creation code out of Initialize.
Have a function to see if the toolbar exists on the users system.
Test for that when the user runs one of your commands.
If the toolbar doesn't exist THEN create it.

If you are saving the toolbar on the users system (the CUI files) this will only happen once.

At least this way you may be able to isolate what is really happening. Your dll will get loaded.
If you clean out Initialize and it still doesn't netload that will tell you something too.  :?
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions