Question

I am programming a smartcard system using C#. In my unpublished program, it don't show any errors and running smoothly.

But when I converted it into an installer and run it's exe file it shows an error object reference not set to an instance of an object. Any idea why does this happened in an exe file?

Était-ce utile?

La solution

To help you locate the problem you can idetify where in the code this is happening by catching all unhandled exceptions and logging them in a manor that is fit for your application.

Now each application type has different methods for catching unhandled exceptions. Here are some basic pointers for different types.

WinForms: http://msdn.microsoft.com/en-us/library/system.windows.forms.application.threadexception.aspx

WPF : http://msdn.microsoft.com/en-us/library/system.windows.application.dispatcherunhandledexception.aspx

WebForms \ MVC : http://msdn.microsoft.com/en-us/library/24395wz3(v=vs.100).aspx

Now how you log is your own responsibility you can use some off the shelf \ OS features if you wish.

log4net: http://logging.apache.org/log4net/

EventLogs: http://support.microsoft.com/kb/307024

Back to original problem. The reason you are getting the error is you are accessing \ manipulating an object that is not set. Now which object and why is quite difficult to trace and impossible for us to resolve without some indication as to where this error is ocurring. At a minimum we would need to know where in the code this is happening.

Ideally a full stack trace will resolve this quite quickly.

Cheers.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top