Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

,EXE fails when transferred to new PC

Posted on 2014-01-03
3
Medium Priority
?
312 Views
Last Modified: 2014-01-04
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
0
Comment
Question by:pclarke7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 668 total points
ID: 39754944
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
0
 
LVL 19

Assisted Solution

by:Raheman M. Abdul
Raheman M. Abdul earned 668 total points
ID: 39754956
You can use the stacktrace to trace the error source.

eg: System.Diagnostics.StackTrace t = new System.Diagnostics.StackTrace();
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 664 total points
ID: 39755749
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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question