<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[C# plugins share AppDomain?]]></title><description><![CDATA[<p dir="auto">TLDR: I have 2 independent C# plugins that appear to share the same .Net AppDomain when running in NPP.<br />
Does anyone know the side-effects of this?<br />
Is it something I should investigate further?</p>
<p dir="auto">I wrote a C# plugin and had to jump through some hoops so .Net could find a required 2nd dll…</p>
<p dir="auto">I hooked into <a href="https://docs.microsoft.com/en-us/dotnet/api/system.appdomain.assemblyresolve" rel="nofollow ugc">AppDomain.CurrentDomain.AssemblyResolve</a> event so I could give the exact path via <a href="https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly.loadfrom" rel="nofollow ugc">System.Reflection.Assembly.LoadFrom()</a>.</p>
<p dir="auto">This works well enough, but I just discovered that a new C# plugin I am writing is being trapped by the above event in the <em>first plugin</em>.</p>
<p dir="auto">I can re-work the first plugin and avoid the <a href="https://docs.microsoft.com/en-us/dotnet/api/system.appdomain.assemblyresolve" rel="nofollow ugc">AppDomain.CurrentDomain.AssemblyResolve</a> event, but I am wondering if there is something I could do to prevent my plugin affecting other .Net plugins (and vice-versa).</p>
<p dir="auto">Any thoughts?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/19228/c-plugins-share-appdomain</link><generator>RSS for Node</generator><lastBuildDate>Thu, 18 Jun 2026 17:14:18 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/19228.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 14 Apr 2020 15:23:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C# plugins share AppDomain? on Wed, 15 Apr 2020 18:27:36 GMT]]></title><description><![CDATA[<p dir="auto">Thanks both.</p>
<p dir="auto">I’ve not much idea myself about AppDomains, but I am swatting up. I’m also learning about Managed Extensibility Framework (MEF) and Managed AddIn Framework (MAF) to see if they can help.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/makwana-prahlad" aria-label="Profile: Makwana-Prahlad">@<bdi>Makwana-Prahlad</bdi></a><br />
Thanks for the example - easier for me than theory sometimes!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52645</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52645</guid><dc:creator><![CDATA[moon6969]]></dc:creator><pubDate>Wed, 15 Apr 2020 18:27:36 GMT</pubDate></item><item><title><![CDATA[Reply to C# plugins share AppDomain? on Wed, 15 Apr 2020 08:39:55 GMT]]></title><description><![CDATA[<p dir="auto">Hello,<a class="plugin-mentions-user plugin-mentions-a" href="/user/moon6969" aria-label="Profile: moon6969">@<bdi>moon6969</bdi></a></p>
<p dir="auto">Follow this information,To C# plugins share AppDomain?</p>
<p dir="auto">1.Check if the assembly is already loaded<br />
2.If its not loaded, read the assembly into a byte array. This will prevent locking the file.<br />
3.Supply the byte array as an arguement to Assembly.Load</p>
<pre><code>Assembly assembly = null;

foreach(Assembly loadedAssembly in AppDomain.CurrentDomain.GetAssemblies())
    if (loadedAssembly.FullName == "foobar, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
        assembly = loadedAssembly;

if(assembly == null)
{
    byte[] studybin = System.IO.File.ReadAllBytes(@"C:\pathToAssembly\foobar.dll");
    assembly = Assembly.Load(studybin);                
}
</code></pre>
<p dir="auto"><strong>Note :</strong><br />
If you are trying to find a specific assembly in a directory, you can run <strong>‘System.Reflection.AssemblyName.GetAssemblyName(path);’</strong> to see if the FullName matches what you are looking for. <strong>‘GetAssemblyName(path)’</strong> does NOT inject the assembly into your current AppDomain.</p>
<p dir="auto">I hope this information will be usefull.<br />
Thank you.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52620</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52620</guid><dc:creator><![CDATA[Makwana Prahlad]]></dc:creator><pubDate>Wed, 15 Apr 2020 08:39:55 GMT</pubDate></item><item><title><![CDATA[Reply to C# plugins share AppDomain? on Tue, 14 Apr 2020 22:14:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/moon6969" aria-label="Profile: moon6969">@<bdi>moon6969</bdi></a></p>
<p dir="auto">what about <a href="https://stackoverflow.com/questions/88717/loading-dlls-into-a-separate-appdomain" rel="nofollow ugc">this</a>, sounds like you can isolate the domains. Note, I have no idea what I’m talking about.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52605</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52605</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Tue, 14 Apr 2020 22:14:13 GMT</pubDate></item></channel></rss>