Late binding run-time error in VB6 when creating an object from a .NET assembly

后端 未结 2 1889
一整个雨季
一整个雨季 2021-01-18 10:10

i have a vb6 project that has a reference to a vb.net com library.

the project runs well when i use early binding such as:

Dim b as object
Set b = ne         


        
2条回答
  •  误落风尘
    2021-01-18 10:50

    If you're the ClassInterfaceType.None setting, You have to add a ProgId attribute to your class to allow late binding.

    For example:

    [Guid("B1E17DF6-9578-4D24-B578-9C70979E2F05")]
    public interface _Class1
    {
        [DispId(1)]
        string TestingAMethod();
    }
    
    [Guid("197A7A57-E59F-41C9-82C8-A2F051ABA53C")]
    [ProgId("Rubberduck.SourceControl.Class1")]
    [ClassInterface(ClassInterfaceType.None)]
    public class Class1 : _Class1
    {
        public string TestingAMethod()
        {
            return "Hello World";
        }
    
    }
    

提交回复
热议问题