Solved

,EXE fails when transferred to new PC

Posted on 2014-01-03
3
304 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 74

Accepted Solution

by:
käµfm³d   👽 earned 167 total points
Comment Utility
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 18

Assisted Solution

by:Raheman M. Abdul
Raheman M. Abdul earned 167 total points
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Contained Database Collations 6 18
Calling stored proc in EDMX 11 17
IN with @variable 5 15
Unable  to create new object 9 19
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now