Keep getting "Object reference not set to an instance of an object." - asp.net

On our development environment system works fine but on Live system sometimes buttonClick action generates below error. If i press back 1-2 times it works without generating error.
On the live system error, it still shows my local path. Can this be the issue?
Thanks for your help
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:
System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
WebApplication4.orderConfirmation.SubmitButton_Click(Object sender, EventArgs e) in C:\Documents and Settings\Desktop\Purchase\WebApplication4\WebApplication4\orderConfirmation.aspx.cs:341
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +153
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3690

To answer one question: when compiling .NET code into DLL, the local path of the source files is being stored in the assembly - not sure if only when compiling in Debug or also in Release.
Anyway, add the generated .PDB file to the same folder containing the DLL file on the server and you'll also get line number (instead of cryptic +3690): having this you can identify the exact line causing this error.. post this information here and we'll be able to help.

It seems you might have the page life cycle wrong and you might be setting a variable at a certain point and expecting that variable not to be null when you are accessing it.

Related

Could not load file or assembly 'SharpSvn'

I am using SharpSvn.dll and SharpSvnUI.dll in my project . I am getting error like this
Server Error in '/WebUI' Application.
Could not load file or assembly 'SharpSvn' or one of its dependencies.
An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load
file or assembly 'SharpSvn' or one of its dependencies. An attempt was
made to load a program with an incorrect format.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to
determine why the assembly 'SharpSvn' could not be loaded.
WRN: Assembly binding logging is turned OFF. To enable assembly bind
failure logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There
is some performance penalty associated with assembly bind failure
logging. To turn this feature off, remove the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog].
Using :
VS 2015 -64bit
ref :
https://sharpsvn.open.collab.net/
You will get this error if you try to host a web application using a 32 bit dll on a 64 bit server.Quick fix is to set "Enable 32 bit applications" flag to true in AppPool Advance Settings for the site.Select the Application Pool used for the application and the set that flag to true.Restart IIS.

adding reference and get error : System.BadImageFormatException

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file
or assembly 'Microsoft.Build.Framework' or one of its dependencies.
This assembly is built by a runtime newer than the currently loaded
runtime and cannot be loaded.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to
determine why the assembly 'Microsoft.Build.Framework' could not be
loaded.
WRN: Assembly binding logging is turned OFF. To enable assembly bind
failure logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There
is some performance penalty associated with assembly bind failure
logging. To turn this feature off, remove the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog].
Check to make sure all bindings are the same 32 or 64 build

The EventLogWebEventProvider provider failed to log an event with the error code 0x80070057

I am writing WebEvent in my asp.net Application and it is working fine in both my development and production region.However, When I analyze Event Logs in production server for past couple of months.I see below event
The following exception was thrown by the web event provider 'EventLogProvider' in the application '/(MyApplicationName)' (in an application lifetime a maximum of one exception will be logged per provider instance):
System.Web.HttpException (0x80004005): The EventLogWebEventProvider provider failed to log an event with the error code 0x80070057.
at System.Web.Management.EventLogWebEventProvider.ProcessEvent(WebBaseEvent eventRaised)
at System.Web.Management.WebBaseEvent.RaiseInternal(WebBaseEvent eventRaised, ArrayList firingRuleInfos, Int32 index0, Int32 index1)
Although Occurrence is very low, still I am curious to understand why this is happening.I tried to do some research and found below link
http://forums.iis.net/t/1201176.aspx?IIS+Keep+hanging
According to this link, I may be passing some invalid argument while writing event log.
But I double checked my EventLog.WriteEntry method and I am using it in my application only in couple of places and moreover, I am passing static string message. If argument is invalid then it should occur every time I try to write event.
Can anyone please help me understanding possible cause for this event.is there any known issue when working with EvenLog?
Check your code you may be trying to perform an invalid operation.
In my case i was writing a file to C Drive after changing Location to D Drive Problem Resolved

ASP.NET related error

If you could help me with my problem, I'd really appreciate it. I'm unable to open my website in another computer, The following error occurs:
Server Error in '/WebSite2' Application.
An attempt to attach an auto-named database for file C:\Users\evisen\Desktop\Amy the conqueror\WebSite2\App_Data\Database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file C:\Users\evisen\Desktop\Amy the conqueror\WebSite2\App_Data\Database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
I hope I've been as specific as I can be. Thank you!
This error generally comes when there is some problem in your connection string. Try to check your connection string.
Also check this related forum. Hope that helps!

Me.ChangeSet.GetOriginal, Object reference not set to an instance of an object

hey , I have a problem with updating a record using a domain service, entity framework and asp.net.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 257: }
Line 258: Me.ObjectContext.OrderStatusHistories.AddObject(_orderStatusHistory)
Line 259: Me.ObjectContext.Orders.AttachAsModified(currentOrder, Me.ChangeSet.GetOriginal(currentOrder))
Line 260: End Sub
Line 261:
The order is commited in the database, does anyone know whats going on here?
Turns out the changeset was null. So in my code added an if changeset is not null, i dont need to run the code if there isnt a changeset.

Resources