views:

260

answers:

2

I wrote a Windows Form Application in C# and it works well for my computer. But on another PC, an error occurs when I try to do some stuff.

MenuItem_Click Event Handler

private void rUNToolStripMenuItem_Click(object sender, EventArgs e)
{
    MessageBox.Show("I'm in rUNToolStripMenuItem_Click!");
    ...

}

ToolStripMenuItem Event Handler

private void dataPositionToolStripMenuItem_Click(object sender, EventArgs e)
{
    MessageBox.Show("I'm in dataPositionToolStripMenuItem_Click!");
    ...    
}

Running on my computer:

MenuItem_ClickEvent Handler Output (On My PC)

MessageBox appears: "I'm in rUNToolStripMenuItem_Click"

ToolStripMenuItem Event Handler (On My PC)

MessageBox appears: "I'm in dataPositionToolStripMenuItem_Click!"

MenuItem_Click Event Handler: (On another PC)

Messagebox doesn't appear and an Exception is thrown
Method not found: "Void    
Microsoft.CSharp.RuntimeBinder.CSharpGetMemberBinder.ctor(
System.String.System.Type, System.Collections.Generic.IEnumerable'1<Microsoft 
.CSharp.RuntimeBinder.CSharpArgument Info>)'.

This is the PrintScreen with error:
Screen Capture

What am I doing wrong?

+4  A: 

does the other computer have the correct version of the .net runtime installed on it for which you built that application too?

ANC_Michael
Yes, my computer has .NET Framework 4.0.20506 and the computer where i deployed it has .NET Framework 4.0.30319 . The programme runs on both computers, but on the "destination" computer it doesn't work when i try to do some stuff. I mention that i made a setup for my application.Thanks
That isn't the same version of hte .NET runtime. Build your app for .NET 4 RTM, deploy to a machine with .NET 4 RTM, and you should be fine.
Judah Himango
Thanks a lot, ANC_Michael!
I solved the problem! I installed on my computer Visual Studio 2010 Professional (Full Version) and now, my project is set for .NET Framework 4.0.30319. Now the program works fine on both computers. Thanks a lot!
A: 

When developing applications in .NET you need to ensure the host environment has the same version of the .NET framework that your application is targeting.

If you right click on your application from the solution explorer, go to properties then select the Application tab you can specify (or confirm) what framework your application is using, this will be the version you will have to install.

If you have a setup project you can make the .NET framework a pre-requisite (basically makes the user install that before they can install the application) so you don't have issues like this...

James
Thanks a lot, James!