ASP.NET: Wrong Code Displayed in Crash Dump - c#

So a webapp I've been working on broke, and I made some fixes... it still crashes, but in the YSOD it shows me the old code. I'm running this from the VS 2005 IDE. It won't hit any breakpoints, and it crashes on line 249, which is clearly commented out. I've cleared out my debug/release folders and rebuilt it; restarted IIS (just in case); what would cause this?
Could not find file 'c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\map.xml'.
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.IO.FileNotFoundException: Could not find file 'c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\map.xml'.
Source Error:
Line 248: //XmlDocument xMap = new XmlDocument();
Line 249: //xMap.Load(MapPath("map.xml"));

The current code probably did not compile, therefore the metadata in the DLL is for your old code.

Related

Published WIndows Console App fails with System.ComponentModel.Win32Exception at Microsoft.Data.SqlClient.SNINativeMethodWrapper..cctor()

I have a Windows Console application that accesses our SQL database. This app works fine from VS2019, the debug folder and the release folder. However, if I publish this app, the installed version fails with the exception shown below.
I do note the following differences between the installed location (\AppData\Local\2.0\xxx\yyy) and the \Release folder:
The \Release folder has SNI files in the \x86 and \64 directories, but the installed directory is missing this information. How do I include this in the manifest? I suspect that this is the main issue causing the exception.
The manifest file in the installed location is missing information related to Identity - not sure if this is a concern, but perhaps it is?
Application: SmartRView Configuration.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ComponentModel.Win32Exception
at Microsoft.Data.SqlClient.SNINativeMethodWrapper..cctor()
Exception Info: System.TypeInitializationException
at Microsoft.Data.SqlClient.SNINativeMethodWrapper.SNIInitialize()
at Microsoft.Data.SqlClient.SNILoadHandle..ctor()
at Microsoft.Data.SqlClient.SNILoadHandle..cctor()
Exception Info: System.TypeInitializationException
at Microsoft.Data.SqlClient.TdsParser..cctor()

Why is it actually impossible to load onnxruntime.dll?

Using the tutorial from the developers at Microsoft, I followed the tutorial created at https://learn.microsoft.com/en-us/dotnet/machine-learning/tutorials/object-detection-onnx.
I made sure to install CUDA V10.1.243 and cuDNN 7.6.5 from Nvidia's site.
Yet somehow, even after copying the entire contents of C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin to my project binary's directory at machinelearning-samples\samples\csharp\end-to-end-apps\ObjectDetection-Onnx\OnnxObjectDetectionApp\bin\Debug\netcoreapp3.0, I keep running into the following error while compiling the example program MS provided: Exception thrown: 'System.DllNotFoundException' in System.Private.CoreLib.dll An exception of type 'System.DllNotFoundException' occurred in System.Private.CoreLib.dll but was not handled in user code Unable to load DLL 'onnxruntime' or one of its dependencies: The specified module could not be found. (0x8007007E).
This should make sure they are accessible from the PATH right? I'm also including their original location in NVIDIA GPU Toolkit in the system PATH as well. I am using the latest version of Visual Studio 2019 to load and compile this solution. Is there anyone out there that has been able to run this code successfully, and if so, how?

How to fix the Server Error(parse Error) after deploying te asp.net site

