.Net 4.0 crashes in clr.dll on Windows Server 2008 x86 - c#

We have a Windows Application that runs day in day out at several locations. Now though they've started crashing, they don't even generate an error on crash (should be catched by NLOG), they just stop suddenly. The only logs of the crash I can find is in the system event logger where I get 2 error logs:
Faulting application myapp.exe, version 1.0.0.0, time stamp 0x53f3377c, faulting module clr.dll, version 4.0.30319.2034, time stamp 0x52ccfa2b, exception code 0xc0000005, fault offset 0x0000ee9f, process id 0x%9, application start time 0x%10.
and
The process was terminated due to an internal error in the .NET Runtime at IP 6D09EE9F (6D090000) with exit code 80131506.
These are the descriptions in the event viewer (I can post the entire event log if it would help).
I hope someone knows how to get rid of these (I'm sick of getting calls in the night).

Related

WCF Windows Service fails to start, throws System.IO.FileNotFoundException

I've been battling an issue for several days. Among our solutions, we have an aging monolith comprising various ASP.NET technologies, as well as a WCF service, and several other Windows Services. Everything builds for my colleagues, and the services all start correctly. I hadn't worked on the monolith in a while, and when I turned my attention back to it, I experienced some various errors, including one that I still have not solved. In order for our WCF stuff to work, we have to run a Windows Service that acts as the WCF host. When I try to start this service, it bombs out, throwing up this dialog:
Windows could not start the {name of service} service on Local Computer.
Error 1064: An exception occurred in the service when handling the control request.
Checking Event Viewer, I find this .NET Runtime error in Windows Logs/Application:
Application: {redacted full path/name of WCF service host}.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
Exception Info: System.IO.FileNotFoundException
at System.ServiceModel.Channels.HttpChannelListener..ctor(System.ServiceModel.Channels.HttpTransportBindingElement, System.ServiceModel.Channels.BindingContext)
at System.ServiceModel.Channels.HttpChannelListener`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]..ctor(System.ServiceModel.Channels.HttpTransportBindingElement, System.ServiceModel.Channels.BindingContext)
at System.ServiceModel.Channels.HttpTransportBindingElement.BuildChannelListener[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.ServiceModel.Channels.BindingContext)
at System.ServiceModel.Channels.Binding.BuildChannelListener[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Uri, System.String, System.ServiceModel.Description.ListenUriMode, System.ServiceModel.Channels.BindingParameterCollection)
at System.ServiceModel.Description.ServiceMetadataExtension.CreateGetDispatcher(System.Uri, System.ServiceModel.Channels.Binding, System.String)
at System.ServiceModel.Description.ServiceMetadataExtension.EnsureGetDispatcher(System.Uri, Boolean)
at System.ServiceModel.Description.ServiceMetadataBehavior.EnsureGetDispatcher(System.ServiceModel.ServiceHostBase, System.ServiceModel.Description.ServiceMetadataExtension, System.Uri, System.String)
at System.ServiceModel.Description.ServiceMetadataBehavior.CreateHttpGetEndpoints(System.ServiceModel.Description.ServiceDescription, System.ServiceModel.ServiceHostBase, System.ServiceModel.Description.ServiceMetadataExtension)
at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(System.ServiceModel.Description.ServiceDescription, System.ServiceModel.ServiceHostBase)
at System.ServiceModel.ServiceHostBase.InitializeRuntime()
at System.ServiceModel.ServiceHostBase.OnOpen(System.TimeSpan)
at System.ServiceModel.Channels.CommunicationObject.Open(System.TimeSpan)
at {elided - a few more stack trace lines referring to our custom code}
Also in the same Event Viewer log, I have this Application Error (immediately after the .NET Runtime one):
Faulting application name: {service name}.exe, version: 4.2.0.0, time stamp: 0x5f0f45ce
Faulting module name: KERNELBASE.dll, version: 10.0.18362.815, time stamp: 0xb89efff3
Exception code: 0xe0434352
Fault offset: 0x000000000003a799
Faulting process id: 0xd84
Faulting application start time: 0x01d65ad32192a62b
Faulting application path: {full service path/name}.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: 1db8e59a-b3a0-47e3-bb0f-5d8c6e2f8ed5
Faulting package full name:
Faulting package-relative application ID:
I've mostly been working in .NET Core with VS 2019 for the past year and a half, and so I thought maybe some configuration or SDK needed for Framework had gone missing. I still have 2017 on my machine, and that is what my colleagues prefer to use for this one monolithic solution. Now, over these several days, I have done the following:
Removed and/or installed various SDKs and targeting packs
Repaired VS 2017
Uninstalled and reinstalled VS 2017
Repaired VS 2019
Uninstalled and reinstalled VS 2019
Uninstalled and reinstalled the Windows Services many times
I've picked up the vaguest hints from web search results above my head that there could be a problem with some binding redirects. Initially I could have sworn I saw evidence that the FileNotFound was something in System.Net.Http, but now I can't seem to find whatever indicated that to me. At this point I'm completely burnt on it, and I'm considering just wiping the whole system and starting with a clean Windows installation. It would be a real shame if I were to have to do that. If you have even the vaguest hint about where to look or what to try, it would be much appreciated.
This may be due to the failure to find the WCF configuration file when the service starts, which can not start normally.
You need to check the value of the service name, the service name is not set randomly, this is the implementation class of the service interface.
The above picture is the interface and implementation class of WCF service.
For more details about hosting WCF in windows service, please refer to the link below:
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-host-a-wcf-service-in-a-managed-windows-service

C# console app crashes when called using shortcut

I have a small C# console application that copy to a server, where it runs just fine.
However, if I call the .exe using a shortcut from another machine, it crashes. Any dependencies are also present on the calling machine.
In the eventview on the calling machine, all I'm getting is:
Faulting module name:
KERNELBASE.dll, version: 6.2.14393.2189, time stamp: 0x5abdad60
Exception code: 0xe0434f4d
Any ideas to help?
The returned exception is an error with permissions - see the following MSDN forum post;
https://social.msdn.microsoft.com...
It surmises that by default .NET security does not allow you to run .NET programs directly from a network share. The error itself is from a COM object - "Exception from COM object".

Problems publishing working application to Azure

I have an MVC 5 build that is building and running locally without any problems whatsoever. I cannot however publish to Azure. I'm publishing with Intellitrace enabled and I'm seeing that an exception is being thrown attempting to activate the role.
Exception Thrown: "Requested registry access is not allowed." (System.Security.SecurityException)
I have made sure of the following:
I have the latest edition of the Microsoft Azure SDK
All the relevant project references for all of my project references are set to Copy Local: True
All the relevant libraries have the correct binding redirects in their respective app.config/web.config files
All the Azure references in my project are to the correct versions of the assemblies
The event log shows the following exceptions in chronological order:
Error 4/11/2014 3:23:57 AM SRMSVC 8228 None
File Server Resource: Manager was unable to access the following
file or volume: 'E:'. This file or volume might be locked by
another application right now, or you might need to give Local
System access to it.
Error 4/11/2014 3:31:44 AM .NET Runtime 1026 None
Application:
DiagnosticsAgent.exe Framework Version: v4.0.30319 Description: The
process was terminated due to an unhandled exception. Exception Info:
System.IO.FileNotFoundException Stack: at
Microsoft.WindowsAzure.Plugins.Diagnostics.DiagnosticsGuidNamedEventProvider.GetNamedEvent(System.String)
at
Microsoft.WindowsAzure.Plugins.Common.BlockingExecutionEnvironment.Execute(System.Func`1)
at
Microsoft.WindowsAzure.Plugins.Diagnostics.Program.Main(System.String[])
Error 4/11/2014 3:31:44 AM .NET Runtime 1026 None
Application:
DiagnosticsAgent.exe Framework Version: v4.0.30319 Description: The
process was terminated due to an unhandled exception. Exception Info:
System.IO.FileNotFoundException Stack: at
Microsoft.WindowsAzure.Plugins.Diagnostics.DiagnosticsGuidNamedEventProvider.GetNamedEvent(System.String)
at
Microsoft.WindowsAzure.Plugins.Common.BlockingExecutionEnvironment.Execute(System.Func`1)
at
Microsoft.WindowsAzure.Plugins.Diagnostics.Program.Main(System.String[])
.
Error 4/11/2014 3:31:45 AM Application Error 1000 (100) Faulting
application name: DiagnosticsAgent.exe, version: 0.0.0.0, time stamp:
0x5243ef34 Faulting module name: KERNELBASE.dll, version:
6.2.9200.16451, time stamp: 0x50988aa6 Exception code: 0xe0434352 Fault offset: 0x000000000003811c Faulting process id: 0x9c Faulting
application start time: 0x01cf55368ce74b73 Faulting application path:
E:\plugins\Diagnostics\DiagnosticsAgent.exe Faulting module path:
D:\Windows\system32\KERNELBASE.dll Report Id:
cdd18167-c129-11e3-93f5-00155d85a04e Faulting package full name:
Faulting package-relative application ID:Server ResourceApplication:
We were getting the following error:
"File Server Resource Manager was unable to access the following file or volume: 'E:'. This file or volume might be locked by another application right now, or you might need to give Local System access to it."
We resolved the issue by updating our project references. If you are getting this error, check your Azure references, specifically these two:
Microsoft.WindowsAzure.ServiceRuntime
Microsoft.WindowsAzure.Diagnostics
Ensure that your references are the appropriate Azure SDK version to the schema/SDK you are pointing to in Azure.

How to catch an untrapped exception? Windows 7

my program is working in Windows XP, but crashes without any exception in windows 7. Try catch does not work. I also tried application.unhandledexception with no luck. Then I tried checking in windows administration and got the following log:
Level Date and Time Source Event ID Task Category
Error 7/25/2011 11:25:14 AM Application Error 1000 (100) "Faulting application name: myApp.exe, version: 1.0.0.0, time stamp: 0x4e2ce191
Faulting module name: ntdll.dll, version: 6.1.7601.17514, time stamp: 0x4ce7b96e
Exception code: 0xc0000005
Fault offset: 0x00052ca9
Faulting process id: 0x%9
Faulting application start time: 0x%10
Faulting application path: %11
Faulting module path: %12
Report Id: %13"
I'm not sure which part of the code to show as it has large collection classes, but I'll get back to editing this post.
I tried dumping files too from task manager, but I'm not sure how to use them.
Are there any particular tools I could use? I'm using VS2008. I looked into NLog, but I'm not sure what to do with it, so I skipped.
Any suggestions? tips and tricks?
Try ThreadExceptionEventHandler and see.
Application.ThreadException += new ThreadExceptionEventHandler(MyCommonExceptionHandlingMethod)
private static void MyCommonExceptionHandlingMethod(object sender, ThreadExceptionEventArgs t)
{
//Exception handling...
}
Edit : In Windows Forms applications, when an exception is thrown anywhere in the application (on the main thread or during asynchronous calls), you can catch it by registering for the ThreadException event on the Application.
EDIT 2
Try with compatibility? If it works fine, then there is something that doesn't compatible with Win7.
You can choose to run the program in Windows XP compatibility mode
Faulting module name: ntdll.dll says you're in for a lot of fun, but you should start with any P/Invokes in your code. It shouldn't be possible to cause such an error from .NET, so it's some native DLL you're calling.
P/Invoke lets you call normal, native, non-managed executables from managed code. This can be anything that isn't programmed in .NET - i.e. drawing libraries, audio libraries, etc. It is possible that you use it without knowing, for example, if you have multimedia controls. There's a pretty decent article right here.
If you're doing COM Interop with i.e. Microsoft Office, the same as above applies. Check if it's the same Office version, and even if it is, you may need the same versions of the Primary Interop Assemblies from Microsoft.
You may also try starting the application from Visual Studio, you might get a stack trace, which tells you the exact path the application took before crashing. Then you'll know what's happening.

Faulting system dll then service crashes

We've got a weird pattern of failure in one of our written services. We'll get a fault out of a system dll then a minute or so later our service will crash with or without a unhandled exception.
We'll get one of the following faulted module messages from .Net runtime error reporting:
faulting module kernel32.dll, version 5.1.2600.5781
faulting module ntdll.dll, version 5.1.2600.5755
faulting module clbcatq.dll, version 2001.12.4414.700
More than 30 seconds (but less than a minute) later we may or may not get an exception like:
System.Runtime.InteropServices.SEHException
System.AccessViolationException
exception in a MSDTC related component
System.Globalization.CultureNotFoundException
Has anyone seen this delayed/paired behavior? Both errors are reported to the event viewer. This only occurs on some physically-older XP production systems, never in dev.

Categories