The EventLogWebEventProvider provider failed to log an event with the error code 0x80070057 - asp.net

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

Related

SignalR 2 fails on Azure

I deployed an ASP.NET 5 MVC 6 app on Azure, and ran into this problem with SignalR 2:
when starting connection from client, call to
/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B"name"%3A"gameHub"%7D%5D&_=1460028930688
fails with error 500.
The exception behind error 500 is this:
Exception Details:
System.Security.Cryptography.CryptographicException: The data
protection operation was unsuccessful. This may have been caused by
not having the user profile loaded for the current thread's user
context, which may be the case when the thread is impersonating.
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:
[CryptographicException: The data protection operation was
unsuccessful. This may have been caused by not having the user
profile loaded for the current thread's user context, which may be the
case when the thread is impersonating.]
I read and tried solution suggested at SignalR CryptographicException on AzureWebsites, but id didn't work for me.
As I understand, Azure doesn't allow LoadUserProfile.
Any workaround?
I had the same problem and my fix was to add a call to UseAesDataProtectorProvider() before my call to MapSignalR(). Hope this helps someone.

Rare System.NullReferenceException show up for a HttpContext.Current.Session["courseNameAssociatedWithLoggedInUser"] that was previously populated?

Our ASP.NET C# web application is used in the following environment
.NET Framework 4
Silverlight 4 / PivotViewer
IIS 7
Windows 2008
Visual Studio 2010 .NET IDE
C#
HTTPS ( SSL )
Our Silverlight 4 / PivotViewer controls are obviously embedded in
ASP.NET pages.
In rare cases we get the "Object reference not set to an instance of
an object. error when navigating around ASP.NET pages that host our
Silverlight 4 / PivotViewer modules on our standalone Windows 2008
server with IIS 7.
Also, there is number of very odd things about the error. First, it
occurs only sometimes on certain user computers. To elaborate, it
usually only occurs when a the user uses a computer that accesses our ASP.NET web application for the first time.
Moreover, once we clear the browser cache the error does Not occur
when navigating around ASP.NET pages that host our
Silverlight 4 / PivotViewer modules.
Another interesting aspect about the error is that it refers to
absolute path on my local development computer in the error stack
trace when it is in reality deployed to the standalone Windows 2008
server with IIS 7. That`s really strange because before I deploy to
the standalone Windows 2008 server with IIS 7, I ensure that all
configuration parameters in files such as web.config refer to the
standalone server environment. In other words, I remove any
references to configuration parameter values associated with my local
development computer.
Therefore, I am confused as to why it refers to absolute path on my
local development computer in the error stack trace.
It would be bad experience for the user to get the "Object reference
not set to an instance of an object.` while using the site. Also, it
would be bad user experience if we have to tell the user to clear
his/her browser cache everytime the error shows up.
Server Error in '/' Application.
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.]
PivotServer.SectionBasedRelatedModules.SectionBasedPerlsViewer.tailorConfigurationDetailsOfPageElementsToFallInLineWithTutorialSelection()
in C:\VisualStudioWorkSpace\VisualCSharpProjects\PerlsPivot\PivotServer\SectionBasedRelatedModules\SectionBasedPerlsViewer.aspx.cs:160
PivotServer.SectionBasedRelatedModules.SectionBasedPerlsViewer.Page_Load(Object
sender, EventArgs e) in
C:\VisualStudioWorkSpace\VisualCSharpProjects\PerlsPivot\PivotServer\SectionBasedRelatedModules\SectionBasedPerlsViewer.aspx.cs:146
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,
Object o, Object t, EventArgs e) +24
System.Web.UI.Control.LoadRecursive() +70
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3063
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.272
I looked at line 160 which contains the following code:
String coursename = HttpContext.Current.Session["courseNameAssociatedWithLoggedInUser"].ToString();
Obviously, this tells us that there is no value for the variable "courseNameAssociatedWithLoggedInUser" in the HttpContext.Current.Session.
However, I took the same steps on another computer but it all ran smoothly.
Also, I am sure that I am giving a value to the HttpContext.Current.Session["courseNameAssociatedWithLoggedInUser"] as soon as the user logs in.
Does the HttpContext.Current.Session["courseNameAssociatedWithLoggedInUser"] get corrupted for some reason? If so, why, and how do we prevent it?
Should I be using Page.Session instead of HttpContext.Current.Session? Would that help?
"Obviously, this tells us that there is no value for the variable"courseNameAssociatedWithLoggedInUser" in the
HttpContext.Current.Session."
Not exactly... given your code...
String coursename = HttpContext.Current.Session["courseNameAssociatedWithLoggedInUser"].ToString();
... the following items could be causing this
HttpContext - unlikely
HttpContext.Current - more often than you would think, but would be reproducible
HttpContext.Current.Session["courseNameAssociatedWithLoggedInUser"]
To find out the specific item in that chain, you could do something like this (pseudo code)
function string GetCourseNameThingie()
{
if HttpContext is null
throw new Exception("HttpContext is null")
if HttpContext.Current is null
throw new Exception("HttpContext.Current is null")
if HttpContext.Current.Session["courseNameAssociatedWithLoggedInUser"] is null
throw new Exception("HttpContext.Current.Session["courseNameAssociatedWithLoggedInUser"]is null")
return HttpContext.Current.Session["courseNameAssociatedWithLoggedInUser"].ToString()
}
This would tell you specifically what was missing. As we have pointed out, it is more likely the value is either being cleared by another page or an error is occurring that is severe enough to destroy session for that user (Do you have a Application_Error or Session_End handler in Global.asax?).
You can also try wrapping the original statement in a try/catch and if an exception occurs, immediately check another session variable you assume to be still working. This will also tell you for sure whether the other variables are OK or not.
First, sorry for my grammar-English.
I had a similar issue with my .net applications and the reason was the idle time expiration.
There are four time expiration settings "(Yes 4)" and the recycling process of the application pools. I did the following
A) From Application pool: Open the advance setting and change the "Idle Time out". By default is 20 minutes.
Also, set the "Regular Time Interval" to 0. so it wont be recycled. I do not know why microsoft decided to default this to 1740 minutes. This is not a time out setting, it is a setting for always recycling the appPool after a period of time, so if your users are in the middle of something they will loose everything or having exceptions like that one you are having. Setting it to 0 will disable this.
B) Authentication Time Out. if you are using it, for example Form Authentication, then go to the authentication feature of your virtual directory app, right click in "Form Authentication" and select "Edit". Change the authentication cookie-time out.
C) ASP.NET Session State. in ISS, open the .net session state feature and change the session time-out. It is also by default 20 minutes.
D) asp.net form authentication time out. This was confusing for me at the beginning because I had already modified the cookie-time out of the form authentication in IIS (Step B). So I still had some problems, when I realised that I also need to change the web.config form authentication tag in order to add a time out attribute for changing the default 20 minutes.
My tag is looking like that: ...forms name=".ASPXFORMSAUTH" path="/" loginUrl="frmLogin.aspx" timeout="1740" protection="All" ...
We have developed a javascript mechanism that take the session state time out setting so we warm users that the system is about to auto log off due to inactivity.
It works beautiful now, Basically I have set all the time out settings to "1740" minutes, except the session state that we set to 30 minutes. So at the minute 29 of inactivity we show the user that the system will auto log off in a minute unless that they do some activity so the idle time is beginning from 0 again. Brilliant, now we do not have any problem with sessions.
Anyway guys, I have told you our experience and how we solve a similar problem that you are having now. However, the reason why I ended here is because we also want to eliminate the references to the absolute path on my local development computer at the moment of any exception.
We have not figured out why it is showing the absolute path. We have compiled our DLL assemblies in released mode, but this does not change anything. Have someone of you sort it out this issue?????
Thanks guys
Referencing a Session Within a ViewModel
You may not be using ASP.net MVC, but this would be useful if someone were to be looking for an answer.
I was in exactly the same situation except I would receive the null exception every time, whereas my colleague didn't at all, even though we were running exactly the same code.
Our mistake was to reference a session variable from a ViewModel, which is apparently bad practice. The code was changed so that the ViewModel received the session contents via the controller then set it as a property of the ViewModel. The session data (my example is called ProcessingWeek) would use this.ProcessingWeek, and not look directly at the httpcontext.current.session["ProcessingWeek"].
EventMatchResult Match = new EventMatchResult(
(ImportedEventModel)SessionData.ImportedEventModel,
ref db,
SessionData.ProcessingWeek);
...
public EventMatchResult(ImportedEventModel Event, ref CFModel db,
int ProcessingWeek)
{
this.db = db;
this.MatchedField = new List<PlayerMatchResult>();
this.ImportedEvent = Event;
this.ProcessingWeek = ProcessingWeek;
}

