Thanks for your very response and excellent answer. I can grok this but why
is this (IDispatch) the default? I know you are just the messenger, but when
are we going to get rid of this VB3 behavior? I should not have to do extra
work to get an early bound interface out of COM Interop. This should be the
default case as everything but Scripting handles vtable interfaces
correctly. I should get an early bound interface automatically and have to
do extra work to do the "wrong" thing - IDispatch. Failing that, the default
behavior should be that it generates both.


>From: "Adam Nathan" <[EMAIL PROTECTED]>
>To: "Sam Gentile" <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
>Subject: RE: COM Interop: Not seeing COM Interfaces in OLEVIEW after
>regasm?
>Date: Tue, 2 Apr 2002 12:22:45 -0800
>MIME-Version: 1.0
>Received: from [131.107.3.126] by hotmail.com (3.2) with ESMTP id
>MHotMailBE735E66002540042A14836B037E528B0; Tue, 02 Apr 2002 12:24:06 -0800
>Received: from inet-vrs-06.redmond.corp.microsoft.com ([157.54.6.201]) by
>mail6.microsoft.com with Microsoft SMTPSVC(5.0.2195.4905); Tue, 2 Apr 2002
>12:22:51 -0800
>Received: from 157.54.5.25 by inet-vrs-06.redmond.corp.microsoft.com
>(InterScan E-Mail VirusWall NT); Tue, 02 Apr 2002 12:22:51 -0800
>Received: from red-msg-06.redmond.corp.microsoft.com ([157.54.12.71]) by
>inet-hub-03.redmond.corp.microsoft.com with Microsoft
>SMTPSVC(5.0.2195.4905); Tue, 2 Apr 2002 12:22:51 -0800
>From [EMAIL PROTECTED] Tue, 02 Apr 2002 12:24:23 -0800
>X-MimeOLE: Produced By Microsoft Exchange V6.0.6177.0
>content-class: urn:content-classes:message
>Message-ID:
><[EMAIL PROTECTED]>
>X-MS-Has-Attach:
>X-MS-TNEF-Correlator:
>Thread-Topic: COM Interop: Not seeing COM Interfaces in OLEVIEW after
>regasm?
>Thread-Index: AcHafvgTPRpRmpLSTrW0moF384U8swAAeMnA
>Return-Path: [EMAIL PROTECTED]
>X-OriginalArrivalTime: 02 Apr 2002 20:22:51.0021 (UTC)
>FILETIME=[298513D0:01C1DA84]
>
>Class interfaces fabricated by the CLR (such as _StringValidator)
>contain all the COM-visible members of the class and its base classes.
>By default, however, they are only accessible via IDispatch; no type
>information about their members is exposed.  This was done for
>versioning flexibility.  An author of a managed class expects to be able
>to add/rearrange members without breaking clients.  But if you do such a
>thing, the DISPIDs assigned to members could change, and the shape of
>the class interface would change if exposed.  COM clients won't be
>broken as long as they go through GetIDsOfNames/Invoke (except for one
>gotcha with overloaded members).
>
>If you want to call through the v-table, the best solution is to have
>your managed class implement an IStringValidator interface with the
>appropriate methods, and mark the class with
>[ClassInterface(ClassInterfaceType.None)] to make it the default
>interface when exposed to COM (suppressing the generation of
>_StringValidator).  You could add/rearrange members of the class without
>breaking anyone, although you should never mess with the interface
>(doing so would even break .NET clients).
>
>A quick & dirty fix to your problem would be to mark the class with
>[ClassInterface(ClassInterfaceType.AutoDual)] rather than
>defining/implementing an interface.  This will cause the exported
>_StringValidator interface to show type information for all of its
>members, but you'll be limited in evolving your class in the future.
>This also applies to base classes - if a COM-visible member were added
>to System.Object in the future, your interface layout would change and
>COM clients expecting the old layout would break.
>
>This is discussed in the FAQ on page 399.
>
>Hope that helps,
>Adam
>
>-----Original Message-----
>From: Sam Gentile [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, April 02, 2002 11:46 AM
>To: Adam Nathan; [EMAIL PROTECTED]
>Subject: COM Interop: Not seeing COM Interfaces in OLEVIEW after regasm?
>
>I have a basic COM Interop problem/question. I am using Adam's example
>from
>page 380 of his book, the simple StringValidator C# class.
>// To compile:
>// csc /t:library StringValidator.cs /r:System.dll
>
>using System.Text.RegularExpressions;
>using System.Reflection;
>
>[assembly:AssemblyKeyFile("KeyFile.snk")]
>
>public class StringValidator
>{
>       public bool IsPhoneNumber(string s)
>       {
>               return Regex.IsMatch(s,
>                       @"^(((\(\d{3}\)( )?)|(\d{3}(
>|\-)))\d{3}\-\d{4})$");
>       }
>
>       public bool IsZipCode(string s)
>       {
>               return Regex.IsMatch(s, @"^((\d{5})|(\d{5}\-\d{4}))$");
>       }
>
>       public bool IsSSN(string s)
>       {
>               return Regex.IsMatch(s, @"^\d{3}\-\d{2}\-\d{4}$");
>       }
>}
>
>Then I do
>1) sn -k keyfile.snk
>2) csc /t:library StringValidator.cs /r:System.dll
>Then from page 385
>1) register using regasm StringValidator.dll /tlb
>2) gacutil -i StringValidator.dll
>Then I am able to call the IsZipCode method through the IDispatch
>pointer
>and CCW.
>
>The problem(s) are:
>1) I can't see the 3 public methods in OLEVIEW
>[
>   uuid(C286EFF2-D7C4-3712-B8EE-BC7A7F84A823),
>   hidden,
>   dual,
>   custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, StringValidator)
>
>]
>dispinterface _StringValidator {
>     properties:
>     methods:
>};
>
>Where are the methods?
>
>2) I can call using IDispatch. What about an early bound v-table
>interface
>call?
>
>I thought regasm /tlb was a superset of regtlib. Am I wrong? What am I
>missing?
>
>
>
>
>---------------------
>Sam Gentile
>.NET Consultant
>Co-author: Wrox Visual C++ .NET: A primer for C++ developers
>http://www.project-inspiration.com/sgentile/DotNet.htm
>http://www.project-inspiration.com/sgentile/
>---------------------------
>
>
>
>
>_________________________________________________________________
>Get your FREE download of MSN Explorer at
>http://explorer.msn.com/intl.asp.
>




---------------------
Sam Gentile
.NET Consultant
Co-author: Wrox Visual C++ .NET: A primer for C++ developers
http://www.project-inspiration.com/sgentile/DotNet.htm
http://www.project-inspiration.com/sgentile/
---------------------------




_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to