Could be several reasons. One of the more common ones is that you're compiling it for a .NET framework that the target machine does not have. Another could be that you're compiling for 64-bit, while target machines are 32-bit.
Some of the steps to fix this:
If you're using Visual Studio, right click on your project and go to Properties
.
In Application
tab check to see which Target framework
is being listed. It could be .NET Framework 4.5.1.
Change it to .NET Framework 4 Client Profile and see if it runs on your target machines.
Also, under Build
check to see which Platform target
options you have selected and adjust accordingly. It might be helpful to select x86 rather than Any CPU.
Other thoughts/tips:
From the screenshot, it appears that you're running it on Windows 7 machines, so I doubt that .NET framework is the issue; in that case, ensure that target machines contain all the appropriate libraries that you're using. If you have some non-native libraries, make sure that you set Copy Local
to true
for them.
By the way... when you say you copy it, I'm assuming you're copying all the appropriate files along with the executable, right? There might be some files, such as libraries, app configuration files, etc., that you need to copy along with it.
David Khaykin mentioned the fact that you might have an unhandled exception there. Therefore, as suggested in this SO thread, you may want to implement an event handler for the AppDomain.CurrentDomain.UnhandldedException
event and check the value of the e.ExceptionObject.ToString()
.
Here's MSDN link to help you with that (scroll to the bottom to see an example): http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.110).aspx
Some ways to analyze crashes:
Here's a neat article that describes how to analyze your crashes:
http://blogs.msdn.com/b/anandbms/archive/2005/04/20/410225.aspx
It uses AdPlus, which you can read more about and obtain at http://support.microsoft.com/kb/286350
Here's a more direct link to WinDbg debugging tool: http://msdn.microsoft.com/en-us/windows/hardware/hh852365 (scroll down halfway and make sure you get the Windows 7 version if that's your OS).
Those are just some of the things that I've done over the course of my C# adventuring, so hopefully one of them can help you.