Solved

,EXE fails when transferred to new PC

Posted on 2014-01-03
3
307 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
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 167 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 167 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 166 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 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