Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / December 2003

Tip: Looking for answers? Try searching our database.

Difference between CCW and CLR hosting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GV - 08 Dec 2003 09:16 GMT
Hi.

What is the difference between these two approaches?
My thought is that CCW automatically loads the runtime, with default
settings, while with CLR hosting you have control over each step of
the runtime loading (type of GC and so on).

Am I right?

Have a nice day
GV
Dino Viehland [MS] - 17 Dec 2003 19:50 GMT
I think you've done a good job of outlinging some
differences between the two features.  What I'd like to
point out is that these two features are often
complimentary, and if you're hosting the runtime you'll
be using both of them.

So for example if you host the runtime any CCW's you use
after you've loaded the runtime will use the runtime that
you loaded with your hosted configuration.  You'll also
be using CCW's throughout the hosting process to get to
the point where you run managed code.  For example, when
you make calls on an _AppDomain object in unmanaged code
you'll be calling through a CCW.

I'd also point out that if you loaded a CCW into your
process, and then attempted to host the runtime, that
you're not going to be able to load the runtime via the
hosting APIs anymore (because the runtime is already
loaded).  If you attended the PDC and picked up the
Whidbey bits you'll see a new API called LockClrVersion
which allows a host to load the runtime before any other
managed code gets run.  So for example if someone tried
to create a CCW in your process the host would be asked
to start the runtime first.

Finally, I'd like to point out that you might be able to
get some of the same control via config files that you
could over hosting.  Certainly the hosting APIs give you
more thorough control, but there is some overlap in what
is exposed through config files.  Unfortunately I'm not
sure whether or not you can have config files associated
with CCWs, but I imagine you could (sorry, I'm much more
familiar with the hosting side than the CCW side of
things).

Hopefully this helps :)

>-----Original Message-----
>Hi.
[quoted text clipped - 9 lines]
>GV
>.
Gianluca Varenni - 18 Dec 2003 19:42 GMT
> I think you've done a good job of outlinging some
> differences between the two features.  What I'd like to
[quoted text clipped - 9 lines]
> you make calls on an _AppDomain object in unmanaged code
> you'll be calling through a CCW.

But in this case the runtime is already loaded. Am I correct?

> I'd also point out that if you loaded a CCW into your
> process, and then attempted to host the runtime, that
[quoted text clipped - 6 lines]
> to create a CCW in your process the host would be asked
> to start the runtime first.

Quite interesting. I think that CCW and CLR is sometimes confusing. I do not
have access to Whidbey (at the moment), but I have a copy of Longhorn, so
I'll have a look at it. Is this API documented on the longhorn SDK on the
web?

> Finally, I'd like to point out that you might be able to
> get some of the same control via config files that you
[quoted text clipped - 5 lines]
> familiar with the hosting side than the CCW side of
> things).

Since you are "familiar" with CLR hosting, and maybe you are the right
person to ask, why don't you (=MSFT) add some more documentation about CLR
hosting? I haven't checked the Longhorn SDK, but the .NET 1.1 SDK
documentation is quite poor in this field (and this somewhat strange, since
there is a lot of stuff related to managed-unmanaged interaction).

Have a nice day
GV

> Hopefully this helps :)
>
[quoted text clipped - 13 lines]
> >GV
> >.
"Dino Viehland [MS]" - 19 Dec 2003 17:19 GMT
>> So for example if you host the runtime any CCW's you use
>> after you've loaded the runtime will use the runtime that
[quoted text clipped - 3 lines]
>> you make calls on an _AppDomain object in unmanaged code
>> you'll be calling through a CCW.

> But in this case the runtime is already loaded. Am I correct?

Yes, after you've loaded the runtime via the hosting interfaces you'll then
be using the CCWs to call into the runtime.

>> I'd also point out that if you loaded a CCW into your
>> process, and then attempted to host the runtime, that
[quoted text clipped - 11 lines]
> I'll have a look at it. Is this API documented on the longhorn SDK on the
> web?

Unfortunately we haven't released our documentation for this feature yet
(or any of the new hosting interfaces).  It's a fairly simple API, and I'll
give you a quick description here.  In mscoree.h you'll find the definition
of LockClrVersion.  It takes 3 parameters, 1 function pointer, and 2
pointers to function pointers.   You pass in a call back (hostCallback).  
mscoree will pass you back the begin/end setup pointers.  mscoree will call
hostCallback when someone wants to use managed code.  During the callback
the host performs the normal hosted CLR startup, but before they start the
runtime they call the passed in pBeginHostSetup callback, and when they're
done they call the pEndHostSetup callback.  The callbacks & the starting of
the runtime all need to occur on the same thread (this is how we know
you're the one who should be starting the runtime, and that someone else
isn't trying to sneak by it).

You'll find that the callback function (FLockCllrVersionCallback)  is
defined in mscoree as well, takes no parameters, and returns an HRESULT.  
You'll want to return success (eg, S_OK, S_FALSE, etc...) from the callback
to allow managed code to run, or failure if you don't want to allow it to
run.

> Since you are "familiar" with CLR hosting, and maybe you are the right
> person to ask, why don't you (=MSFT) add some more documentation about CLR
> hosting? I haven't checked the Longhorn SDK, but the .NET 1.1 SDK
> documentation is quite poor in this field (and this somewhat strange, since
> there is a lot of stuff related to managed-unmanaged interaction).

I think the best documentation on this that we have today is
http://www.gotdotnet.com/team/clr/about_clr_Hosting.aspx.  There's white
papers, specs on the interfaces, etc...  I don't know if this is included
in the SDK or not (and if not, why not), but I can bring this up to the PM
in charge of this area.  Have you seen this web page before?  Do you think
it gives a good description of the hosting?  Or is there more that you'd
like to hear about?  And if so, what?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.