Why do I get exception "The execution of the InstancePersistenceCommand named LoadWorkflowByInstanceKey was interrupted by an error"

After doing some refactoring to my WF4 service, I got this exception when calling some of the operations:
The execution of the InstancePersistenceCommand named {urn:schemas-microsoft-com:System.Activities.Persistence/command}LoadWorkflowByInstanceKey was interrupted by an error.
My xamlx file contains a few receive/sendreplytoreceive pairs, as shown below. The exception sometimes happens on receive2, sometimes receive3.
receive1 (no correlation, cancreateinstance=true)
send reply to receive (initializes content correlation on generated ID)
receive2 (correlates on ID, cancreateinstance=false)
send reply to receive
receive 3 (correlates on ID, cancreateinstance=false)
send reply to receive
After doing a lot of debugging and making sure all correlations where set up right, the exception disappeared for new instances of the workflow.
What does the exception mean, and why did it show up and why did it dissappear all of a sudden? Is it a code/xamlx issue or something with the infrastructure (AppFabric/SQL)?
I'm hosting the WF service with IIS/AppFabric, using AppFabric' SQL persistence.
According to this support note this error can be the result of a race condition between the Receive and a Delay activity expiring. Is this possible in your workflow.
I kinda figured mine out... aparently if you point your persistance store in a SQL previous to 2012 you get the error... so all i had to do is put mine persistance store in a SQL 2012...
When I had this problem it turned out to be a mistake in my connection string when instantiating the persistence store object.
SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(connStr);
I realise this an old question but fixing the connection string got rid of my error while running store.Execute() so I thought I'd share!

