Search code examples
.netvb6interopbinary-compatibility

Is it possible to achieve binary compatibility in .NET library?


I have a .NET library visible in COM, and it's called from a vb6 application.

If I add some methods and release a new version (but don't erase or change signatures of existing methods), I would like being able to just install it in the production machine, and have it working. However, it seems that such approach doesn't work; I need to reompile the vb6 application.

Is there any way to achieve this?


Solution

  • You can explicitly use the Guid attribute on your COM interfaces and classes and the DispId attribute on your methods, fields and properties:

    [Guid("0E213759-1679-4CD1-8322-566CF76928EF")]
    public class SampleClass
    {
        [DispId(8)]
        public void MyMethod() {}
    }