Enterprise Library 5.0 Logging exception on startup - c#

The application is running on multiple clients. Today I had an incident, where after a power failure, the application was not starting again.
Following are the exceptions from the event log
Faulting application name: MyApplication.exe, version: 7.3.0.14, time stamp: 0x626786ff
Faulting module name: KERNELBASE.dll, version: 6.1.7601.24561, time stamp: 0x5f76968d
Exception code: 0xe0434352
Fault offset: 0x0000c5af
Faulting process id: 0xeb4
Faulting application start time: 0x01d8d17277e726c1
Faulting application path: C:\Program Files (x86)\MyCompany\Visu\MyApplication.exe
Faulting module path: C:\Windows\syswow64\KERNELBASE.dll
Report Id: b5b2baf1-3d65-11ed-b8b3-00139548ead0
Detailed exception
Application: MyApplication.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Xml.XmlException
at System.Xml.XmlTextReaderImpl.Throw(System.Exception)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Configuration.XmlUtil..ctor(System.IO.Stream, System.String, Boolean, System.Configuration.ConfigurationSchemaErrors)
at System.Configuration.BaseConfigurationRecord.InitConfigFromFile()
Exception Info: System.Configuration.ConfigurationErrorsException
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(System.Configuration.ConfigurationSchemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.OnConfigRemoved(System.Object, System.Configuration.Internal.InternalConfigEventArgs)
Exception Info: System.Configuration.ConfigurationErrorsException
at System.Configuration.ClientConfigurationSystem.OnConfigRemoved(System.Object, System.Configuration.Internal.InternalConfigEventArgs)
at System.Configuration.Internal.InternalConfigRoot.OnConfigRemoved(System.Configuration.Internal.InternalConfigEventArgs)
at System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl(System.String, System.Configuration.BaseConfigurationRecord)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(System.String, Boolean, Boolean, Boolean, Boolean, System.Object ByRef, System.Object ByRef)
at System.Configuration.BaseConfigurationRecord.GetSection(System.String)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String)
at System.Configuration.ConfigurationManager.GetSection(System.String)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection.GetConfigurationSourceSection()
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceFactory.Create()
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.CreateDefaultContainer()
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.SetCurrentContainerIfNotSet()
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.get_Current()
at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.get_Writer()
at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(System.Object, System.String, Int32, Int32)
at MyApplication.App.Main(System.String[])
Code:
[System.STAThreadAttribute()]
public static void Main(string[] args)
{
Logger.Write("Application was started on:" + DateTime.Now, "Core", 100, 100);
...
}
As I had no possiblity for remote debugger, I copied the complete application folder from the client to my dev machine. Everything was working properly. The application started and the UI was displayed.
On the client machine I tried the following
checked the application.config file - everything OK
starting the application with administrative rights - same exception
moving the folder from the "program files" directory to somewhere different, including all configuration files - same exception
comparing the current application folder with initial folder after the setup, all files are equal - same exception
As a last point, i updated the code of the main method with a try catch block around the call to the Enterprise Logger. I compiled the exe and started the updated version on the client computer. Only the exe and manifest file have been updated!
The application started and the catch block was never triggered.
I switched back to the "previously corrupted?" version and now it was successfully running.
From the text i assume that something must be wrong the the app.config file. But then it would also throw the exception on my dev machine and would still throw the exception after the update of the app.exe.
What could be the reason of the above exception?

With the tips from #PanagiotisKanavos the solution of the problem was possible.
Checking the file access with procmon, i realised that there was a user.config file stored at C:<Users><Username>\AppData\Local<MyCompany><MyApp><AppVersion>.
This file was corrupt - filled with '\0' - due to the power failure.
At startup the user.config file was merged with the app.config file and this crashed the application.

Related

VS2022 + Net Maui Blazor - Start with/without debugging causes devenv.exe to crash

