|
Hi,
I got Application that working with DB. (The MDF file of the DB is in the Solution). I added to the Solution a new Setup Project. Added to Project Output -> primary Output. the pressed build project.
I got at the and of it in DEBUG folder -> setup.exe file After installing it, I run the app. and I got this error:
Unhandled exception has occurred in your application. if you click Continue. the application will ignore this error and attempt to continue. if you click Quit. the application will close immediatly.
Object reference not set to an instance of an object
What to do? What is wrong here?
How to fix it?
Thanks..
|
| gb_007 Tuesday, July 21, 2009 5:49 PM |
The kind of thing that everyone should do todebug their code is to have aTraceListener that writes trace information (Trace.WriteLine) so that the program flow, data values etc can be written toa text file.
Another thing to do to catch exceptions and check error results. When an object reference is not set to an instance of an object it means that an object you thought was created in fact was not. So you've got code that is one statement after the other, with no try/catch around critical areas like connecting to the database? The "what to do" is to figure out how to write your app so that it is maintainable and you can report errors. Does it work if SQL isn't running? If somebody removed the database? If the connection fails for security reasons? Phil Wilson- Marked As Answer byKira QianMSFT, ModeratorTuesday, July 28, 2009 7:44 AM
-
|
| PhilWilson Thursday, July 23, 2009 12:14 AM |
I'm not sure why you're asking here in a setup forum - the app fails when you run it, so really you need some debugging and more error checking in your app. You've used an object that you assumed has been initialized, but it hasn't. It might be related to something that you should have installed, but to find out what you'll need to find where it's failing and why. Phil Wilson |
| PhilWilson Tuesday, July 21, 2009 10:43 PM |
But when I'm running the apps from Visual without debugging it's running all good.
what to do? |
| gb_007 Wednesday, July 22, 2009 7:50 AM |
The kind of thing that everyone should do todebug their code is to have aTraceListener that writes trace information (Trace.WriteLine) so that the program flow, data values etc can be written toa text file.
Another thing to do to catch exceptions and check error results. When an object reference is not set to an instance of an object it means that an object you thought was created in fact was not. So you've got code that is one statement after the other, with no try/catch around critical areas like connecting to the database? The "what to do" is to figure out how to write your app so that it is maintainable and you can report errors. Does it work if SQL isn't running? If somebody removed the database? If the connection fails for security reasons? Phil Wilson- Marked As Answer byKira QianMSFT, ModeratorTuesday, July 28, 2009 7:44 AM
-
|
| PhilWilson Thursday, July 23, 2009 12:14 AM |
|
| RobinDotNet Friday, July 24, 2009 6:49 AM |
What DB are u using, SQL Server? And have u committed any other steps while creating the setup package or just what u hv mentioned above? |
| PranabJyoti Friday, July 24, 2009 4:02 PM |