Hello Todor!
[quoted text, click to view] > I read the book "Customizing the MS .NET Framework CLR" By Steven
> Pratschner.
You too? ;-)
[quoted text, click to view] > What I am missing is, how does the host interact with the managed
> code in the hosted CLR? How does the host create instances
Starting from the ICorRuntimeHost interface, you have to get the _AppDomain
instance. The Domain may be the DefaultDomain
(ICodeRuntimeHost.GetDefaultDomain), or you may start a new AppDomain
(CreateDomain(Ex), ...)
[_AppDomain]
http://msdn2.microsoft.com/en-us/library/system._appdomain.aspx When you have the _AppDomain instance, you can use all Methods like
"CreateInstance", or "CreateInstanceFrom" to create Objects.
[_AppDomain.CreateInstance]
http://msdn2.microsoft.com/en-us/library/system._appdomain.createinstance.aspx [_AppDomain.CreateInstanceFrom]
http://msdn2.microsoft.com/en-us/library/system._appdomain.createinstancefrom.aspx [quoted text, click to view] > and invoke
> methods on those instances?
Maybe there are other methods, but I am only aware of one way to do this:
You should make the Objects that you have to call from the unmanaged world
COM-Visible. Then you can call methods using COM (as done within the CLR
itself). I do not know how the SQL-Server integration has been managed.
[quoted text, click to view] > How does the host gets reply from the
> CLR?
If I understand you correclty, you meen how the unmanaged Code gets
Methodcalls, Data, ... from the managed Code? Well, it's just a matter of
the Object-Model. If you have the ability to create objects, and call
methods (with parameters) from this object, you have everything you need.
If the managed Code should invoke unmanaged methods, you sould implement an
COM-based "Context" Object which is passed to the managed Object as an
Parameter. When the managed Code calls Methods from the Context-Object, it
calls the unmanaged Code via COM Interop.
With a proper Object-Model on the managed side, you can hide awai all this
unamanged / COM Stuff from the implementor of the managed Components (if
this is part of a bigger project).
[quoted text, click to view] > And how does the CLR communicates to the host, if a callback is
> needed?
What kind of callback to you meen?
:: GP