none
How to break binary compatibility for a COM-visible type? RRS feed

  • Question

  • My employer has a code policy which requires us to annually rename and break binary compatibility for our class libraries. This year we need to break binary compatibility for a C# class library project which exposes a COM-visible type.

    The only GUID in the entire C# project refers to the assembly, which is not COM-visible. It looks to me as if all that's required is to assign a new name and a new GUID to the assembly, build it, and register it using regasm.exe.

    Is that correct? Relevant code snippets are similar to:

    // Source file: MyProject.csproj   
    <AssemblyName>MyClassLib2008</AssemblyName>   
       
    // Source file: AssemblyInfo.cs     
    [assembly: ComVisible(false)]     
    [assembly: Guid("{4537D573-F23B-4c7c-94F7-307DE331803E}")]     
        
    // Source file: IMyType.cs     
    [ComVisible(true)]     
    public interface IMyType     
    {     
        // ...     
    }     
        
    // Source file: MyType.cs     
    [ComVisible(true)]     
    public class MyType : IMyType     
    {     
        public MyType()     
        {     
            // ...     
        }     
        
        // ...     
    }    
     

    Thanks in advance!

    Monday, January 12, 2009 7:34 PM

Answers

  • Oh gawd, I wonder how that policy came into effect.  Well, not using the [Guid] attribute on your interface declaration would explain that perhaps.  Essential, and enough to break compatibility.
    Hans Passant.
    • Marked as answer by Matt Fisher Tuesday, January 13, 2009 4:03 AM
    Tuesday, January 13, 2009 1:14 AM
    Moderator

All replies

  • Oh gawd, I wonder how that policy came into effect.  Well, not using the [Guid] attribute on your interface declaration would explain that perhaps.  Essential, and enough to break compatibility.
    Hans Passant.
    • Marked as answer by Matt Fisher Tuesday, January 13, 2009 4:03 AM
    Tuesday, January 13, 2009 1:14 AM
    Moderator
  • Thank you.
    Tuesday, January 13, 2009 4:05 AM