DLL doesn't store string C#
<p>I have an application that can be launched from the explorer context menu for a Windows drive. When you click the menu item the drive letter is passed to the new instance. I want to make sure that any old instance is closed.</p>

<p>I also want to make sure that the last drive that was selected is persisted, so that when I start the application again from the start-menu, it will remember the drive I originally selected.</p>

<p>It would be best if the already running application would receive an event so that it can update without having to kill and restart.</p>

<hr>

<p>I tried the following, but that doesn't seem to be working:</p>

<p>This is my Class library method(it is just a line that define a variable so just i have a DLL that there a variable in it and no more)    </p>

<pre><code> namespace Dispatch
 {
     public class cls_get_drive_letter
     {
         public static string drive_letter;
     }
 }
</code></pre>

<p>This is my loading form code: (Here i will fill the DLL's variable)</p>

<pre><code> private void Frm_loading_Load(object sender, EventArgs e)
 {
     Dispatch.cls_get_drive_letter.drive_letter = "XXX";
     Process currentProcess = Process.GetCurrentProcess();
     if (Process.GetProcessesByName(currentProcess.ProcessName, currentProcess.MachineName).Length &gt;1)
     {
        currentProcess.Kill();
     }
 }  
</code></pre>

<p>So when i run this for first time the "XXX" will be stored in DLL but when the current instance of application is running and i am going to run next instance of it the application will be closed because of this code:</p>

<pre><code> Process currentProcess = Process.GetCurrentProcess();
 if (Process.GetProcessesByName(currentProcess.ProcessName, currentProcess.MachineName).Length &gt;1)
 {
     currentProcess.Kill();
 }
</code></pre>

<p>So when closing code occurs with this code the new "XXX" will not stored in DLL and the last string will be in dll.</p>
