<?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 Load dependent assemblies from another location. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/load-dependent-assemblies-from-another-location/m-p/10035272#M17523</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have managed dll with a bunch of dependencies.&lt;/P&gt;&lt;P&gt;If my dll and all dependencies are in the same folder everything works fine.&lt;/P&gt;&lt;P&gt;But after cleaning up and moving those to another place, my dll just refuses to load.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way so I can keep my&amp;nbsp; dll and the dependencies separated?&lt;/P&gt;&lt;P&gt;Autocad suppport paths does not work.&lt;/P&gt;&lt;P&gt;Preloading them using Assemly.LoadFile does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Mats&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jan 2021 13:52:48 GMT</pubDate>
    <dc:creator>Mats_Sarapik</dc:creator>
    <dc:date>2021-01-27T13:52:48Z</dc:date>
    <item>
      <title>Load dependent assemblies from another location.</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-dependent-assemblies-from-another-location/m-p/10035272#M17523</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have managed dll with a bunch of dependencies.&lt;/P&gt;&lt;P&gt;If my dll and all dependencies are in the same folder everything works fine.&lt;/P&gt;&lt;P&gt;But after cleaning up and moving those to another place, my dll just refuses to load.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way so I can keep my&amp;nbsp; dll and the dependencies separated?&lt;/P&gt;&lt;P&gt;Autocad suppport paths does not work.&lt;/P&gt;&lt;P&gt;Preloading them using Assemly.LoadFile does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Mats&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 13:52:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-dependent-assemblies-from-another-location/m-p/10035272#M17523</guid>
      <dc:creator>Mats_Sarapik</dc:creator>
      <dc:date>2021-01-27T13:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Load dependent assemblies from another location.</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-dependent-assemblies-from-another-location/m-p/10035946#M17524</link>
      <description>&lt;P&gt;.NET framework provides ways for its runtime to locate assemblies (assmbly binding, probing...). These articles would give you some useful information:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/dotnet/framework/deployment/how-the-runtime-locates-assemblies" target="_self"&gt;https://docs.microsoft.com/en-us/dotnet/framework/deployment/how-the-runtime-locates-assemblies&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://weblog.west-wind.com/posts/2016/dec/12/loading-net-assemblies-out-of-seperate-folders" target="_self"&gt;https://weblog.west-wind.com/posts/2016/dec/12/loading-net-assemblies-out-of-seperate-folders&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unless your said dependent assemblies are signed and is placed in GAC (Global Assembly Chache), it is very likely you need to make some configuration in the app.exe.config file. In the case of AutoCAD plugin, it is acad.exe.config. I am not sure it would be less troublesome than simply place the depedent assemblies in the same folder as your plugin DLL(s). That is, while it is doable, it only cause more trouble than good, unless you have very convincing reasons to take pains to seperate your plugin DLL from the said dependent assemblies.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 16:58:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-dependent-assemblies-from-another-location/m-p/10035946#M17524</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2021-01-27T16:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Load dependent assemblies from another location.</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-dependent-assemblies-from-another-location/m-p/10038790#M17525</link>
      <description>&lt;P&gt;When you add the desired assemblies as Embedded Resource, you can use the followings static method to load them on runtime:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;static YourClassName()
{
		AppDomain.CurrentDomain.AssemblyResolve += (sender, bargs) =&amp;gt;
		{
				String dllName = new AssemblyName(bargs.Name).Name + ".dll";
				var assem = System.Reflection.Assembly.GetExecutingAssembly();
				String resourceName = assem.GetManifestResourceNames().FirstOrDefault(rn =&amp;gt; rn.EndsWith(dllName));
				if (resourceName == null) return null; // Not found, maybe another handler will find it
				using (var stream = assem.GetManifestResourceStream(resourceName))
				{
						Byte[] assemblyData = new Byte[stream.Length];
						stream.Read(assemblyData, 0, assemblyData.Length);
						return System.Reflection.Assembly.Load(assemblyData);
				}
		};
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 28 Jan 2021 14:28:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-dependent-assemblies-from-another-location/m-p/10038790#M17525</guid>
      <dc:creator>gleeuwdrent</dc:creator>
      <dc:date>2021-01-28T14:28:09Z</dc:date>
    </item>
  </channel>
</rss>

