Pete, what does supporting IDispatch have to do with RegAsm?  You lost me on
that one.

I think Allan was showing off IDispatch specifically to support your
cant-create-any-regkeys requirement.  If you asked for a custom interface,
it might need to be registered under HKCR/Interfaces, in order to support
COM standard marshalling.

The proxy/stub clsid for IDispatch is already registered, so no worries.
Right?

-S


-----Original Message-----
From: Pete Moss [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 10, 2004 11:29
Subject: Re: Calling managed C++ code from an unmanaged MFC app

Allan,

Thanks for the reply.

Keep in mind that the whole point of this exercise is to eliminate the
requirement to have Admin privileges for an installation (see original
post). If I understand your response, it seems to violate this requirement
on 2 accounts:
1) If I place an assembly in the GAC, does that not require Admin
privileges to run GACUTIL to install the assembly?
2) Your code snippet of using ClrCreateManagedInstance() seems to imply
that I would support IDispatch on my object.  If I did that, would I not
have to register the Assembly using REGASM?  If so, that would again
violate the no Admin requirement.

I am trying to figure out a way to write a managed C++ DLL to bridge the
gap between my unmanaged MFC code and my C# Assembly and achieve xcopy
deployment bliss ;)

I thought I was on to something by creating a set of global C-style
functions in a managed C++ DLL that I am able to call from my MFC app.
Under the covers, these functions create and manage an unmanaged C++
class. This class contains gcroot<> wrappers to instances of my managed
code classes. This was actually looking promising until I started to try
to sink events fired from my C# code. I am tying myself up in knots trying
to get anything to work. I feel like I am running out of steam...

Thanks for your help, and I'm open to any and all suggestions,
Pete

On Tue, 10 Feb 2004 07:21:30 -0500, Allan N. <[EMAIL PROTECTED]> wrote:

>Hi,
>>>I can't use ClrCreateManagedInstance() since that would be used to
>create COM objects in a managed DLL, and that is what ><I am trying to
>avoid. (This assumes I understand the signature of
ClrCreateManagedInstance
>()).
>small modification on that one :
>
>you use this undocumented api to create an instance of a managed class
>directly in your unmanaged code.
>
>The ClrCreateManagedinstance takes a ~fully qualified name~ of your
>assembly....remember that, otherwise you get HRESULT 0x80070002 which
>is "The system cannot find the file specified". Do your self a favor an
>place your assembly in the GAC.
>
>...example on how to create an instance of SomeClass, you need to include
>the mscoree.h header file.
>
>
> CComPtr<IDispatch> pDisp;
> HRESULT hr = S_OK;
> hr = ClrCreateManagedInstance(L"Namespace.SomeClass,Namespace,
>Version=1.5.0.1, Culture=neutral,
>PublicKeyToken=f09ae53443459c4e",IID_IDispatch, (void**)&pDisp);
>
> OLECHAR FAR* szMember = L"Hallo"; //call the Hallo method, I know this is
>complex stuff but bare with me here.
> DISPID dispid;
> DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
>
> //Retrieve the DISPID
> pDisp->GetIDsOfNames (IID_NULL,
>        &szMember,
>        1,
>        LOCALE_SYSTEM_DEFAULT,
>        &dispid);
>
> //Invoke the method on the Dispatch Interface
> pDisp->Invoke(dispid,
>      IID_NULL,
>      LOCALE_SYSTEM_DEFAULT,
>      DISPATCH_METHOD,
>      &dispparamsNoArgs,
>      NULL,
>      NULL,
>      NULL);
>
>it's undocumented as Shawn said, so putting this in production code seems
>like a good idea :)
>
>Note: if the namespace.class you are trying to create an instance of in
>your unmanaged code also has dependencies on other assemblies or uses com-
>interop, remember to place them in the GAC also, otherwise you will get
>the 0x80070002.
>
>cheers, Allan
>
>===================================
>This list is hosted by DevelopMentorR  http://www.develop.com
>Some .NET courses you may be interested in:
>
>NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles
>http://www.develop.com/courses/gaspdotnetls
>
>View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentorR  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to