IL Rewrite to mscorlib crashing w3wp.exe - asp.net

I have built the IL Rewriter to monitor any file is being opened in ASP.Net WebApp. To do so, I am rewriting IL for a private method called 'Init' in FileStream class in mscorlib. Here, I inject the epilogue/prologue to register a custom callback.
Injection is working fine. Custom callbacks are also getting called whenever a file is getting opened in Windows Application.
But, when I do the same for ASP.Net web application, it keeps crashing with the following error -
System.ExecutionEngineException was unhandled
Message: An unhandled exception of type 'System.ExecutionEngineException' occurred in System.Web.dll
I don't understand if it is working fine with .Net-based Desktop Application, then why it does not work with .Net-based web application i.e. ASP.Net. What is the difference between Web and desktop application?
Googled for above error does not yield any solution :(

Related

IIS Blazor JS Error CircuitOptions.DetailedError

I have a problem with deployment of my project on IIS.
In visual studio 2019 everything work properly but when i send it to server, blazor part stop working.
I received Error from web browers:
Error: There was an unhandled exception on the current circuit, so this circuit will be terminated. For more details turn on detailed exceptions by setting 'DetailedErrors: true' in 'appSettings.Development.json' or set 'CircuitOptions.DetailedErrors'.
blazor.server.js:1 DELETE http://webserver/_blazor?id=fR_6PmknQXUvrw2NAbvt2g 405 (Method Not Allowed)
Error: HttpConnection.transport.stop() threw error 'Error: Method Not Allowed'.
I am little confused.
Project is asp.net MVC .net Core 3.
OK, I finded solution.
I instaled Http Activation for .net Framework 3.5.

How prevent CefSharp crash from killing my main Application on Winforms

I have a simple Winforms application.
I've added a ChromiumWebBrowser control on my Form and I'm navigating on various pages.
For unknown reasons, an exception is thrown from Chromium which causes my app to crash
CefSharp.BrowserSubprocess.exe Description: The process was terminated
due to an unhandled exception.)
Is there a way for me to somehow handle that error so my app doesn't crash?
(and maybe reload the current page)

How to Debug Com dll (accessed through Interop) in IIS 7.0( Windows Server 2008 R2) invoked from ASPX Page using VB 6.0

Can anybody tell how to debug the Com Dll in IIS 7.0 using VB 6.0 in Windows Server 2008 R2.
I am able to hit break point in VB 6.0 accessed from Console Application using interop dlll.Through ASPX pages in IIS 7.0 I am getting the following Exception
Unable to cast COM object of type 'XCreateUser.XAcctUserProfileClass'
to interface type 'XCreateUser._XAcctUserProfile'. This operation
failed because the QueryInterface call on the COM component for the
interface with IID '{7A48FABA-CCC8-4FA6-94E8-803F6CF121F2}' failed due
to the following error: Error loading type library/DLL. (Exception
from HRESULT: 0x80029C4A
Already DLL built and registered and com interop dll generated.
Please somebody show some light on this
Already DLL built and registered
"Registered" is the problem here, it wasn't correctly registered. This is an exception message that's generated by the CLR when it tries to locate the proxy for a .NET component that is [ComVisible]. A proxy is required to make a call to a COM component from a worker thread that doesn't do anything to help make the call thread-safe. A thread that's in the MTA, usually a thread-pool thread.
A .NET component is registered with Regasm.exe. You forgot to use the /tlb argument.
Should be simple to fix. If you still have trouble then SysInternals' Process Monitor is the weapon of choice.
I generally debug these things as you say through a console or windows forms application. You can always add logging to your web app to see what parameters are being passed to it.
Generally errors like the above are setup issues when running on a 64 bit platform and when utilizing 32 bit dlls. One thing to make sure of is that your application pool allows 32 bit applications. In IIS Manager right click on the application pool your website is running under and go to Advanced Settings->Enable 32 bit Applications. Set that to True.
You'll also need to make sure that your 32 bit dll is registered in the 32 bit registry hive. C:\Windows\syswow64\regsvr32 is the version you'll need to use to register this dll.

ASMX web service crashes when using vb6 .dll

I got a new problem while using vb6 dll in my Web Services. When using dll, the object instance is created fine but when I start calling it's method from my service I got this exception:
Server was unable to process request. ---> Unable to cast COM object
of type 'WS_Resevat_DLL.WS_ResevatCLClass' to interface type
'WS_Resevat_DLL._WS_ResevatCL'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{69F1DA59-56D1-47CE-94A4-D681ABECDF80}' failed due to the following
error: No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).
The whole system runs fine when I test it on my computer IIS (I have Windows 7 with IIS 7). The problem starts when I publish it on server (Windows Server 2003 with IIS 6). I'm using asp.net 3.5 web services with SOAP 1.1. The VB dll is from the third part and I sadly can't debug it (the only thing I checked with dll creator is that binary compatability is enabled, I don't know VB at all), but when it runs outside the service (on Win Server 2003) it works fine.
Some explanation bout the types (WS_ResevatCLClass and WS_ResevatCL). In origin the dll has only one type: WS_ResevatCl. But when I look at the dll in component explorer in Visual Studio I see strange things - there is a class called WS_ReservatCLClass and 4 different interfaces: _WS_ResevatCL, WS_ResevatCL, WS_ResevarCL_v0 and WS ResevatCL_v1. And the most strange thing is that I can create instance of one them (WS_ResevatCL) and it drives exactly like an instance of the class.
Are there any significant differences between Win7 and WinServer2003 that can cause the crash with such exception?

PDFCreator and ASP.NET

Has anyone managed to get PDFCreator running on an ASP.NET 2.0 website ?
On my development machine with Visual Studio webserver, it works just fine after following this procedure :
create a com interop dll with tlbimp
reference this dll
write some code to use it
However, when I deploy it to our test server, it fails miserably with this error :
Retrieving the COM class factory for component with CLSID {082391C9-8188-4364-B4FD-66A1524B2097} failed due to the following error: 80070005.
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.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {082391C9-8188-4364-B4FD-66A1524B2097} failed due to the following error: 80070005.
And I can't find this component in DCOMCNFG.msc.
Our server configuration :
Windows 2003
Asp.net 2.0
MS Office XP
PDFCreator 0.9.0
The problem is that IIS process (and so ASP.Net processes) run as the SYSTEM account, wich does not have any printers set up.
You have two options:
1 - Set up the printers for the system account using the article provided by Craig Lebakken
2 - Impersonate the ASP.Net site to use an account wich has the printers set up
The following Microsoft Knowledgebase article describes the problem and a solution:
COM objects fail to print when called from ASP

Resources