C# error breaks program when coming from JS button, yet C# button functions fine. What am I doing wrong?
<p>First let me explain what my program does.  I have a web browser inside of a form.  I have a class dedicated to cross communication between the webpage and the program.  In order for my class to communicate with the other class where most of the code is, I have to do the following (which I suspect is the problem):  </p>

<pre><code>public class TEST
        {
            public void goHere()
            {  
                Form1 frm1 = new Form1();
                frm1.another();
            }
        }

public partial class Form1 : Form
        {
            public void another()
            {
                //do stuff
            }
        }
</code></pre>

<p>The TEST class is only called from the via Javascript.<br>
I get the error:  </p>

<pre><code>An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

Additional information: Exception has been thrown by the target of an invocation.
</code></pre>

<p>This happens at:  </p>

<pre><code>    static void Main()
            {
                Application.Run(new Form1());
            }
</code></pre>

<p>In order to get to that line the program executes this line:  </p>

<pre><code>        webKitBrowser1.Invoke(new MethodInvoker(delegate
        {
            webKitBrowser1.GetScriptManager.CallFunction("doStuff", new Object[] { });
        }));
</code></pre>

<p>In order to see if my communication between classes was an issue, I simply called another(); from a C# button.  I did not encounter the error.  This leads me to believe that the Form1 frm1 = new Form1(); line is causing an error.  Any ideas on how to fix this?  Is my diagnosis correct?  </p>
