[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: IBugTraqProvider2

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: Fri, 17 Oct 2008 11:36:14 +0200

Roger Lipscombe wrote:
> Roger Lipscombe wrote:
>> That C# interop was hand-crafted, so it might not actually be
>> equivalent to what you'd get from using TLBIMP. Particularly, I'm not
>> sure about deriving one interface from the other. I'll take a quick
>> look at it today.
> Ah. The reason it's hand-crafted is because MIDL and TLBIMP do strange
> things with the HWND (see below), which make it hard to use from C#; I
> had to change it to use an IntPtr. I've just created a TLB from the
> source IDL and imported that using TLBIMP.
>
> Loading that into "Reflector" gives me this:
>
> [ComImport, InterfaceType((short) 1),
> Guid("C5C85E31-2F9B-4916-A7BA-8E27D481EE83")]
> public interface IBugTraqProvider2 : IBugTraqProvider
> {
> [MethodImpl(MethodImplOptions.InternalCall,
> MethodCodeType=MethodCodeType.Runtime)]
> bool ValidateParameters([In,
> ComAliasName("BugTraqProviderLib.wireHWND")] ref _RemotableHandle
> hParentWnd, [In, MarshalAs(UnmanagedType.BStr)] string parameters);
> [return: MarshalAs(UnmanagedType.BStr)]
> [MethodImpl(MethodImplOptions.InternalCall,
> MethodCodeType=MethodCodeType.Runtime)]
> string GetLinkText([In, ComAliasName("BugTraqProviderLib.wireHWND")]
> ref _RemotableHandle hParentWnd, [In, MarshalAs(UnmanagedType.BStr)]
> string parameters);
> [return: MarshalAs(UnmanagedType.BStr)]
> [MethodImpl(MethodImplOptions.InternalCall,
> MethodCodeType=MethodCodeType.Runtime)]
> string GetCommitMessage([In,
> ComAliasName("BugTraqProviderLib.wireHWND")] ref _RemotableHandle
> hParentWnd, [In, MarshalAs(UnmanagedType.BStr)] string parameters, [In,
> MarshalAs(UnmanagedType.BStr)] string commonRoot, [In,
> MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_BSTR)]
> string[] pathList, [In, MarshalAs(UnmanagedType.BStr)] string
> originalMessage);
> [return: MarshalAs(UnmanagedType.BStr)]
> [MethodImpl(MethodImplOptions.InternalCall,
> MethodCodeType=MethodCodeType.Runtime)]
> string OnCommitFinished([In,
> ComAliasName("BugTraqProviderLib.wireHWND")] ref _RemotableHandle
> hParentWnd, [In, MarshalAs(UnmanagedType.BStr)] string commonRoot, [In,
> MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_BSTR)]
> string[] pathList, [In, MarshalAs(UnmanagedType.BStr)] string
> logMessage, [In] uint revision);
> }
>
> ...so it looks like C# doesn't correctly handle deriving one COM
> interface from the other.
>
> Try this:
>
> [ComVisible(true),
> InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
> Guid("C5C85E31-2F9B-4916-A7BA-8E27D481EE83")]
> public interface IBugTraqProvider2 : IBugTraqProvider
> {
> [return: MarshalAs(UnmanagedType.VariantBool)]
> bool ValidateParameters(IntPtr hParentWnd,
> [MarshalAs(UnmanagedType.BStr)] string parameters);
>
> [return: MarshalAs(UnmanagedType.BStr)]
> string GetLinkText(IntPtr hParentWnd,
> [MarshalAs(UnmanagedType.BStr)] string parameters);
>
> [return: MarshalAs(UnmanagedType.BStr)]
> string GetCommitMessage(IntPtr hParentWnd,
> [MarshalAs(UnmanagedType.BStr)] string parameters,
> [MarshalAs(UnmanagedType.BStr)] string commonRoot,
> [MarshalAs(UnmanagedType.SafeArray, SafeArraySubType =
> VarEnum.VT_BSTR)] string[] pathList,
> [MarshalAs(UnmanagedType.BStr)] string originalMessage);
> [return: MarshalAs(UnmanagedType.BStr)]
> string OnCommitFinished(
> IntPtr hParentWnd,
> [MarshalAs(UnmanagedType.BStr)] string commonRoot,
> [MarshalAs(UnmanagedType.SafeArray, SafeArraySubType =
> VarEnum.VT_BSTR)] string[] pathList,
> [MarshalAs(UnmanagedType.BStr)] string logMessage,
> [MarshalAs(UnmanagedType.U4)] int revision);
> }
>
> If that doesn't work, try it without the ": IBugTraqProvider"

That was it!
Thank you so much - I've really tried and just couldn't get this to work.

Stefan

-- 
       ___
  oo  // \\      "De Chelonian Mobile"
 (_,\/ \_/ \     TortoiseSVN
   \ \_/_\_/>    The coolest Interface to (Sub)Version Control
   /_/   \_\     http://tortoisesvn.net

Received on 2008-10-17 11:36:29 CEST

This is an archived mail posted to the TortoiseSVN Dev mailing list.