I uploaded my asp.net application through FTP from visual studio, after deploying it is throwing runtime(Parse Error).
I have seen several posts and tried many alternatives but none of them is working:
After uploading, the error was:
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to
service this request. Please review the following specific parse error
details
and modify your source file appropriately.
Parser Error Message: Could not load type 'SimpleEchoBot.WebApiApplication'.
Source Error:
Line 1: <%# Application CodeBehind="Global.asax.cs"
Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>
Source File: /global.asax Line: 1
As mentioned in this post: Parser Error Message: Could not load type 'webmarketing', I changed CodeBehind to CodeFile but a new error has been raised stating that asax.cs does not exist!
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to
service this request. Please review the following specific parse error
details and modify your source file appropriately.
Parser Error Message: The file '/Global.asax.cs' does not exist.
Source Error:
Line 1: <%# Application CodeFile="Global.asax.cs"
Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>
Source File: /global.asax Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET
Version:4.7.3282.0
At the time my plesk file manager looked like this:
And then I uploaded Global.asax.cs file and then this error showed up:
As shown in this post: Parser Error: Server Error in '/' Application I changed Global.asax.cs namespace such that it is equal to the inherits path in asax!
Modified namespace code in asax.cs:
https://imgur.com/59d4IJK.jpg
code in asax:
<%# Application CodeBehind="Global.asax.cs" Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>
but still, the above "This program is blocked by group policy" error is getting raised!
And I deployed the same application to Azure, same parse error, mentioned at the top is showing up!
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'SimpleEchoBot.WebApiApplication'.
Source Error:
Line 1: <%# Application CodeBehind="Global.asax.cs" >
Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>
Source File: /global.asax Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3163.0
Edit: As requested by jessehouwing, here are the Bin folder Screenshots:
As #jeesehouwing comment mentioned, I tried to precompile the website and upload, but while precompiling I received few errors:
System.AggregateException: One or more errors occurred. --->
System.Exception: Publish failed due to build errors. Check the error list
for more details.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean
includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout,
CancellationToken cancellationToken)
at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.
<>c__DisplayClass40_0.<PublishAsync>b__2()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) atSystem.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)atMicrosoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__88.MoveNext()
---> (Inner Exception #0) System.Exception: Publish failed due to build errors.
Check the error list for more details.<---
Looks like you can only upload a pre-compiled website and can't include the Roslyn compiler in your deployment, as it's being blocked by the host. You can use Publish Profile in Visual Studio to configure pre-compilation (and I suspect you'll need to pick the "non-updatable" option).
See also:
https://stackoverflow.com/a/40225124/736079
More info
It looks like your web host has whitelisted which executables are allowed to run. This is a hardening practice to make an environment more secure. The most recent versions of ASP.NET include the C# compiler as part of the deployment to compile the MVC views and other elements on the fly. To do so your application ships the csc.exe compiler executable with your web application. csc.exe hasn't been whitelisted by the provider and that is blocking the dynamic recompilation of the Global.asax.cs.
Either target an older version of ASP.NET (which doesn't ship the roslyn compiler framework) or precompile the website so it no longer relies on the roslyn compiler to be present.

libzmq.dll FileNotFoundException

tl;dr Q. "how do we successfully deploy [unmanaged library] libzmq to load dynamically to support 'ZeroMQ CLR namespace' being used in a C# program?"
C# code with NuGet pkg ZeroMQ 4.1.0.17 (Runtime version v4.0.30319; Version 4.1.0.42169) installed. Works just fine running in the Visual Studio workspace but when deployed with the .exe in the same directory as the ZeroMQ.dll and with an amd64 subdirectory containing both libzmq.dll and libsodium.dll -- and even with copies of both those copied up into the same exec directory as program and ZeroMQ.dll -- we get:
Connect System.TypeInitializationException: The type initializer for 'ZeroMQ.lib.zmq' threw an exception. ---> System.IO.FileNotFoundException: UnmanagedLibrary[libzmq] Unable to load library "libzmq" from "C:\Windows\TEMP\libzmq.dll". Inspect Trace output for details. ---> System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
--- End of inner exception stack trace ---
at ZeroMQ.lib.Platform.Win32.LoadUnmanagedLibrary(String libraryName)
at ZeroMQ.lib.zmq..cctor()
--- End of inner exception stack trace ---
at ZeroMQ.ZContext..ctor()
at Core.Adapter.ZeroMQ.ZeroMQMessagingService.Connect(String connection_string) in \ZeroMQMessagingService.cs:line 201
Note that is says it is looking in C:\Windows\TEMP but maybe that is only the last place in a chain.
We're getting this after upgrading to ZeroMQ 4.1.0.21 and failing to load the libzmq.dll as an "embedded resource", so we removed .21 completely and returned to .17. It had been working fine in .17 before we upgraded to .21.
Copy If Newer is checked on the amd64\libzmq.dll and libsodium.dll and, yes, this is an x64 build attempting to run on an x64 machine. The failing host is 2012 Server running .NET 4.5.
This turned out to be very simple. We are moving to a new machine still being configured and installing the C++ 2010 redistributable solved the problem for us.

debugger does not stop on error

I'm working on Asp.net MVC4 project using Visual Studio 2012.
When there's an error during debugging, it used to stop on the error.
But suddenly, the debugger does not stop and just spit out the error information webpage like below.
Server Error in '/' Application.
The given key was not present in the dictionary.
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.Collections.Generic.KeyNotFoundException:
The given key was not present in the dictionary.
Source Error: ...
Stack Trace: ...
How can I set the debugger to stop on the error?
I had the same problem, even my debugging options are the same as #John Koerner.
I found that not all exception types are enabled to break the solution by default. You can choose which are enabled from the Exception Setting window.
VS2015: Debug -> Windows -> Exception Settings.
VS2012: Debug -> Exceptions more details
I enabled the whole CLR Exceptions set.
Make sure the exception assistant is enabled:

Categories

Resources