<?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[My plugin crashes because of a C# NuGet]]></title><description><![CDATA[<p dir="auto">Hi, im trying to write a plugin with c#. The plugin connects to a server and gets json data and deserialize the data .It works succesfully on c# . before i tried to convert it to a npp plugin .</p>
<p dir="auto">I noticed the reason of plugins crash , notepad++ cannot use or read a c# nuget named newtonsoft.json and crashes. But if i dont use that NuGet i cant use deserialization .Whole program written with that NuGet and my boss dont want to change it. So what should i do ? Is there any solution to get this plugin worked with newtonsoft.json NuGet?</p>
<p dir="auto"><img src="/assets/uploads/files/1631687793995-plugincrash.png" alt="pluginCrash.PNG" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/topic/21826/my-plugin-crashes-because-of-a-c-nuget</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 12:38:23 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/21826.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 15 Sep 2021 06:38:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to My plugin crashes because of a C# NuGet on Fri, 17 Sep 2021 13:27:44 GMT]]></title><description><![CDATA[<p dir="auto">From the Home page of <a href="https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net" rel="nofollow ugc">NotepadPlusPlusPluginPack.Net</a></p>
<pre><code class="language-text">References
The prefered way to use dependencies is via References, in the best-case through NuGet.

Via NuGet you are able to add packages to your project, certain versions etc. through a global repository. Package information is stored in your project and other developers can gather the same, correct versions through the global repository without committing masses of data.

To use included references in your compiled plugin you need to merge these into the .dll as Notepad++ is not fond of locating non-plugin .dll's in its folder. ILMerge was developed for the purpose of merging managed libraries. It can be installed via NuGet and used manually.

The best way is to install MSBuild.ILMerge.Task via NuGet in your plugin project. It will include ILMerge as dependency and attach itself to your Visual Studio build process. By that, with every build you compile a merged plugin .dll including all your custom references to use. ILMerge will add configuration files to your project: ILMerge.props and ILMergeOrder.txt. Refer to the official homepage for more information about the configuration possibilities.

Note: To use ILMerge in your plugin you have to change the Target Framework of your plugin project to at least .NET Framework 4.0 (CP). ILMerge can work with .NET 3.5 and below, but requires additional configuration and adaptation. If you do not required the extreme backwards compatibility, upgrade the .NET Framework target as quick and easy solution.
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/69784</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69784</guid><dc:creator><![CDATA[Nick Brown]]></dc:creator><pubDate>Fri, 17 Sep 2021 13:27:44 GMT</pubDate></item><item><title><![CDATA[Reply to My plugin crashes because of a C# NuGet on Fri, 17 Sep 2021 11:34:04 GMT]]></title><description><![CDATA[<p dir="auto">It worked ! Thanks  a lot</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69780</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69780</guid><dc:creator><![CDATA[Yunus Emre Kütükçü]]></dc:creator><pubDate>Fri, 17 Sep 2021 11:34:04 GMT</pubDate></item><item><title><![CDATA[Reply to My plugin crashes because of a C# NuGet on Fri, 17 Sep 2021 10:20:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yunus-emre-k%C3%BCt%C3%BCk%C3%A7%C3%BC" aria-label="Profile: Yunus-Emre-Kütükçü">@<bdi>Yunus-Emre-Kütükçü</bdi></a></p>
<p dir="auto">I downloaded the latest <a href="https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net/releases" rel="nofollow ugc">pre-release</a> and installed the template accordingly.</p>
<p dir="auto">Opened a new Notepad++ project in VS2019 and added a button to the frmMyDlg.cs.</p>
<p dir="auto">Added/modified the following code</p>
<pre><code class="language-c#">    public partial class frmMyDlg : Form
    {
        static IScintillaGateway editor = new ScintillaGateway(PluginBase.GetCurrentScintilla());
        public frmMyDlg()
        {
            InitializeComponent();
        }

        private void frmMyDlg_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string text = System.IO.File.ReadAllText(@"shortcuts.xml");
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(text);

            string json = JsonConvert.SerializeXmlNode(doc);
            editor.SetText(json);
        }
    }
</code></pre>
<p dir="auto">After building and running it crashed when I pressed the button.<br />
I investigated what was happening with loading the necessary dlls with <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/procmon" rel="nofollow ugc">procmon</a> and found that it was<br />
NOT looking in the plugins directory to find the<br />
Newtonsoft.Json.dll, but instead was looking in the root directory.<br />
I copied Newtonsoft.Json(.dll/.xml) into the directory and ran it again and it worked</p>
<p dir="auto"><img src="/assets/uploads/files/1631873733731-18c4c935-afd9-43e3-bec8-12940ae4eeaf-image.png" alt="18c4c935-afd9-43e3-bec8-12940ae4eeaf-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I don’t know what needs to be done to load the Newtonsoft.Json.dll from another directory, but I’d be surprised if it couldn’t be done.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69779</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69779</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 17 Sep 2021 10:20:21 GMT</pubDate></item><item><title><![CDATA[Reply to My plugin crashes because of a C# NuGet on Fri, 17 Sep 2021 06:55:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yunus-emre-k%C3%BCt%C3%BCk%C3%A7%C3%BC" aria-label="Profile: Yunus-Emre-Kütükçü">@<bdi>Yunus-Emre-Kütükçü</bdi></a>  <strong>main class</strong>* not function</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69776</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69776</guid><dc:creator><![CDATA[Yunus Emre Kütükçü]]></dc:creator><pubDate>Fri, 17 Sep 2021 06:55:32 GMT</pubDate></item><item><title><![CDATA[Reply to My plugin crashes because of a C# NuGet on Fri, 17 Sep 2021 06:37:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> I wish it was open source . Program gets data from admin panel and gives permission to change all data. Because of that I cant share the whole code</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69773</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69773</guid><dc:creator><![CDATA[Yunus Emre Kütükçü]]></dc:creator><pubDate>Fri, 17 Sep 2021 06:37:25 GMT</pubDate></item><item><title><![CDATA[Reply to My plugin crashes because of a C# NuGet on Fri, 17 Sep 2021 06:26:05 GMT]]></title><description><![CDATA[<p dir="auto">I copied package to plugin directory but still having same error. I think <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> is right. Problem seems to be elsewhere.  Also I noticed when I debugging , program gets in the <strong>read</strong> function until the if(response.StatusCode ==… line and it goes to my main function ,creates my form then it enters  the <strong>read</strong> function again, if i commented <strong>projects = JsonConvert.DeserializeObject&lt;List&lt;Project&gt;&gt;(responseBody);</strong> and <strong>script = JsonConvert… .</strong> sections . I couldnt figure out why is that happening</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69772</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69772</guid><dc:creator><![CDATA[Yunus Emre Kütükçü]]></dc:creator><pubDate>Fri, 17 Sep 2021 06:26:05 GMT</pubDate></item><item><title><![CDATA[Reply to My plugin crashes because of a C# NuGet on Thu, 16 Sep 2021 09:13:36 GMT]]></title><description><![CDATA[<p dir="auto">I am a C# developer and I am also familiar with the use of nuget packages and the newtonsoft json package in particular, and what you need to check is that you are copying the relevant newtonsoft json .dll file from the package to the plugin directory under notepad++ that you are putting your plugin dll file. Without those  newtonsoft json .dll file locally it is probably unable to find it.</p>
<p dir="auto">The file you need to copy will be Newtonsoft.Json.dll, and should be in the bin folder of wherever your c# project is building to.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69749</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69749</guid><dc:creator><![CDATA[Nick Brown]]></dc:creator><pubDate>Thu, 16 Sep 2021 09:13:36 GMT</pubDate></item><item><title><![CDATA[Reply to My plugin crashes because of a C# NuGet on Thu, 16 Sep 2021 09:00:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yunus-emre-k%C3%BCt%C3%BCk%C3%A7%C3%BC" aria-label="Profile: Yunus-Emre-Kütükçü">@<bdi>Yunus-Emre-Kütükçü</bdi></a><br />
First of all, I would like to clarify that I am not a C# developer.<br />
I recently started taking my first C# steps, but I don’t have a<br />
basic understanding of this programming language.</p>
<p dir="auto">If it crashes, even if your code doesn’t call the read method,<br />
doesn’t that mean the problem is somewhere else?<br />
Have you tried building the C# example plugin that comes with<br />
it? Is this crashing as well? If so, you might think about <a href="https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net/issues" rel="nofollow ugc">reporting a bug</a>.<br />
Is your plugin project open source so one can try to figure out what’s going on?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69746</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69746</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Thu, 16 Sep 2021 09:00:35 GMT</pubDate></item><item><title><![CDATA[Reply to My plugin crashes because of a C# NuGet on Thu, 16 Sep 2021 07:19:21 GMT]]></title><description><![CDATA[<p dir="auto">Also if i uncomment the sections i mentioned program didnt even get in the <strong>read</strong> method, just crashes</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69745</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69745</guid><dc:creator><![CDATA[Yunus Emre Kütükçü]]></dc:creator><pubDate>Thu, 16 Sep 2021 07:19:21 GMT</pubDate></item><item><title><![CDATA[Reply to My plugin crashes because of a C# NuGet on Thu, 16 Sep 2021 06:54:15 GMT]]></title><description><![CDATA[<p dir="auto">using Newtonsoft.Json;<br />
using Newtonsoft.Json.Linq;<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Drawing;<br />
using System.Net.Http;<br />
using System.Text;<br />
using System.Windows.Forms;</p>
<p dir="auto">namespace Kbg.NppPluginNET<br />
{<br />
public partial class getScript : Form<br />
{<br />
Microsoft.Win32.RegistryKey key;<br />
List&lt;Project&gt; projects;<br />
List&lt;Scripts&gt; scripts;</p>
<pre><code>    string URL;
    string TOKEN;

    public class Project : IEquatable&lt;Project&gt;
    {
   [JsonProperty]
        public string name { get; set; }
       [JsonProperty]
        public string dsc { get; set; }
       [JsonProperty]
        public int id { get; set; }

        public bool Equals(Project other)
        {
            if (other == null) return false;
            return (this.id.Equals(other.id));
        }

        public override bool Equals(object obj)
        {
            if (obj == null) return false;
            Project objAsPart = obj as Project;
            if (objAsPart == null) return false;
            else return Equals(objAsPart);
        }

        public override string ToString()
        {
            return "ID: " + id + "Name: " + name;
        }
        public override int GetHashCode()
        {
            return id;
        }
    }

    public class Scripts
    {
        public string name { get; set; }
        public string dsc { get; set; }
        public string id { get; set; }

    }
    public getScript()
    {
        InitializeComponent();
        key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("insAddin");
        if (key != null)
        {
            URL = key.GetValue("BaseUrl").ToString();
            TOKEN = key.GetValue("Token").ToString();
            HttpClient client = new HttpClient();

            Uri result = null;
            Uri.TryCreate(URL, UriKind.Absolute, out result);
            if (result != null)
            {
                if (result.IsAbsoluteUri)
                {
                    read(URL, TOKEN, "/projects");
                }
            }
        }
    }

    public async void read(string URL, string TOKEN, string relativeAddress, string prms = "")
    {
        HttpClient client = new HttpClient();
        client.DefaultRequestHeaders.Add("X-Auth-Token", TOKEN);
        client.DefaultRequestHeaders.Add("Accept", "application/json");
        HttpResponseMessage response = await client.GetAsync(URL + relativeAddress + prms);
       if (response.StatusCode == System.Net.HttpStatusCode.OK)
        {
            string responseBody;
            switch (relativeAddress)
            {
                case "/projects":
                    responseBody = await response.Content.ReadAsStringAsync();
                    projects = JsonConvert.DeserializeObject&lt;List&lt;Project&gt;&gt;(responseBody);
          
                    for (int i = 0; i &lt; projects.Count; i++)
                    {
                        comboBoxProjects.Items.Add(projects[i].name);
                    }
                    break;

                 case "/scripts":
                    responseBody = await response.Content.ReadAsStringAsync();
                  scripts = JsonConvert.DeserializeObject&lt;List&lt;Scripts&gt;&gt;(responseBody);
                    for (int i = 0; i &lt; scripts.Count; i++)
                    {
                        comboBoxScripts.Items.Add(scripts[i].name);
                    }
                    break;

                default:
                    break;
            }
        }
        else
        {
            MessageBox.Show(new Form { TopMost = true }, "Response Error" + response.ToString());
        }
    }
</code></pre>
<p dir="auto">if i comment JsonConvert section in read function, plugin runs without the data i wanted .Just throwing nullreferanceexpeption but it doesnt matter</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69744</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69744</guid><dc:creator><![CDATA[Yunus Emre Kütükçü]]></dc:creator><pubDate>Thu, 16 Sep 2021 06:54:15 GMT</pubDate></item><item><title><![CDATA[Reply to My plugin crashes because of a C# NuGet on Wed, 15 Sep 2021 10:32:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yunus-emre-k%C3%BCt%C3%BCk%C3%A7%C3%BC" aria-label="Profile: Yunus-Emre-Kütükçü">@<bdi>Yunus-Emre-Kütükçü</bdi></a></p>
<p dir="auto">I doubt that npp crashes just because you use some C# library<br />
in your C# created plugin. I assume that it is caused by a<br />
incorrect handling of pointers, but you didn’t give enough<br />
information to identify the source of the problem.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69705</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69705</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Wed, 15 Sep 2021 10:32:00 GMT</pubDate></item></channel></rss>