Re: hosting the runtime



Lloyd, one of the guys on codebetter is Geoff Appleby who is an Aussie, and
being an Indian, I have friends everywhere (yup there are a lot of indians,
must be some fertility drug). I was having this discussion with Geoff
regards the lifestyle there etc. and in general with my friends - trust me
Aus ain't so bad.

Regards your actual issue hehe :) .. Well, I have used COM heavily under
Windows. So I can tell you how to use it under windows, but the usage
shouldn't be too different under Mac. You might run into platform specific
weirdness though because COM is at a lower level than .NET. I'd first
recommend looking at third party solutions if any have been developed that
allow you to leverage a COM component on a Mac (damn I really want to
program on a Mac someday in my life :-)).

So a COM component has a lot to be told about - more than I can possibly
type here. I'd recommend Inside COM by Don Box.

Straight forward way to instantiate a COM component = CoCreateInstance ==>
Not sure if u have this on a Mac.
Non straightforward way - do what CoCreateInstance does -

Any Com component must export the followign 4 functions -
DllRegisterServer, DllUnregisterServer, DllGetClassObject and
DllCanUnloadNow. Check and see if MSCOREE supports IDispatch - if it does,
your life just got a lot simpler. If it doesn't, no biggie, you can use
DllGetClassObject to get the appropriate class factory. Once you have that,
you can easily create an instance of the interface and call the relevant
functions.

At the very heart of any COM Component are 3 methods that define the
IUnknown interface -

QueryInterface - Do you support interface xxx? If so give me an instance and
increase your reference count.
AddRef - Increase your reference count
Release - Decrease your reference count, if it becomes zero - unload
yourself.

Remember, unlike .NET you are now responsible for destroying what you create
(memory management), thus the AddRef and Release methods. The first
instantiation automatically calls AddRef for you once. I suggest picking up
a good book because it is simply impossible for me to give you a 5 minute
COM tutorial. But do let me know if you have any specific questions.

Also, it is quite possible that someone on a Mac has created third party
libraries that make your life simpler - like on a WinX platform you have VB6
... hehe :). I am unaware of any of those libraries, but I'd certainly google
for 'em if I were u .

- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
----------------------------------------------------------------------------




"Lloyd Dupont" <net.galador@ld> wrote in message
news:OsFWTvUdFHA.584@xxxxxxxxxxxxxxxxxxxxxxx
> thanks sahil!
>
> mmhh...
>
> on the other hand I never used COM interface, I have no idea on how they
> work....
> care writing me a veyr simple C:main() which load an exe?
>
> which compile whi gcc ?!?! :D
>
> I just read your article on 21st centure labor in America! hehe.. many
> indian in Australia as well ;) ..
>
> "Sahil Malik [MVP]" <contactmethrumyblog@xxxxxxxxxx> wrote in message
> news:OqC%239mUdFHA.3376@xxxxxxxxxxxxxxxxxxxxxxx
>> Lloyd, I think what you are looking for is
>> ICLRRuntimeHost::SetHostControl
>>
>> Alternatively, if you wish to ask the CLR to give you more control over
>> resource management, you can use IHostControl::GetHostManager
>>
>> - Sahil Malik [MVP]
>> Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
>> ----------------------------------------------------------------------------
>>
>> "Lloyd Dupont" <net.galador@ld> wrote in message
>> news:uAYb3hUdFHA.228@xxxxxxxxxxxxxxxxxxxxxxx
>>>I would like to host the .NET runtime in my (Objective)C application
>>> I wonder what is the API for that.
>>> I have SDK 2.0, I looked in the hosting the runtime section of it, very
>>> succint.
>>> The only 'relevant' function I found was: CorBindToRuntimeEx
>>> but I still don't know how to launch a given (static) method.....
>>>
>>> any tip?
>>>
>>
>>
>
>


.



Relevant Pages


Loading