I am trying to figure out AppDomains.
I use following code to run the current application once more in a new child AppDomain with an argument:
AppDomain domain = AppDomain.CreateDomain("NewAppDomain", null);
domain.ExecuteAssemblyByName(currentAssembly.FullName, "argument");
It works fine, however, when I try to unload it via AppDomain.Unload(domain);, it also kills Parent it was called from.
In the debug output I can see following errors:
Exception thrown: 'System.Threading.ThreadAbortException' in mscorlib.dll
Exception thrown: 'System.Threading.ThreadAbortException' in mscorlib.dll
Exception thrown: 'System.Threading.ThreadAbortException' in TestAppDomain.exe
Exception thrown: 'System.Threading.ThreadAbortException' in System.Windows.Forms.dll
Exception thrown: 'System.AppDomainUnloadedException' in TestAppDomain.exe
I am not sure what is the issue here, how can I correctly unload such child AppDomain without killing Parent?
Main thread was not stopped completely before I tried to unload the AppDomain.
Stopping it correctly fixed the error.
Related
So, I made a fresh ASP.NET Core Web App (Model-View-Controller) project in visual studio 2022 and .NET 6 like shown below.
When I start the project (without changing anything) I get the following 3 exceptions:
Exception thrown: 'System.IO.IOException' in System.Net.Security.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
However the project still runs and the website opens as expected.
Are these exceptions something to worry about?
The fact that an exception is thrown is not a problem. Exceptions get thrown. That's what they do. It's a problem when they aren't caught and managed appropriately. If your code isn't even seeing those exceptions then they are being caught and handled in system code, so they're not relevant to you. If your application crashes, that is an unhandled exception, so you need to look at why it's being thrown and whether or not you need to prevent it and/or catch it and clean up.
ERROR:
Activated Event Time Duration Thread
Exception: Exception thrown: 'System.TypeInitializationException' in EntityFramework.dll ("The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception."). Exception thrown: 'System.TypeInitializationException' in EntityFramework.dll ("The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.")
The steps s for solving my problem:
1.I removed EntityFramework 6.2.0 and installed it again.
2.I deleted ModelData Base and added to project it again.
With this solution, my problem solved.
I have a MVC application, which is referring another project (B) which is a x86 project has one Vc++ dll reference.
When I am trying to run the B project as a console application as start up project it is properly running.
But when I am accessing the same from MVC application , Am getting BadImageFormatException or TypeInitializationException.
I used Assembly trace and am getting exceptions as bellow from each place one by one
BinaryAssemblyInfo Exception thrown:
'System.Runtime.Serialization.SerializationException' in mscorlib.dll
Additional information: Unable to find assembly 'NI.Framework.Logger,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b98c50443551b471'.
RealProxy.cs
'System.Runtime.Serialization.SerializationException' in mscorlib.dll
Additional information: Unable to find assembly 'NI.Framework.Logger,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b98c50443551b471'.
Exception thrown: '.ModuleLoadException' in
MsgComWrapper_4.0.dll Additional information: The C++ module failed to
load while attempting to initialize the default appdomain.
Action method dispatcher.cs: Exception thrown:
'System.TypeInitializationException' in System.Web.Mvc.dll
Additional information: The type initializer for '' threw an
exception.
AsyncControllerActionInvokers.cs
Exception thrown: 'System.TypeInitializationException' in
System.Web.Mvc.dll
Additional information: The type initializer for '' threw an
exception.
I have tried many trail and error but not worked.
Well, AFAIK you have 2 options:
1. You can build your mvc app to x86. It will work on x64, it just will not use all the power x64 architecture can offer.
2. You can run your app on a x86 machine. That would also work
The only way to have a "true" AnyCpu app is to have all your dlls built for AnyCpu. Its very annoying and not intuitive and I have suffered a lot over this over time, but this is the reality. I'm still sure there is a better solution that I don't know of, even though I have spent a decent amount of time looking for it and found nothing
I have a WCF project (.NET 4.5) and when I call a long running function on it, I'm getting this error:
A first chance exception of type 'System.IndexOutOfRangeException' occurred in mscorlib.dll
in the output window, but the thing is when I debug the project, there are no exceptions thrown in the project and the project keeps running/debugging as if no error happened. I thought that if there was an exception in my code, it should break and show the stack trace, but in this case no errors and keeps running. I'm seeing this information like a lot. It fills the output window and keeps going/adding
Do anyone know what this error means? Why am I not getting unhandled exception thrown error if this is true?
This just started happening with an application that has been working:
"A first chance exception of type 'System.DllNotFoundException' occurred in PresentationCore.dll
A first chance exception of type '.ModuleLoadException' occurred in PresentationCore.dll
A first chance exception of type 'System.TypeInitializationException' occurred in mscorlib.dll
An unhandled exception of type 'System.TypeInitializationException' occurred in mscorlib.dll"
How do I figure out which dll is missing?
TIA for any hints...
You can use fuslogvw.exe to check for missing assembly dependencies, or Depends.exe for native dependencies.