External Plug-In Unknown Command Error

External Plug-In Unknown Command Error

ian.berns
Contributor Contributor
2,599 Views
4 Replies
Message 1 of 5

External Plug-In Unknown Command Error

ian.berns
Contributor
Contributor

Hi All,

 

I am currently migrating an external Plant3D plug-in from 2016 to 2018. I have gotten the plug-in to fully run correctly on my test machine and have no issues running the commands properly. However, when I run on a test user's system with 2018, it says "Unknown Command" when running my command. Both systems load the plug-in on the top ribbon, however, the test user gets unknown command when running it.

 

Info:

Project Developed in Visual Studio 2019 Community Edition

C# .NET 4.6 Utilized

 

I have tried:
Changing PackageContent.xml to match the correct series which is "r22.0"

Making sure all references are copy local = false

Making sure all references point to the correct folder of AutoCAD 2018 and AutoCAD/PLNT3D

Verifying the plugin bundle was put in the test users C:/Program Files/Autodesk/ApplicationPlugins folder

 

Please let me know why there may be a discrepancy between systems when utilizing this plugin.

 

Best Regards,

Ian Berns

0 Likes
Accepted solutions (1)
2,600 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor

While the possibility is low that your plug-in package may have error that prevent your app being automatically loaded, I'd say, it is still possible. So, it is up to you to make it certain.

 

You would simply try to load it manually with command "NETLOAD" and then try your commands in the app. If it still gives the "Unknown command", you now know it is the app itself has problem, not the auto-load package. Considering it worked with your own development computer, the first thing you need to look at the code of the app is whether the app implements IExtensionApplication. If yes, is the code in Initialize() correctly wrapped with try...catch... block? Not caught exception raised in Initailize() would render the loaded assembly (your app) useless, thus "unknown command". 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 5

ian.berns
Contributor
Contributor

Awesome response! Led me down a path which my two test systems netload with errors. However, my system netloads with no issues.

 

Here is the issue from the other two systems netloading:

Command: Cannot load assembly. Error details: System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Program Files\Autodesk\ApplicationPlugins\[THIRDPARTYAPPNAME] Plugin.bundle\[THIRDPARTYDLLNAME].dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

File name: 'file:///C:\Program Files\Autodesk\ApplicationPlugins\[THIRDPARTYAPPNAME] Plugin.bundle\[THIRDPARTYDLLNAME].dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)

   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)

   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)

   at System.Reflection.Assembly.LoadFrom(String assemblyFile)

   at Autodesk.AutoCAD.Runtime.ExtensionLoader.Load(String fileName)

   at loadmgd()

 

Any ideas? I looked into CAS policy, seems to be an application side policy that I do not want to change for all users. This has to be on the plugin side for sure

0 Likes
Message 4 of 5

norman.yuan
Mentor
Mentor
Accepted solution

So, its just an entirely third party plug-in and you only updated the auto-load package? Does it come as installation package (*.msi), or you simply downloaded the package and copied/pasted the DLL or DLLs in place? Are there any other dependent DLLs the app uses located in a network location/folder?

 

My guess is that you just copied the downloaded DLL(s) to the place. Since Windows 7 (AFAIK), Windows would flag any executable file (EXE, or DLL...) that is downloaded from the internet (or even your organization's intranet, sometimes, depending on how the intranet is formed) as unsafe and locks it up as a executable file from network somewhere. That could the cause of the error you saw.

 

You can go to the DLL file(s) and right-click it and select "Properties", in the "General" tab at bottom, you might see "Security:   ...." message with a "Unlock" check box. If so, this the reason: the file was from the internet and potentially unsafe. You can tick the check box to unlock it, as long as you know the file is OK to use.

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 5

ian.berns
Contributor
Contributor

Norman, I would like to thank you for the replies. You have solved it!

 

So I was editing the repository and code but since it came from my main machine, it never proved an issue. However, after I went on the other machines and clicked on the files properties and unblocked them it all worked. Thank you so much for your time.

0 Likes