Author Topic: MYNETLOAD - Extension Loader Diagnostic Tool  (Read 14070 times)

0 Members and 1 Guest are viewing this topic.

TheMaster

  • Guest
MYNETLOAD - Extension Loader Diagnostic Tool
« on: December 29, 2012, 09:23:38 PM »
For AutoCAD 2012:

If commands defined in your extension/plug-in assembly are not being recognized, this tool will attempt to identify the cause(s) of the problem.  The readme is in Class1.cs

If you try this tool and it does not detect the cause of unrecognized commands defined by your plug-in, please let me know about it.

[Edit: 12-31-12]:  Uploaded a revised version with a bug removed (the code was originally run from a menu item in my 'Managed Object Explorer' diagnostic tool, and had to be ripped out of that and have dependencies on other parts eliminated, which usually introduces a few bugs. :roll: ).
« Last Edit: December 31, 2012, 06:33:57 AM by TT »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #1 on: December 30, 2012, 02:37:20 AM »
Haven't tried it Tony, just looked through your comments.
This looks like it could make life easier for a lot of people.

Thanks for your continuing contribution to this expanding group of customisers and developers.
Best wishes for a healthy, safe and prosperous new year.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

TheMaster

  • Guest
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #2 on: December 30, 2012, 02:56:36 AM »
Haven't tried it Tony, just looked through your comments.
This looks like it could make life easier for a lot of people.

Thanks for your continuing contribution to this expanding group of customisers and developers.
Best wishes for a healthy, safe and prosperous new year.

Kerry, thanks.

I've only used it a few times to troubleshoot deployed software where the problem couldn't be repro'd on my systems here, and it saved my tail every time.

I usually run it myself on the remote system where the problem is, using TeamViewer, so the user doesn't need to do anything except watch.


gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #3 on: December 30, 2012, 05:28:48 AM »
Hi Tony,

Seems to be very interesting, thanks for sharing.
Happy new year to you and all swampers.
Speaking English as a French Frog

TheMaster

  • Guest
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #4 on: December 30, 2012, 02:14:55 PM »
Thanks Gile.

Happy New Year All

fixo

  • Guest
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #5 on: December 31, 2012, 08:09:25 AM »

Happy New Year All
Happy New Year Tony!
Thanks for your continuous help to all
Kind regards,
Oleg

zoltan

  • Guest
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #6 on: December 31, 2012, 04:31:59 PM »
Thanks Tony, this is very cool and will be of great help.

I did notice that you are collecting all of the command methods using reflection on this line..
Code - C#: [Select]
  1. var methods = type.GetMethods( BindingFlags.Public | BindingFlags.Instance )
  2.         .Where( m => m.IsDefined( typeof( ICommandLineCallable ), true ) );
  3.  
...which collects all of public, instance methods which are marked with the CommandMethodAttribute.

Is it not also true that command methods could be static if they are defined in a static class?



Jeff H

  • Needs a day job
  • Posts: 6150
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #7 on: December 31, 2012, 09:57:45 PM »
Thanks again boss!!

TheMaster

  • Guest
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #8 on: January 01, 2013, 11:05:32 AM »
Thanks Tony, this is very cool and will be of great help.

I did notice that you are collecting all of the command methods using reflection on this line..
Code - C#: [Select]
  1. var methods = type.GetMethods( BindingFlags.Public | BindingFlags.Instance )
  2.         .Where( m => m.IsDefined( typeof( ICommandLineCallable ), true ) );
  3.  
...which collects all of public, instance methods which are marked with the CommandMethodAttribute.

Is it not also true that command methods could be static if they are defined in a static class?

Yes, command methods can be static (in a static class or not), but the code is only looking for classes that have instance methods with CommandMethod attributes applied, because it is testing creation of an instance of each of those types.

VVeli

  • Newt
  • Posts: 27
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #9 on: January 03, 2013, 03:30:28 AM »
Thanks a lot Tony that you share information with us.
This is our problem too when we deliver products to customers.
Your code show us why native NETLOAD command works like a ****.

Most common problems usually are that .NET application is compiled
to different framework than AutoCAD. I think that AutoCAD 2013 is
purely compiled to framework 4.0 and below that are to framework 2.0.

Second problem is that if multiple classes uses commandclass attribute
then usually commands are missing.

Ok, thats all right now and good new year to all! :-D

Cheers
Veli V.

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #10 on: March 21, 2013, 07:52:00 PM »
Have you tested this on 2013 Tony?
I just did a sample deployment of my palette and tools and discovered it fails to load on about 1/3 of the target machines. Will definitely be using this tool to investigate.
Many thanks for this contribution!

TheMaster

  • Guest
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #11 on: March 21, 2013, 11:06:13 PM »
Have you tested this on 2013 Tony?
I just did a sample deployment of my palette and tools and discovered it fails to load on about 1/3 of the target machines. Will definitely be using this tool to investigate.
Many thanks for this contribution!

You may have to build it for 2013, but be advised that MYNETLOAD actually exposes a security flaw in AutoCAD's managed runtime that if exploited, may allow loading of 'unapproved' assemblies.


WILL HATCH

  • Bull Frog
  • Posts: 450
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #12 on: March 26, 2013, 01:28:51 PM »
Tony,

