clr-hosting

hosting clr and catching threading exceptions

醉酒当歌 提交于 2020-01-01 02:04:07
问题 I am trying to write an plugin system that can load managed plugins. The host should be able to unload the plugins if there are any exceptions. for my poc I have a sample code library in C# that throws an exception like this ... public static int StartUp(string arguments) { Console.WriteLine("Started exception thrower with args {0}", arguments); Thread workerThread = new Thread(() => { Console.WriteLine("Starting a thread, doing some important work"); Thread.Sleep(1000); throw new

error C2440: 'function' : cannot convert from 'const IID' to 'DWORD'

Deadly 提交于 2019-12-20 03:49:12
问题 While trying to host the CLR, I keep getting this: error C2440: 'function' : cannot convert from 'const IID' to 'DWORD' My code: ICLRRuntimeHost *host = NULL; HRESULT result = CorBindToRuntime(NULL, L"wks", CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (PVOID*)&host); This is in C, by the way. Not C++. EDIT: When I compile this with C++, it works just fine. Shouldn't it behave the same in either language? 回答1: From guiddef.h: #ifndef _REFIID_DEFINED #define _REFIID_DEFINED #ifdef __cplusplus

Injecting a CLR host into a running process - possible?

半腔热情 提交于 2019-12-12 13:16:53
问题 This way lies madness, I know. I have an executable (the source code to which I do not have access) that I would like to extend via .NET. It's a native executable, so I would need to inject a CLR host in order to do this. My basic idea is to provide scripting-like functionality via a .NET language (C#, for example) and provide hooks in the target executable for the scripts to manipulate, and vice versa. I know I'll need to use various techniques to achieve this - DLL injection, some runtime

How to tell what version of the .NET CLR is loaded by a running application on XP?

岁酱吖の 提交于 2019-12-08 06:56:37
问题 I know that there are managed shell extensions loaded by explorer.exe on a computer. I want to know what version of the CLR is loaded into explorer.exe. If I am running Vista or Win7, I can use Process Explorer and look at the .NET Assemblies tab of the properties for explorer.exe. However, this doesn't work on XP. Is there a way to get this info on XP? 回答1: Doesn't Process Explorer also show the the DLLs that have been loaded? Look for mscorwks.dll in that list, and see where it's being

Can AppDomainManager be loaded by ProvideAssembly from a CLR Host?

走远了吗. 提交于 2019-12-07 15:44:42
问题 I have an application hosting the .net clr with a custom AppDomain Manager and an AssemblyManager with a store. This all works fine when the Assembly with the AppDomainManager in is a dll in the same directory as the executable. What I want to do is embed the Managers assembly inside the executable. When I do this ProvideAssembly is called with the correct strong name, I return a stream with the assembly bytes, but ICLRRuntimeHost->Start() returns an error indicating that a type cannot be

Can AppDomainManager be loaded by ProvideAssembly from a CLR Host?

匆匆过客 提交于 2019-12-06 02:06:31
I have an application hosting the .net clr with a custom AppDomain Manager and an AssemblyManager with a store. This all works fine when the Assembly with the AppDomainManager in is a dll in the same directory as the executable. What I want to do is embed the Managers assembly inside the executable. When I do this ProvideAssembly is called with the correct strong name, I return a stream with the assembly bytes, but ICLRRuntimeHost->Start() returns an error indicating that a type cannot be loaded. All the assembly binding details match etc. My questions is, does anyone know if this

CLR hosting exception handling in a non-CLR-created thread

南笙酒味 提交于 2019-12-03 15:37:49
问题 The issue: An unhandled exception in a thread entering the CLR from unmanaged code does not trigger the "normal" unhandled exception CLR processing. In the code below calling CSSimpleObject.GetstringLength() from C++ with "1" throws an exception in the calling thread (non-CLR-created thread), "2" throws an exception in a new Thread() (CLR-created thread). In case "1" CurrentDomain_UnhandledException() is never called. The Application Domain and the process will stay loaded and running, you

hosting clr and catching threading exceptions

人盡茶涼 提交于 2019-12-03 05:35:49
I am trying to write an plugin system that can load managed plugins. The host should be able to unload the plugins if there are any exceptions. for my poc I have a sample code library in C# that throws an exception like this ... public static int StartUp(string arguments) { Console.WriteLine("Started exception thrower with args {0}", arguments); Thread workerThread = new Thread(() => { Console.WriteLine("Starting a thread, doing some important work"); Thread.Sleep(1000); throw new ApplicationException(); } ); workerThread.Start(); workerThread.Join(); Console.WriteLine("this should never print

CLR hosting exception handling in a non-CLR-created thread

青春壹個敷衍的年華 提交于 2019-12-03 05:03:55
The issue: An unhandled exception in a thread entering the CLR from unmanaged code does not trigger the "normal" unhandled exception CLR processing. In the code below calling CSSimpleObject.GetstringLength() from C++ with "1" throws an exception in the calling thread (non-CLR-created thread), "2" throws an exception in a new Thread() (CLR-created thread). In case "1" CurrentDomain_UnhandledException() is never called. The Application Domain and the process will stay loaded and running, you will only get a FAILED. In case "2" (expected behavior) CurrentDomain_UnhandledException() is called. The

error C2440: 'function' : cannot convert from 'const IID' to 'DWORD'

我与影子孤独终老i 提交于 2019-12-02 05:13:35
While trying to host the CLR, I keep getting this: error C2440: 'function' : cannot convert from 'const IID' to 'DWORD' My code: ICLRRuntimeHost *host = NULL; HRESULT result = CorBindToRuntime(NULL, L"wks", CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (PVOID*)&host); This is in C, by the way. Not C++. EDIT: When I compile this with C++, it works just fine. Shouldn't it behave the same in either language? From guiddef.h: #ifndef _REFIID_DEFINED #define _REFIID_DEFINED #ifdef __cplusplus #define REFIID const IID & #else #define REFIID const IID * __MIDL_CONST #endif #endif #ifndef _REFCLSID