I create a new C# Windows Form project in Visual Studio 2013 Update 5. I do not change it in any way. It debugs properly as usual. As soon as I change the Platform target to x64, the debugger shows this error:
System.AccessViolationException was unhandled
Message: An unhandled exception of type 'System.AccessViolationException' occurred in System.Windows.Forms.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
This happens in every 5 times of debugging. Do you have any idea on what may be causing this error and how it can be fixed?
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.
I removed a dynamic filter from OnModelCreating and the related NuGet package, EntityFramework.DynamicFilters, from my application as it is no longer required. As soon as I did this I started seeing Exceptions being thrown in the Output Window.
First when I run my application (C# with WPF and EF) I get:
Exception thrown: 'System.TypeLoadException' in mscorlib.dll
Then when I access my Data (Entity Framework) I get a whole bunch of exceptions when my code reaches this statement:
public List<T> GetAll() => Table.ToList();
The errors include:
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in EntityFramework.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in EntityFramework.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in EntityFramework.SqlServer.dll
The odd thing is that data is returned as expected and the application appears to be working, however, my gut tells me not to simply ignore them and hope for the best.
Taking advice from other posts I deleted the content of the Debug folder, Cleaned Solution and Rebuilt solution with no improvement.
Following other advice I uninstalled and re-installed Microsoft.Net Core and Microsoft.Net Framework, also with no improvement. My application is targeting .Net Framework 4.8
I removed and repaired the Entity Framework NuGet package, still no help.
To make 100% sure it was not a bug in my code I cloned the application to a different machine and it ran perfectly first time. (Edit: for clarity I also created a new folder on problematic machine and cloned to that with same problem) This tells me it must be something in my environment, but what?
I am all out of ideas, short of formatting by hard drive and re-installing Windows which I actually seriously considered a few time in the last 24 hours.
Reading https://learn.microsoft.com/en-us/visualstudio/debugger/just-my-code?view=vs-2019 prompted me to compare the debug settings on the two machines. Turns out that the problematic machine had Enable Just My Code unchecked. Checking it makes my problem "go away". The question now I suppose is whether it is safe to simply ignore exception which are "not in my code"?
After much research, my problem turned out to be the Debug setting in Visual studio which was not set to "Enable Just My Code". (Tools -> Options -> Debugging Tab, Enable Just My Code). https://learn.microsoft.com/en-us/visualstudio/debugger/just-my-code?view=vs-2019
From what I can gather from Google, it is safe enough to ignore minor errors originating from external assemblies. Assuming they are not impacting your program logic that is. I am not 100% comfortable with ignoring exceptions, but be that as it may.
Currently facing this issue in Visual studio:
An unhandled exception of type 'System.AccessViolationException' occurred in Unknown Module.
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt**
I do not have any code that I can show as I get this error when I start a new MVC 5 project. Facing the same issues if I try a regular MVC 4 project.
The projects builds just fine but when I try to run I get that error.
Note I haven't added any code. It's just a plain MVC 5 project.
I had the same error, in windows 10. My solution was Install Visual Studio 2013 Update 5 and still works.
You can download this package here https://go.microsoft.com/fwlink/?LinkId=519379.
I have program that works fine in my windows 8 x64. But when i try to run it in my laptop with windows 7 x64 i have some problems.
errors:
A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: URI formats are not supported.
A first chance exception of type 'System.BadImageFormatException' occurred in Emgu.CV.dll
Additional information: You tried to load the wrong format. (Excluded from the HRESULT: 0x8007000B)
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Target call threw an exception.
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Target call threw an exception.
'InzV2.vshost.exe' (CLR v4.0.30319: InzV2.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xaml.resources\v4.0_4.0.0.0_pl_b77a5c561934e089\System.Xaml.resources.dll'. Module was built without symbols.
A first chance exception of type 'System.Xaml.XamlObjectWriterException' occurred in System.Xaml.dll
Additional information:Calling the constructor for the type of „InzV2.MainWindow” compatible with specific binding constraints caused an exception.
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: Calling the constructor for the type of „InzV2.MainWindow” compatible with specific binding constraints caused an exception., line number 3, position 9.
An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: Calling the constructor for the type of „InzV2.MainWindow” compatible with specific binding constraints caused an exception., line number 3, position 9.
This errror looks like this:
I'm using Emgu.CV lib from Nuget called: myEmguCV.Net.
even if i try just crete new project with only:
BackgroundSubtractorMOG2 pMog11 = new BackgroundSubtractorMOG2(0, 80, false);
i have error..
This error occurs when unmanaged assembly is compiled for different platform than your .NET code is currently being compilled to.
For example if the unmanaged dll are in x86 architecture and you are trying to compile your code to x64 .NET runtime, you will get this type of error.
In the image you have provided it seems that you are trying to compile the code to x86 architecture and your EmguCV unmanaged .dlls are probably x64 based.
So go to
Project -> Properties -> Build -> tick the platform that matches the platform for which an unmanaged dll is compiled (x86, x64) (probably in your case it should be x64).
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?