<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Load Plug-in DLL Without Editing Config File in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/load-plug-in-dll-without-editing-config-file/m-p/7316294#M30020</link>
    <description>&lt;P&gt;I had the same issue even after I fooled with the&lt;/P&gt;&lt;P&gt;"&lt;SPAN&gt;&amp;lt;loadFromRemoteSources enabled="true" /&amp;gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The one work around I found was to have the other machine, right click the dll, and go to its properties. In the security area, check the box to unblock the dll, then apply and ok.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This worked for me and my office.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Aug 2017 15:06:55 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-08-21T15:06:55Z</dc:date>
    <item>
      <title>Load Plug-in DLL Without Editing Config File</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-plug-in-dll-without-editing-config-file/m-p/7313507#M30018</link>
      <description>&lt;P&gt;I'm developing a windows form application that needs to open AutoCAD and load my plug-in DLL to send custom commands and lisp functions to it.&lt;/P&gt;&lt;P&gt;I'm using the following C# code and it works fine in my device&amp;nbsp;but when I tried to run it another machines, I got the attached error message "&lt;STRONG&gt;&lt;EM&gt;Cannot load file or &amp;nbsp;assembly...&lt;/EM&gt;&lt;/STRONG&gt;".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it worked fine after editing&amp;nbsp;AutoCAD config file "acad.exe.config" by adding :&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;lt;runtime&amp;gt;&amp;nbsp; &amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;lt;loadFromRemoteSources enabled="true" /&amp;gt;&amp;nbsp; &amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;lt;/runtime&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any other way to fix this error programmatically to avoid editing the config file manually? or is there a better way to load my plug-in DLL and call the lisp functions from it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//1-Opening AutoCAD//&lt;/P&gt;&lt;P&gt;&amp;nbsp;AcadApplication _acadApp;&lt;/P&gt;&lt;P&gt;const string progID = "AutoCAD.Application";//for all AutoCAD versions&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;_acadApp = (AcadApplication)Marshal.GetActiveObject(progID);&lt;BR /&gt;}&lt;BR /&gt;catch&amp;nbsp;&lt;BR /&gt;{&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;Type acType = Type.GetTypeFromProgID(progID);&lt;/P&gt;&lt;P&gt;if (acType == null)&lt;BR /&gt;acType = Type.GetTypeFromProgID("AutoCAD.Application");&lt;/P&gt;&lt;P&gt;_acadApp = (AcadApplication)Activator.CreateInstance(acType, true);&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;catch (System.Exception ex)&lt;BR /&gt;{&lt;BR /&gt;CommonOperations.Log("Exception", ex.ToString());&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//2-Opening DWG//&lt;/P&gt;&lt;P&gt;&amp;nbsp;_acadApp.Documents.Open("myDrawingPath", Type.Missing, Type.Missing);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//3-Load My Plug-In DLL//&lt;/P&gt;&lt;P&gt;string appDirectory = AppDomain.CurrentDomain.BaseDirectory; // get the application directory&lt;BR /&gt;string dllLocation = $"{appDirectory}SolutionMetric.Qsurv.AutoCAD_Plugin.dll"; // get the plugin directory&lt;BR /&gt;if (File.Exists(dllLocation))&lt;BR /&gt;{&lt;BR /&gt;dllLocation = dllLocation.Replace(@"\", @"\\"); // so that the lisp can understand the directory&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;_acadApp.ActiveDocument.SendCommand("(command \"NETLOAD\"" + $@"""{dllLocation}"") "); //TODO:Causes error in the user's devices&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//4-Call lisp functions from the plug-in//&lt;/P&gt;&lt;P&gt;&amp;nbsp;_acadApp.ActiveDocument.SendCommand($@"(LoadItems {taskID} {fileID}) ");&lt;/P&gt;</description>
      <pubDate>Sat, 19 Aug 2017 23:03:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-plug-in-dll-without-editing-config-file/m-p/7313507#M30018</guid>
      <dc:creator>ahmedshawkey95</dc:creator>
      <dc:date>2017-08-19T23:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Load Plug-in DLL Without Editing Config File</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-plug-in-dll-without-editing-config-file/m-p/7315927#M30019</link>
      <description>&lt;P&gt;&amp;lt;runtime&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;lt;loadFromRemoteSources enabled="true" /&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;/runtime&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;was introduced into .NET framework 4.0 when the code security execution in "sand box" mode, as an "security compromised" backward compatibility.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With AutoCAD .NET add-in, originally, when the DLL is placed in a network location, one can use his as quick/dirty solution. Since later AutoCAD versions added tigher code execution security, a DLL would not be considered safe not only when it locates outside of local drive, but also when it locates in local drive as long as it is not in a folder specified by "TrustedDomains" and "TrustedPaths".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You really need to understand the latest security settings for AutoCAD, instead of trying to use &amp;lt;loadFromRemote.../&amp;gt; in acad.exe.config, or trying to programmingly bypass security (which is equivalent to write virus/malicious code:-(). That is, you can either load your Add-in with AutoCAD's auto plug-in loading mechanism, or setup "TrustedDomains/Paths", so that the code is considered by AutoCAD as safe code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2017 13:16:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-plug-in-dll-without-editing-config-file/m-p/7315927#M30019</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2017-08-21T13:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Load Plug-in DLL Without Editing Config File</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-plug-in-dll-without-editing-config-file/m-p/7316294#M30020</link>
      <description>&lt;P&gt;I had the same issue even after I fooled with the&lt;/P&gt;&lt;P&gt;"&lt;SPAN&gt;&amp;lt;loadFromRemoteSources enabled="true" /&amp;gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The one work around I found was to have the other machine, right click the dll, and go to its properties. In the security area, check the box to unblock the dll, then apply and ok.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This worked for me and my office.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2017 15:06:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-plug-in-dll-without-editing-config-file/m-p/7316294#M30020</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-21T15:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Load Plug-in DLL Without Editing Config File</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-plug-in-dll-without-editing-config-file/m-p/7316358#M30021</link>
      <description>&lt;P&gt;This issue is/may not be the same as the OP has.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue you had is because the DLLs you installed on other computer somehow being transferred via the Internet (say, you email the Dlls files, even you zipped it up) to the user, or your company has complicated network that may connected to user with VPN via the Internet), thus Windows OS automatically flag this executable file as "potentially unsafe". You can remove this "unsafe" flag as you described.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regardless whether the OP has this issue or not, he/she should be loading Acad DLLs following AutoCAD security guidance, rather than change acad.exe.config, or try to programmatically write "malicious" code to bypass security.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2017 15:24:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-plug-in-dll-without-editing-config-file/m-p/7316358#M30021</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2017-08-21T15:24:21Z</dc:date>
    </item>
  </channel>
</rss>