Running a Net Maui blazor hybrid app in Net core 7 causes VS 2022 to close without error
After reviewing event viewer there are 2 errors when the crash occurs
.Net runtime
Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
at Microsoft.VisualStudio.Deployment.ReparsePoint.GetTarget(Microsoft.VisualStudio.Deployment.DebugLogger, System.String, Boolean ByRef)
at Microsoft.VisualStudio.Deployment.PackageManagerOperations.TranslatePackageInfo(Windows.ApplicationModel.Package)
at Microsoft.VisualStudio.Deployment.PackageManagerOperations.TranslatePackageInfoForInstalledPackages(System.Collections.Generic.IEnumerable`1<Windows.ApplicationModel.Package>, Boolean)
at Microsoft.VisualStudio.Deployment.AppxLayoutManager.CheckPackageLayoutState(Microsoft.VisualStudio.Deployment.DeployPackageName, System.String)
at Microsoft.VisualStudio.Deployment.DeploymentDriver+<ConsumeRecipeAsync>d__133.MoveNext()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
Application error
Faulting application name: devenv.exe, version: 17.5.33209.295, time stamp: 0x20c46274
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0x00007ff9aacefb24
Faulting process ID: 0x50a4
Faulting application start time: 0x01d92853f93d94de
Faulting application path: C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\devenv.exe
Faulting module path: unknown
Report ID: 783eb4ba-2b16-40ff-830a-39d2611476f1
Faulting package full name:
Faulting package-relative application ID:
I've tried to catch an error dump but with VS closing it detaches from the process before catching.
Any help would be muchly appreciated.
Had this issue occuring all day.
Not sure if it was due to me running it in administrator but, I ran the exe directly from 'C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\devenv.exe' opened my project and it build/ran without VS closing.

App runs directly but not after Clickonce publishing

I have written a demo application, which will be expanded later into an actual app (the demo for now is that it is only UI without any meat behind it yet). I tried to publish it, and am having problems getting the published version to run, even on my machine, where it was developed.
When I run the app under visual studio, there are no issues. Likewise, if I run it from the bin\debug or bin\release folder when studio is closed, there is also no problem.
After publishing it (more below), and running the install, it installs, but doesn't run. If I go to where the application is actually installed (c:\users]\steveb\appdata\local\apps\2.0\gibberish1\gibberish2\reallylonggibberish\tmg.exe), it runs nicely from there as well. However, from the link it makes me, it refuses to run, and in the system event viewer I get two events:
First: Net Runtime – event ID 1026
Application: applaunch.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Security.SecurityException
at TMG.UserForm..ctor()
at TMG.Program.Main()
at System.AppDomain._nExecuteAssembly(System.Reflection.RuntimeAssembly, System.String[])
at System.Runtime.Hosting.ManifestRunner.NewThreadRunner()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
followed by:
Application error – event ID 1000
Faulting application name: applaunch.exe, version: 4.7.3056.0, time stamp: 0x5a8e5805
Faulting module name: KERNELBASE.dll, version: 10.0.17134.441, time stamp: 0x428de48c
Exception code: 0xe0434352
Fault offset: 0x000000000003a388
Faulting process id: 0x2cb0
Faulting application start time: 0x01d49dd862272806
Faulting application path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\applaunch.exe
Faulting module path: C:\Windows\System32\KERNELBASE.dll
Report Id: cf77cf44-c3b4-44a3-b7ae-956e11898c98
Faulting package full name:
Faulting package-relative application ID:
All this is on my own machine. I have tried putting the setup on other machines, and it is not working there as well, but I didn't get to this level of debugging there, although I expect it is the same.
Any help appreciated.
akseli - your comment was correct - it was in partial trust mode, which I assume translates as "don't run this anywhere including where it was written". Thanks for the help.

Wpf exe file crashes after deployment

My wpf application uses Windows.winmd and System.Windows.Runtime dll, and I have been trying to deploy the application using Visual studio setup installer project.
When I tried to build the setup project it would silently fail and show this non-descriptive error:
ERROR: An error occurred while validating. HRESULT = '80070057
taking help from this link: Could not load file or assembly Windows.winmd' I learned that when winmd files are referenced in a wpf application than files need to be manually added to the 'Application Folder', I did so, after manually adding the .exe file it added the dlls to the Application Folder, now I can build the setup project but it still shows these following warnings:
WARNING: Unable to find dependency 'WINDOWS' (Signature='(null)' Version='255.255.255.255') of assembly 'System.Runtime.WindowsRuntime.dll'
WARNING: Unable to find dependency 'MATERIALDESIGNCOLORS' (Signature='(null)' Version='2.5.0.1205') of assembly 'MaterialDesignThemes.Wpf.DLL'
WARNING: Unable to find dependency 'WINDOWS' (Signature='(null)' Version='255.255.255.255') of assembly 'Scout_Windows.exe'
Am I adding the files the wrong?
After installing the application from the generated setup.msi file, when I launch the .exe file, it doesn't start. The event viewer shows two errors, Application error:
Faulting application name: Scout_Windows.exe, version: 1.0.0.0, time stamp: 0xaf6df283
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0x015909b0
Faulting process ID: 0x2f58
Faulting application start time: 0x01d4907c33342151
Faulting application path: D:\temp\scout\Scout_Windows.exe
Faulting module path: unknown
Report ID: d0cf8414-8f12-4166-8836-ba1ec5ca8c80
Faulting package full name:
Faulting package-relative application ID:
.Net Runtime error:
Application: Scout_Windows.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
at Scout_Windows.App..ctor()
at Scout_Windows.App.Main()
here is snapshot for the contents of my Application Folder in the setup project
I have spent two days on this error! any help is appreciated.

How to debug a 0xc0000409 error in PerfMon.dll? / AssemblyBinding

Problem description
I am trying to debug a problem on a customer's server (Win 2012R2) where one of our .NET Web Applications is hosted in their IIS (version 8.5.9600.16384).
Recently, one of our technical supports changed a minor internal setting in the Web.config file of the application and according to them, nothing else was changed or done to the system. The application was not updated either, and had been running without any issues before.
Since that change, the AppPool in which the site is configured cannot be started anymore. According to the System Event logs, there are a few attempted starts, each resulting in a worker process crash, until the Rapid-Fail Protection of the pool stops the startup process entirely.
Also, since I'm on a customer's server, I only have limited debugging options.
Findings
Reported in the System Event log by WAS:
A process serving application pool '[our pool]' suffered a fatal communication error with the Windows Process Activation Service. The process id was '5664'. The data field contains the error number.
Application pool '[our pool]' is being automatically disabled due to a series of failures in the process(es) serving that application pool.
A look at the corresponding Application Error log reveals the following:
Faulting application name: w3wp.exe, version: 8.5.9600.16384, time stamp: 0x52157ba0
Faulting module name: PerfMon.dll, version: 8.0.10977.0, time stamp: 0x59cfb424
Exception code: 0xc0000409
Fault offset: 0x000f8c7b
Faulting process id: 0x1620
Faulting application start time: 0x01d423ff75bef49f
Faulting application path: C:\Windows\SysWOW64\inetsrv\w3wp.exe
Faulting module path: C:\Program Files\Microsoft Monitoring Agent\Agent\APMDOTNETAgent\V8.0.10918.0\PerfMon.dll
Report Id: b56327b3-8ff2-11e8-80d5-005056a52299
Faulting package full name:
Faulting package-relative application ID:
While googling for this problem I mainly focused on PerfMon.dll issues and the provided error code 0xc0000409, which is apparently either related to a corrupted registry entry or a Stack Buffer Overflow, but in both cases I've simply been unable to figure out what the cause could be.
I also tried the crash dump analysis described here
https://blogs.msdn.microsoft.com/parvez/2016/08/06/iis-application-pool-crash-and-debug-diag/
But in the end it seemed like it was just a round-trip back to the original problem, as this was the only error found in the dump:
The assembly instruction at PerfMon!DllGetClassObject+966fb in C:\Program Files\Microsoft Monitoring Agent\Agent\APMDOTNETAgent\V8.0.10918.0\PerfMon.dll from Microsoft Corp. has caused an unknown exception (0xc0000409) on thread 2
Which is basically what I've gotten from the event log already.
My main question here is not only what might be the cause and a potential fix to this problem, but also how to properly find the cause/solution in the first place.
UPDATE
Using Fusion Logs, I was able to find three binding errors for System.Web.DynamicData, System.Web.Extensions and System.ServiceModel.web.
The operation failed.
Bind result: hr = 0x80004005. Unspecified error
Assembly manager loaded from: >C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Windows\SysWOW64\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = [app root path]
LOG: Initial PrivatePath = [app root bin directory]
LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\bee9e73a
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\bee9e73a
LOG: AppName = b83a4ee
Calling assembly : (Unknown).
Rejecting code sharing because a dependent assembly did not match the conditional APTCA share mode
Searching for any information on this I was only able to find an old error related to MVC3/MVC4, which required a configuration change. That is unrelated to this issue, though.
This might also mean that the original error has nothing to do with the PerfMon at all and that the original error is just a weird side effect.
Just wanted to add that we had this (or a very similar) issue now on a Windows Server 2012 and resolved it by removing the Microsoft Monitoring Agent APM service as described in this rather brilliant blog post: http://kevingreeneitblog.blogspot.com/2017/03/scom-2016-agent-crashing-legacy-iis.html
(The issue described in the blog post supposedly only affects apps running on older .NET framework versions, but we experienced in with an app pool running only version 4.)
From our event log:
Faulting application name: w3wp.exe, version: 8.5.9600.16384, time stamp: 0x52157ba0
Faulting module name: PerfMon.dll, version: 8.0.11072.0, time stamp: 0x59c01c4c
Exception code: 0xc0000409
Fault offset: 0x000f8c7b
Faulting process id: 0x1ae8
Faulting application start time: 0x01d4eac448929ba3
Faulting application path: C:\Windows\SysWOW64\inetsrv\w3wp.exe
Faulting module path: C:\Program Files\Microsoft Monitoring Agent\Agent\APMDOTNETAgent\V8.0.11072.0\PerfMon.dll
Report Id: 8a700b62-56b7-11e9-8124-001dd8b71cba
Faulting package full name:

Unhandled exception for the component "MultiScaleImage" of "Silverlight 5"

I am developing a web application based on "Silverlight 5".
I found a blocking bug related to the component "MultiScaleImage" that happens after a unpredictable (sometimes it takes hours, sometimes minutes) number of zooms of the image.
When the issue occurs the following messages are shown:
Windows 7 Event Log: Faulting application name: IEXPLORE.EXE, version: 11.0.9600.17126, time stamp: 0x53882e30
Faulting module name: agcore.dll, version: 5.1.30214.0, time stamp: 0x52fdb3c4
Exception code: 0xc0000005
Fault offset: 0x003a8d0d
Faulting process id: 0x18dc
Faulting application start time: 0x01cf9cf438322755
Faulting application path: C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE
Faulting module path: C:\Program Files (x86)\Microsoft Silverlight\5.1.30214.0\agcore.dll
Report Id: a9de107e-08fe-11e4-b5ce-c86000a4b136)
Visual Studio Debugger: Unhandled exception at 0x5CCD8D0D (agcore.dll) in iexplore.exe: 0xC0000005: Access violation reading location 0xFFE2E6F2.
Internet Explorer 11: Internet Explorer has stopped working.
The test has been done with Win7+SP1 with IE11 and IE8.
This bug is preventing me from releasing the application and deploying it to the customer servers.
I can't believe there's no way to solve it nor a valid workaround.

Categories

Resources