VS2010 Strange ASP.NET Startup Errors - c#

I have existing VS2010 ASP.NET solution which was working OK. However now when I try to run it, I get some very strange (seemingly random combination of) errors:
Invalid file name for file monitoring: '[Web App Path]\Controls' (this is a directory)
Requested registry access is not allowed. (Source: mscorlib - the call Stack says its parent higher up the stack is from System.Web.Compliation.BuildManager.ExecutePreAppStart())
System.Web.HttpException occurred / HResult=-2147467259 / Message=File does not exist.
Access to the path: 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\6c9c2bea\84b35c9c\App_Web_cyfzelmo.dll' is denied. (also
App_Browsers.dvwnc2tw.dll, App_global.asax.wtigsdou.dll)
An existing connection was forcibly closed by the remote host
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) - System.Threading.Monitor.ReliableEnter(Object obj, Boolean& lockTaken)
at System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
Value cannot be null. Parameter name: source [stack parent: System.Web.Compilation.BuildManager.LoadCachedPreAppStartAssemblies(string preStartInitListPath)]
These are only shown if I have Debug/Exceptions/CLR Exceptions (Thrown) set, however I don't recall seeing them before (I usually always have this option set). I created a blank ASP.NET solution, enabled CLR Exceptions (Thrown) and also got the registry and argument null error - whenever I rebuilt and re-ran the solution.
I have recently installed VS2012 as well, but am not sure if this is a cause. I've also upgraded my Telerik controls - but my blank solution doesn't have them configured.
Any suggestions other than a repair install of VS2010? (Which I'll likely try eventually when I get the time).

The installation must have been corrupt. We re-imaged the machine and re-installed VS2010.

Related

The type initializer for 'Sap.Data.Hana.HanaConnection' threw an exception. ---> System.IO.FileNotFoundException: Cannot find libADONETHDB.dll

I have a problem only on a specific machine.
I have two programs with a reference to Sap.Data.Hana.v4.5.dll, the ADO.NET Provider for .NET 4.5 for HANA database.
When my programs instantiates a connection object with
dbConnection = new HanaConnection(...);
I get this error:
System.TypeInitializationException: The type initializer for 'Sap.Data.Hana.HanaConnection' threw an exception. ---> System.IO.FileNotFoundException: Cannot find libADONETHDB.dll.
at Sap.Data.Hana.HanaUnmanagedDll.SearchNativeDlls(String regKeyName)
at Sap.Data.Hana.HanaUnmanagedDll..ctor()
at Sap.Data.Hana.HanaUnmanagedDll.get_Instance()
at Sap.Data.Hana.HanaConnection..cctor()
--- End of inner exception stack trace ---
at [...my program calls...]
Why can't it find libADONETHDB.dll?
My applications are build one in 32-bit, the other in 64-bit.
On this machine I installed SAP HANA client 2.8.20.23662 (latest version) both 32-bit and 64-bit.
The file that cannot be found seems to exist:
You could use Process Monitor while running the relevant part of the program to see, which file is missing and the path it should be in. Exclude all other events than file events and filter out all SUCCESS messages.
Perhaps it is referenced relative to the calling DLL (where Sap.Data.Hana.HanaUnmanagedDll.SearchNativeDlls is defined).
My hipotesis is that GAC had been corrupted with version 1 of Sap.Data.Hana.v4.5.dll:
Probably in the past HANA Client version 1 had been installed and removed and uninstallation hadn't cleaned the GAC.
My program uses HANA Client of any version, works both with version 1 and 2. For some reason when they start they seem to take version 1 of Sap.Data.Hana.v4.5.dll in the GAC. Process Monitor (thanks #sc911) confirms it:
This .NET DLL then looks for some unmanaged DLLs in C:\Program Files (x86)\hdbclient. Version 1 seems to look for libADONETHDB.dll in root folder.
But currently in this machine in that folder we have HANA Client 2.x and its folder structure is quite different from that of version 1 (there is no libADONETHDB.dll in root folder).
Hence the error in this question.
All this is valid both for 32-bit and 64-bit HANA Client.
I solved renaming or deleting version 1 folder in C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Sap.Data.Hana.v4.5 (probably there are better ways for performing this cleanup).

Program fails to start; Event Viewer logs ConfigurationsErrorException

Issue: On my development machine, everything works fine. However, when I copy the executable to the server, my program doesn't start
What I've done so far: I checked the event viewer and the error stack looks like this:
Application: Project.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Configuration.ConfigurationErrorsException
Stack:
at System.Configuration.ClientConfigurationSystem.EnsureInit(System.String)
at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(System.String)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String)
at System.Configuration.ConfigurationManager.GetSection(System.String)
at System.Configuration.ConfigurationManager.get_ConnectionStrings()
at Project.BaseService..ctor()
at Project.Service..ctor()
at Project.Program.Main()
I checked online and, most of the times, this error is generated by some misplacement of configSections on the .config files. To make sure this was not the case, I let both app.config and .exe.config files clean (only the section was there), but my program still didn't work.
Then, I generated a dump file from the failing process and here is where things get strange: the exception that is thrown when I'm calling ConfigurationManager.ConnectionStrings is "Configuration System failed to initialize", with a "The 'add' start tag on line 257 position 6 does not match the end tag of 'connectionManagement'. Line 258, position 3." inner exception. I double-checked my entire project and there is not a single reference to "connectionManagement" anywhere! I even tried to check AppDomain.CurrentDomain.SetupInformation.ConfigurationFile's value and it indicates the right config file.
By fixing this connectionManagement issue I'll probably be able to run my application, but do you guys have any idea about where this might be coming from?
Problem was on the machine.config file on the server. Changing it solved the problem!

Trying to debug Windows Store App from dump files

Let me start with my main questions, then below I will add some specifics and history. I have done research, but can't seem to fit the pieces together. Please ask for clarification before voting me down.
My questions:
Why would my Windows Store app start and run correctly locally on my Win 8.1 64 bit AND my Win 8.1 32 bit (Atom) tablet, but not start for other users?
When I get the dump file from Windows Store certification failure, how can I get the debug symbols to work so I can see more of the issue?
When I build in 'Release' mode, does it actually put the symbols into the .pdb files? And does it index the symbols?
Here's the history:
I developed a little game as a Universal app, Win Phone and Windows Store. Win Phone version is in the store, getting downloaded, and works fine.
The Windows Store version is having issues.
It runs on my machine, Win 8.1 64bit. It runs on my tablet, Win 8.1 Atom, which I install via Remote Debug from within Visual Studio. It passes the App Certification here on my box. But when I submit the package to the Windows Store it doesn't pass, and the report says it crashes when starting up. (Somehow the first appx package was released on the store, then later they replied that it crashes, so some users say the app doesn't load.)
So, I download the debug data and open up the .dmp file. I get Exception Code 0xC000027B
Digging around online, I find this is a 'Language Exception', and is a general error saying the bug was Unhandled. Following articles like this (http://blogs.msdn.com/b/ntdebugging/archive/2014/01/13/debugging-a-windows-8-1-store-app-crash-dump.aspx)
I try to get the symbols for my app to load to see if that will help. I added a folder for my app to my local symbols cache folder (c:\symbols\myApp\1.3.0.7) thinking Visual studio would pick them up, and copied the .exe, .dll, and .pdb files from the apx package that I had submitted to the store, but still get these messages:
'WER38D7.tmp.dmp' (Minidump): Loaded '*CryptoQuoteW8cs.exe'. Module was built without symbols.
'WER38D7.tmp.dmp' (CLR v4.0.30319: ): Loaded '*CryptoQuoteW8cs.exe'. No matching binary found.
'WER38D7.tmp.dmp' (CLR v4.0.30319: ): Loaded '*CryptoLogic.DLL'. No matching binary found.
A fatal exception was caught by the runtime. See $stowedexception in the Watch window to view the original exception information.
So, I'm at a loss. How do I get my app working? What error is holding it up? Why does it work and pass Certification locally, but not on the store? How can I find out? I've been all over Bing and Microsoft, and maybe I'm just not searching for the right thing. Please help!
Edit:
From windbag, I get this call stack.
combase!RoFailFastWithErrorContextInternal2(HRESULT hrError = 0xaaaaaaaa, unsigned long cStowedExceptions = 0xaaaaaaaa, struct _STOWED_EXCEPTION_INFORMATION_V2 ** aStowedExceptionPointers = 0xaaaaaaaa)+0x10a [d:\blue_gdr\com\combase\winrt\error\error.cpp # 1035]
combase!RoFailFastWithErrorContextInternal(HRESULT hrError = 0xaaaaaaaa, unsigned long cStowedExceptions = 0xaaaaaaaa, struct _STOWED_EXCEPTION_INFORMATION_V1 ** aStowedExceptionPointers = 0xaaaaaaaa)+0x10b [d:\blue_gdr\com\combase\winrt\error\error.cpp # 948]
kernel32!BaseThreadInitThunk+0xe
ntdll!__RtlUserThreadStart+0x20
ntdll!_RtlUserThreadStart+0x1b
ok, with the help of the Windbg Extension PDE.dll from Andrew Richards, I see that your application crashes because of an not handled System.UnauthorizedAccessException.
I used !PDE.dpx -dse to shows all Stowed Exceptions (those 0xC000027B exceptions):
0:006> !PDE.dpx -dse
Start memory scan : 0x0551fc7c ($csp)
End memory scan : 0x05520000 (User Stack Base)
0x0551fc94 : 0x012db914 : !dse combase!STOWED_EXCEPTION_INFORMATION_V1
0x0551fcdc : 0x0163c168 : !dse combase!STOWED_EXCEPTION_INFORMATION_V1
Now I use !PDE.dse to display its data:
0:006> !PDE.dse 0551fc94
Stowed Exception Array # 0x0551fc94
Stowed Exception #1 # 0x012db914
0x80070005 (FACILITY_WIN32 - Win32 Undecorated Error Codes): E_ACCESSDENIED - General access denied error
Stack : 0x163c528
770ba9f1 combase!RoOriginateLanguageException+0x3b
6f137872 clr!SetupErrorInfo+0x1e1
6f1fbc91 clr!MarshalNative::GetHRForException_WinRT+0x7d
>>> Associated CLR Exception <<<
Exception object: 02b424f8
Exception type: System.UnauthorizedAccessException
Message: <Invalid Object>
InnerException: <none>
StackTrace (generated):
SP IP Function
00000000 00000001 UNKNOWN!UNKNOWN+0x2
0551FC58 015702E9 CryptoQuoteW8cs!UNKNOWN+0x81
0551FC6C 01570251 CryptoQuoteW8cs!UNKNOWN+0x11
StackTraceString: <none>
HResult: 80070005
0:006> !PDE.dse 0163c168
Stowed Exception Array # 0x0163c168
Stowed Exception #1 # 0x012db914
0x80070005 (FACILITY_WIN32 - Win32 Undecorated Error Codes): E_ACCESSDENIED - General access denied error
Stack : 0x163c528
770ba9f1 combase!RoOriginateLanguageException+0x3b
6f137872 clr!SetupErrorInfo+0x1e1
6f1fbc91 clr!MarshalNative::GetHRForException_WinRT+0x7d
>>> Associated CLR Exception <<<
Exception object: 02b424f8
Exception type: System.UnauthorizedAccessException
Message: <Invalid Object>
InnerException: <none>
StackTrace (generated):
SP IP Function
00000000 00000001 UNKNOWN!UNKNOWN+0x2
0551FC58 015702E9 CryptoQuoteW8cs!UNKNOWN+0x81
0551FC6C 01570251 CryptoQuoteW8cs!UNKNOWN+0x11
StackTraceString: <none>
HResult: 80070005
Stowed Exception #2 # 0x01639748
0x80070005 (FACILITY_WIN32 - Win32 Undecorated Error Codes): E_ACCESSDENIED - General access denied error
Stack : 0x69d29c4
6d33bd5e Windows_UI_Xaml!DirectUI::Application::MainASTAInitialize+0xa9
6d33bb05 Windows_UI_Xaml!DirectUI::FrameworkView::Initialize+0x5a
6dc5a597 twinapi_appcore!Windows::ApplicationModel::Core::CoreApplicationView::CreateAndInitializeFrameworkView+0xa7
6dc5a6eb twinapi_appcore!Windows::ApplicationModel::Core::CoreApplicationView::CreateAndInitializeFrameworkView+0x1fb
74b2a83a SHCore!Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<2>,CScalingInfoBase,Microsoft::WRL::FtmBase,Microsoft::WRL::Details::Nil,Microsoft::WRL::Details::Nil,Microsoft::WRL::Details::Nil,Microsoft::WRL::Details::Nil,Microsoft::WRL::Details::Nil,Microsoft::WRL::Details::Nil,Microsoft::WRL::Details::Nil>::`vector deleting destructor'+0x189
772c919f kernel32!BaseThreadInitThunk+0xe
775a0bbb ntdll!__RtlUserThreadStart+0x20
775a0b91 ntdll!_RtlUserThreadStart+0x1b
Here you can see that the underlaying issue is the System.UnauthorizedAccessException. The dmp is only a minidump, so I can't see what CryptoQuoteW8cs!UNKNOWN+0x81 does.
Use the Application.UnhandledException event to handle exception that you have not handled via try/catch to prevent the app from crashing.
Here is a good guide on how to handle exceptions:
Strategies for Handling Errors in your Windows Store Apps

How to include libsodium.net on ASP.NET

I have an old webservice build on ASP.NET (using .asmx) files. I need to use sodium.net - unfortunately it fails while loading the dependent libsodium.dll file. Any ideas about what I make wrong?
I have added libsodium.net through NuGet.
I have renamed the 64 bit DLL to "libsodium.dll" (and other naming conventions too).
I have tried to reference libsodium.dll directly but VS rejects it (not a valid DLL). So I have added it as "content" instead with "copy to output".
After building I can see that the website/Bin folder contains both sodium.dll (the .NET assembly) and libsodium.net.
When I try to use libsodium.net I get:
ERROR 2015-02-02 11:14:27,118 13798ms [41] CabinetService doRequest - Caught: The type initializer for 'Sodium.SodiumCore' threw an exception.
System.TypeInitializationException: The type initializer for 'Sodium.SodiumCore' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'libsodium.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at DynamicDllInvokeType.sodium_init()
at Sodium.SodiumCore..cctor()
--- End of inner exception stack trace ---
at Sodium.SodiumCore.LibraryName()
at Sodium.SecretBox.Create(Byte[] message, Byte[] nonce, Byte[] key)
at Macaroons.SecretBoxCryptoAlgorithm.Encrypt(Byte[] key, Byte[] plainText) in c:\Projects\Macaroons.Net\Macaroons.Net\SecretBoxCryptoAlgorithm.cs:line 58
So it cannot find "libsodium.dll" even though it is in the Bin folder. I did also try to remove the dependency on "sodium.net" where after I got a runtime error saying "sodium.net" is missing - when I re-added it, that error disappeared and I got the one above instead (indicating the "sodium.net" loads correctly).
So I open up the website shadow folder in "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\cabinetservice" and search for "sodium". The only result is "sodium.dll" in some subfolder. There is no "libsodium.dll".
So apparently ASP.NET ignores the "libsodium.dll" file when creating the shadow copy of the website.
I have also tried adding the libsodium.dll (32 bit) to C:\Windows\System32 and libsodium.dll (64 bit) to C:\Windows\SysWOW64. Same result.
And I have tried C:\Windows\Microsoft.NET\assembly\GAC_32\libsodium and C:\Windows\Microsoft.NET\assembly\GAC_64\libsodium. Same result.
How can I make ASP.NET aware of the dependency?
It turns out that ASP.NET doesn't make shadow copies of unmanaged DLLs such as libsodium.dll and libsodium-64.dll.
Sodium.dll (the managed code) tries to load the DLLs from either the same directory as the shadow copy of Sodium.dll (which is not going to work) - or some where in the PATH environment variable's directories.
My solution was to add the AppDomain \Bin directory to the path before calling any Sodium code:
// Make it possible to load unmanaged libsodium DLLs that .NET does not make shadow copies of.
// -> Simply point the "path" variable to the Bin directory.
string path = Environment.GetEnvironmentVariable("PATH");
string binDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Bin");
Environment.SetEnvironmentVariable("PATH", path + ";" + binDir);
Update January 2018 (from Jordan Rieger's answer):
Note that you may also need to install the Microsoft Visual C++ 2015
Redistributable on your server (either the x64 or x86 target,
depending on your process.)
Don't forget to restart your app pool (I did an IIS reset) after
installing the redistributable.
Note that you may also need to install the Microsoft Visual C++ 2015 Redistributable on your server (either the x64 or x86 target, depending on your process.)
Don't forget to restart your app pool (I did an IIS reset) after installing the redistributable.
See my comment on https://stackoverflow.com/a/45078280/284704.

Allowing partially trusted callers security exception is been thrown althought running on Full trust mode

While developing using ASP.net 2.0 (C#) and NHibernate 2.1.0
I am getting the error:
System.TypeInitializationException: The type initializer for 'NHibernate.ByteCode.LinFu.ProxyFactory' threw an exception. ---> System.Security.SecurityException: That assembly does not allow partially trusted callers.
This error is been thrown only in the production server (a web hosting company) and in my development environment everything is fine.
I also ran this code below on the production server to see the Code Access Security (CAS) level and got True from:
System.Security.SecurityManager.IsGranted(new AspNetHostingPermission(AspNetHostingPermissionLevel.Unrestricted))
so I can assume I am currently running in a full trusted mode..
After reading some articles about this kind of problem (not specifically for NHibernate)
I understood that I need to add
[assembly: AllowPartiallyTrustedCallers()]
to my AssebmlyInfo.cs file.
My question is:
Is there a way to solve this exception without having to edit the NHibernate.ByteCode.LinFu.dll's AssmeblyInfo.cs ? Is there something that can be configured in the web.config to allow this kind of action?
Thanks,
Tal.
Have you tried the steps called out here?
Using NHibernate in a Medium Trust web environment

Categories

Resources