Saving error message and stack on asp.net

I've designed a website that works through my own PC.
I set the IIS to work with Custom Errors in case user ran into some unknown exception.
I've also added a check that the error page will e-mail me whenever it found an error.
Can I somehow get the error information (Stack and description) from the error page?
I encourages you to use Open Source library out there that provided functional need. My recommendation is ELMAH.
With a few line of settings in your web.config, you will all set. result screen looks like this.
(source: googlecode.com)
You can use ASP.NET Health monitoring.
http://msdn.microsoft.com/en-us/library/ms998306.aspx
Catch any errors that might be thrown and write them to the event log.
EventLog Logger = new EventLog();
Logger.Source = "ApplictionNme";
Logger.WriteEntry("Writing to event log.");

IIS7/Win7 - App Pool is failing suddenly

After nearly 5 months with this configuration I am now getting a series of:
"A process serving application pool 'Classic .NET AppPool' suffered a fatal communication error with the Windows Process Activation Service. The process id was '1640'."
This leads to:
Application pool 'Classic .NET AppPool' is being automatically disabled due to a series of failures in the process(es) serving that application pool.
I cannot, for the life of me, figure out what changed to start causing this nor can I figure out how to possibly dig in deeper to find out what is causing it to fail.
I recently (2 weeks ago) started adding Entity Frameworks to my solution. Right before this happened I did get an "out of stack space" error due to a reported self-referenced call. I cannot find any calls like that in the code I wrote and am suspecting EF may have added a join in my simple (3 table) model that is wrong.
Any ideas on where to start looking? What would cause the AppPool to fail?
TIA
NOTE:
An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll
I have an outside object that calls this method to get a single record:
public static AutoNegotiationDetails GetAutoNegotiationByCompany(Guid companyId)
{
return RivWorks.Controller.Negotiation.GetAutoNegotiationByCompany(companyId);
}
That method calls into:
internal static AutoNegotiationDetails GetAutoNegotiationByCompany(Guid companyId)
{
var autoNeg = from a in _dbRiv.AutoNegotiationDetails where a.CompanyId == companyId select a;
var ret = autoNeg.FirstOrDefault();
return ret;
}
In stepping through it I can set a break point inside the first method, step into the second method, see the record populated, return to the first method then finally exit the method. At that point my IDE locks up for a few seconds until I get the StackOverflow error.
For a more accurate picture of the whole system:
Running WebOrb30 on the IIS machine.
In the VS IDE -> Attach to Process (INETINFO.exe)
Log into WebOrb30 -> Management Console -> Drill down to service entry point -> Enter CompanyID into input box -> Click Invoke
Hit break point in VS IDE -> (See above)
NOTE:
Looks like it may be caused by another issue in EF. See C# - Entity Framework - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll for further clarification.
I may be that you have two apps/sites using one app pool, but the apps/sites are running different .net versions.
This might not be the case, but its the only similar recurring problem i've ever had with iis.
Because of a bug in my Entity Framework I was getting a cyclic call into one of my relationships. This was causing a stack overflow which was reported to WebOrb as a general error and WebOrb would halt causing the App Pool to crash. (I still don't quite understand all the specifics). When I rebuilt my EF Model without the relationships the behavior went away. (sigh/)
EF will be another question (or series of questions).

Resources