Questions tagged [clr-hosting]

CLR hosting means enabling a native process to execute managed code by using .NET runtime library dll that actually executes the managed code. Such native process said to "host" CLR, .NET Common Language Runtime, then in the hosted runtime the native process can execute any CLR assemblies.

CLR hosting means enabling a native process to execute managed code by using .NET runtime library dll that actually executes the managed code. Such native process said to "host" CLR, .NET Common Language Runtime, then in the hosted runtime the native process can execute any CLR assemblies.

Stack Overflow link: What is CLR hosting?

MSDN documentation:

So far, there are 3 different versions of CLR hosting for each major release of CLR: 4.0: https://msdn.microsoft.com/en-us/library/dd380851(VS.100).aspx

2.0: (Covers .NET 2.0/3.0/3.5):     https://msdn.microsoft.com/en-us/library/9x0wh2z3.aspx

1.1: https://msdn.microsoft.com/en-us/library/9x0wh2z3(v=vs.71).aspx

Books:

There is also a good book on this subject (but it mostly covers 2.0 hosting APIs):  "Customizing the Microsoft .NET Framework Common Language Runtime" from Steven Pratschner.

54 questions
3
votes
2 answers

Injecting a CLR host into a running process - possible?

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…
Erik Forbes
  • 35,357
  • 27
  • 98
  • 122
3
votes
2 answers

How to limit a memory that can be allocated by a specific class?

I'm loading several external assemblies into my application at runtime. And I need to limit an amount of memory that can be used by a specific class which is defined in each of the external assemblies, for example, 10 mb per instance, otherwise we…
Andrey
  • 5,906
  • 4
  • 24
  • 30
3
votes
1 answer

Hosting CLR - Bad parameters

I'm trying to host the CLR inside my C++ application and I'm having problems invoking the entry point of the managed application. The entry point is defined as usual: static void Main(string[] args) And here's the actual C++…
arul
  • 13,998
  • 1
  • 57
  • 77
3
votes
1 answer

What/Where is the value of E_CLR_ALREADY_STARTED?

The docs for ICLRRuntimeHost::SetHostControl claim that it can return E_CLR_ALREADY_STARTED. I have been unable to find a definition for this value. Ideally, I'd like to know what the appropriate header to include is (it does not appear to be in…
Logan Capaldo
  • 39,555
  • 5
  • 63
  • 78
3
votes
2 answers

Allow managed code in hosted environment to call back unmanaged code

I have C++ code that hosts a clr in order to make use of Managed.dll, written in c#. This .net has a method like the following that allows code to register for notification of events: public void Register(IMyListener listener); The interface looks…
Evgeniy Berezovsky
  • 18,571
  • 13
  • 82
  • 156
3
votes
2 answers

How can two .NET CLR loaded in the same process talk to each other?

Now that it is possible to have two CLRs running on the same box, how could they 'talk' to each other? Let's say that the GUI is running under .NET 2.0 CLR and there is a script running on the .NET 4.0 CLR, for example, is there a way to modify the…
Dinis Cruz
  • 4,161
  • 2
  • 31
  • 49
2
votes
1 answer

Hosting CLR in native - COM interfaces, unresolved external symbol _CStdStubBuffer_Release@4

I'm experimenting with hosting CLR (not trying to use mono for now, though I will probably try). Basically, I'm following this: http://www.lenholgate.com/blog/2010/07/clr-hosting---a-flexible-managed-plugin-system-part-1.html However, I've got some…
Bartosz
  • 3,318
  • 21
  • 31
2
votes
5 answers

A SQL Server function to generate of sequential numbers

I would like to have a SQL Server function dbo.GetNextNumber(), which would generate sequential numbers for each call. As far as I understand this is impossible with a native T-SQL function as SQL Server insists the functions has to be…
Kemal Erdogan
  • 1,060
  • 1
  • 9
  • 19
2
votes
1 answer

CLR4 Hosting Interface is causing Heap Corruption?

I'm working with native CLR hosting for some weeks now. In the beginning it worked pretty well. But later on I've noticed that something in my application causes heap corruption. I've figured out that this is caused by the CLR startup. (See…
Christoph Meißner
  • 1,511
  • 2
  • 21
  • 40
2
votes
0 answers

Providing an Action or EventHandler from unmanaged code

I'm working with the JEDI Code Library to host a CLR for using C# code in Delphi. Using the TJclClrHost this works pretty good, for the common cases. However, now I'm in the situation where I'd like to register to an event in C# code. There are…
Florian Koch
  • 1,372
  • 1
  • 30
  • 49
2
votes
0 answers

Hosting .NET CLR in C++ app: Sandboxed app domain (CAS)

TL;DR; How do I create a sandboxed AppDomain (configuring CAS) from a C++ app? Long version: I'm hosting the .NET CLR in a C++ app and everything is working fine... However, my AppDomain has full trust, and I'd like to have a more granular control…
C. Augusto Proiete
  • 24,684
  • 2
  • 63
  • 91
2
votes
1 answer

CLRProfiler not connecting to CLR when hosted

I have a native Win32 application that hosts the CLR to use C# as a sophisticated 'scripting' language. I've got a memory leak and I decided to try Microsoft's CLR Profiler to investigate. (I'm not sure if the leak is managed or not and was hoping…
Kevin
  • 1,179
  • 7
  • 18
2
votes
2 answers

CLR hosting. Howto enumerate _AppDomains in .net 4

I have unmanaged dll written in C, that will be injected into managed application (dotNet 4). I am going to enumerate _AppDomains, running in this app to load some module into domain. It is available to do this using ICorRuntimeHost interface.…
Viacheslav Kovalev
  • 1,745
  • 12
  • 17
2
votes
1 answer

Hosting CLR Runtime in C++

I am working on an extension for a project that will allow hosting the CLR inside the core application. With this I plan to allow this extension to manage managed extensions that it loads/unloads inside itself. That being said, I need to use…
atom0s
  • 485
  • 6
  • 22
2
votes
2 answers

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

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, …
David Brown
  • 35,411
  • 11
  • 83
  • 132