Hello,

I am developing a C# wrapper to an existing C++ / COM system. The COM
library is currently frozen. The goal is to eventually migrate the code to
C#, but keep the interface (IServer, ISearch, etc roughly the same).

The interfaces within the IDL for the project contain a number of propget
statements which currently return IDispatch ** types. This causes the
tlbimp program to expose those properties simply as "object" types.

For instance, one interface is like this (pseudo-code)

interface IServer {

 [id(0x0000000f), propget, helpstring("Advanced Search")]
        HRESULT AdvancedSearch([out, retval] IDispatch** pVal);

}

interface ISearch
{
[id(0x0000000f), propput, helpstring("Page Size")]
        HRESULT PageSize([in, retval] long pVal);
[id(0x0000000f), propget, helpstring("Page Size")]
        HRESULT PageSize([out, retval] long* pVal);

}

When the interop assembly is created, IServer looks like:

interface IServer
{
    object AdvancedSearch { get; }
}

This leads to having to write non-intuitive C# code like:

Server s = new ServerClass();
Search src = (Search) s.AdvancedSearch;
src.PageSize = 20;

What I really want is to be able to do more like:

Server s = new ServerClass();
s.AdvancedSearch.PageSize = 20;

So, I manually modified the IDL to look like:

interface IServer {

 [id(0x0000000f), propget, helpstring("Advanced Search")]
        HRESULT AdvancedSearch([out, retval] ISearch** pVal);

}

And compiled it with MIDL.EXE then used tlbimp.exe to create a new RCW.
This then allowed me to use that nice dotted syntax.

My question is: is it safe to do this? Is there anything I should watch
out for or could this cause any problems somehow?

Thank you,
Josh

Note: I've also posted this at
http://groups.google.com/group/microsoft.public.dotnet.framework.interop/browse_thread/thread/9f5d3668c6e2cf12/cda171f720ba4521#cda171f720ba4521

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

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

Reply via email to