When running this program I get the following error:
Stacktrace: System.InvalidOperationException: ExtensionLoader not found
   at ExtensionLoaderTest.MyExtensionLoader.GetAssemblyLoadHandler()
   at ExtensionLoaderTest.MyExtensionLoader.EnableExtensionLoader(Boolean enable)
   at ExtensionLoaderTest.MyExtensionLoader.MyNetLoadCommand()

From analyzing your methods I can see you're trying to get the Application's ExtensionLoader object to extract the OnAssemblyLoad handler to stop it from being called while your tool is active.  I'll look into the issue to try and see what Autodesk has changed in the 'Big Split' that is causing the issue.

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #13 on: March 26, 2013, 11:56:37 PM »
Aww snap
found it here....

They found the security flaw you mentioned and fixed it.

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #14 on: March 27, 2013, 09:22:06 PM »
Hmmmm... Still no success.  It appears the security features are not what's limiting me though

Matus

  • Guest
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #15 on: September 02, 2013, 04:46:05 AM »
I have the same problem as Will, is there any chance, that this tool will be usable in 2013?

Jeff H

  • Needs a day job
  • Posts: 6150
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #16 on: September 04, 2013, 02:46:18 AM »
I downloaded it but guess never used it or not on 2013 at least.
I  created a project with using required assemblies for 2013  and made one change noted below and project attached.

If interested a couple of notes of what needed changing.
There is a  Application class in accoremgd and Acmgd assembly
In accoremgd assembly is located in namespace Autodesk.AutoCAD.ApplicationServices.Core, and
for acmgd in namespace Autodesk.AutoCAD.ApplicationServices

The Application class in accoremgd assembly is abstract and the and the one in acmgd assembly inherits the application class in accoremgd.

In 2013 the ExtensionLoader class is still located in same namespace Autodesk.AutoCAD.ApplicationServices  but in a different assembly accoremgd.
 
So to quickly fix it make sure your using the Application type defined in accoremgd or pick another type.
Just used Document but could use any other type defined in accoremgd assembly.
Code - C#: [Select]
  1.     // Get the ExtensionLoader's AssemblyLoaded delegate:
  2.         static AssemblyLoadEventHandler GetAssemblyLoadHandler()
  3.         {
  4.             ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  5.                                                                 //CHANGE//
  6.             //Type type = typeof(Application).Assembly.GetType("Autodesk.AutoCAD.ApplicationServices.ExtensionLoader");/////
  7.                                                                  //TO//
  8.             //Type type = typeof(Autodesk.AutoCAD.ApplicationServices.Core.Application).Assembly.GetType("Autodesk.AutoCAD.ApplicationServices.ExtensionLoader");
  9.                                                                  //OR//
  10.             Type type = typeof(Document).Assembly.GetType("Autodesk.AutoCAD.ApplicationServices.ExtensionLoader");
  11.             if (type == null)
  12.                 throw new InvalidOperationException("ExtensionLoader not found");
  13.             MethodInfo method = type.GetMethod("OnAssemblyLoad", BindingFlags.Static | BindingFlags.Public);
  14.             if (method == null)
  15.                 throw new InvalidOperationException("OnAssemblyLoad() method not found");
  16.             return (AssemblyLoadEventHandler)Delegate.CreateDelegate(typeof(AssemblyLoadEventHandler), method);
  17.         }
  18.  
  19.  

gwhitch`

  • Mosquito
  • Posts: 2
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #17 on: August 09, 2016, 02:55:12 PM »
Does this tool exist? I cant find it anywhere. I am having a problem with the commands not showing up although I know the dll is being loaded

gwhitch`

  • Mosquito
  • Posts: 2
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #18 on: August 09, 2016, 02:57:15 PM »
Oops. Nevermind, I found it.

alexb

  • Mosquito
  • Posts: 2
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #19 on: June 11, 2023, 04:16:10 AM »
Hi,
I am aware that this is a very old topic but....
I am trying to NETLOAD some old assemblies in an old Acad 2012 x64, on Win 7.
On one of them I get the error "Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated."
I downloaded the Extension Loader Diagnostic Tool to help identify the problem but, to my dismay, I get the same error on loading the tool.
I want to emphasize that many other assemblies load and work correctly, so it's probably not a problem of Acad installation or .NET frameworks etc. I think.
I shall be thankful for any help.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #20 on: June 11, 2023, 04:32:32 AM »
According to google, it's a runtime mismatch

you can try to edit acad.exe.config

Quote
<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
 </startup>

or recompile the module for whatever framework 2012 supported

edit, and make sure you have the target framework installed on your computer

alexb

  • Mosquito
  • Posts: 2
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #21 on: June 11, 2023, 10:29:40 AM »
Thank you El Jefe.
I edited acad.exe.config to runtime 4.0. It was set (intentionally) to runtime 2.0, and never had any problems with that, there were plenty of modules loading and running ok.
Anyway, now the tool loads and works and it finds no faults when loading my assembly.
But:
Under the debugger, my assembly loads with no error messages but the command is not registered.
Starting without debugging: ditto.
Manually opening Acad and loading the assembly: it loads ok, the command is registered and the forms is shown but of course, cannot debug it.
Any ideas?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: MYNETLOAD - Extension Loader Diagnostic Tool
« Reply #22 on: June 11, 2023, 06:02:36 PM »
Debugging was an issue for some versions, AutoCAD was using fibers, .NETís debuggers couldnít see them
you can play with NEXTFIBERWORLD/FIBERWORLD and toggling useLegacyV2RuntimeActivationPolicy