,EXE fails when transferred to new PC

Hello,
I have developed a C# application running on Windows 7 (32 bit) called RBS07.exe which accesses a remote SQL database. It is now ready for testing and so I need to install the .exe on a Windows 7 (64 bit) machine. After compiling on the development box I copied the RBS07.exe to the test PC and set up the appropriate ODBC connections. However when I run this RBS07.exe on the test PC , it displays the 1st window and subsequently crashes (I suspect when attempting to connect to the remote SQL server. The error message is "Unhandled error has occurred in your application - Object reference not set to an instance of an Object"    

The Test PC does not have MS Visual 2010 installed. Is there any way that I can get more information on what is causing the error ?

regards
Pat
LVL 1
pclarke7Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kaufmed   ( ⚆ _ ⚆ )Commented:
Add the following event handler to your application, and then redeploy:

// Add at the beginning of your application
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);

// Add this into your program so the above can call it
static void MyHandler(object sender, UnhandledExceptionEventArgs args) 
{
    System.Windows.Forms.MessageBox(args.ExceptionObject.ToString());
}

Open in new window


You should get the full error message and stack trace. This can help you hone in on where in your code the error is occurring.

http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.110).aspx

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
You can use the stacktrace to trace the error source.

eg: System.Diagnostics.StackTrace t = new System.Diagnostics.StackTrace();
Jacques Bourgeois (James Burger)PresidentCommented:
A few features of the compiler can make a difference in the way things work. The option to enable and disable optimization for instance can lead to problems such as yours (It's under the Advanced Compile Options, in the Compile tab of the project's Properties window.

If you test on your development computer with optimization disabled, which is the default for the Debug configuration, which is the default in the Release configuration, the debugging and release versions do not generate exactly the same code. Although optimization usually increases the performance of the application, it can sometime remove code that makes it crash.

To see if this is the case, deploy a Debug version of the application on the test computer. If the program crashes with the Release version but not with the Debug version, than you are  almost sure that optimization is the cause of the crash.

In such a case, temporarily enabling optimization during debugging on your development station might help you pinpoint the problem and code differently until you find a way to do it that does not trigger the optimizer. It might however leads to some problems in the debugger that will prevent you from being able to use it properly.

The alternative, if you find out that this is the problem, is to remove optimization from the release version. Sometimes, the difference between an optimized and as non-optimized version is so negligible that you can live with it.

If you do not think that optimization could be the problem, you could temporarily install Visual Studio 2010 Express on the test computer and run in there with the source code. You would not have all your development tools, but you would have the whole debugger available to perform your tests.

If it works under inside of Visual Studio, but not when you run the .exe directly, then you would need to look a little further and use the debugger directly on the .exe. Lookup "Jit debugging" in the documentation or MSDN. It will tell you how to configure the application so that the debugger is triggered even when the application is run by launching the .exe outside of Visual Studio. Visual Studio (Express is OK) need to be installed on the test machine for that to work, but it enables you to get the problem exactly as the user would.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.