If you are calling an external IUnknown interface, then you will need to define every method that procedes the methods you will call. You must define the methods in the order in which they appear in the IDL or .H file, not in the order they appear in the documentation (which is usually alphabetized).
If the external COM component is calling your interface, then you will want to define every method, because you never know which methods the external component will call. As a rule of thumb, I always define every method to eliminate one more potential cause of interop failure. Note that you must not define the IUnknown methods. These will be provided by the CLR. You will probably want to look at the Docs for Marshaling data [1]. Examples for marshaling structures that point to other structures are here: [2]. -- Peter [1] http://msdn.microsoft.com/library/en-us/cpguide/html/cpconmarshalingdatawith platforminvoke.asp?frame=true [2] http://msdn.microsoft.com/library/en-us/cpguide/html/cpconstructssample.asp? frame=true Erick Thompson spake: > > After beating around a number of bushes, I've decided to jump into interop > with both feet. So, I'm trying to put together code to let me use IFilter > via LoadIFilter. Do I need to write RCW method signatures for all the > methods of an interface, or only the ones I am interested > in/going to call? > > Thanks, > Erick > > ----- Original Message ----- > From: "Peter Stephens" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, May 09, 2002 3:05 PM > Subject: Re: [DOTNET] Using IFilter interface from C# > > > > > Erick Thompson spake: > > > > > > How would I go about using the IFilter[1] interface from C#? > From what I > > > gather, it's not an automation interface (== not a COM object?), > > > so I'm not > > > sure where to start. > > > > > > Thanks, > > > Erick > > > > > > [1] > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/i > > ndexsrv/ixrefint_9sfm.asp > > > > > > If there is a type library, you could use the tlbimp utility to > generate a > > proxy assembly. > > > > If there is no type library, you can create your own Runtime Callable > > Wrappers (RCWs). > > > > Here is an RCW for IClassFactory: > > > > ===> > > [ComVisible(true)] > > [Guid("00000001-0000-0000-c000-000000000046")] > > [CLSCompliant(false)] > > [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] > > public interface IClassFactory > > { > > [PreserveSig] > > Int32 CreateInstance( > > IntPtr pUnkOuter, > > [In] ref Guid refiid, > > IntPtr ppvObject); > > void LockServer( > > [MarshalAs(UnmanagedType.Bool)] Boolean fLock); > > } > > <=== > > > > And here is an RCW for IPersistStreamInit: > > ===> > > [ComVisible(true)] > > [Guid("7fd52380-4e07-101b-ae2d-08002b2ec713")] > > [CLSCompliant(false)] > > [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] > > public interface IPersistStreamInit > > { > > void GetClassID(out Guid pClassID); > > [PreserveSig] > > Int32 IsDirty(); > > void Load(IStream stream); > > void Save(IStream stream, > [MarshalAs(UnmanagedType.Bool)] Boolean > > fClearDirty); > > UInt64 GetSizeMax(); > > void InitNew(); > > } > > <=== > > > > If you call a DLL routine to get your interface pointer, setup your > p/invoke > > as follows: > > // P/Invoke functions > > [DllImport("urlmon.dll")] > > private static extern Int32 CoInternetGetSession( > > UInt32 dwSessionMode, > > ref IInternetSession ppIInternetSession, > > UInt32 dwReserved); > > > > -- > > Peter You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.