none
Make Assembly Com-Visible Option Not Automatically Registering CCW

    Question

  • I have created a COM Callable Wrapper for my managed assembly to prepare it for use by VB6.

    I have create the interface...

    using System;
    using System.Runtime.InteropServices;
     
    namespace CompanyName.Interop
    {
        [ComVisible(true)]
        [InterfaceType(ComInterfaceType.InterfaceIsDual)]
        [Guid("FBC2092E-B9EF-42CF-9D9D-E9D71F9F0A56")]
        public interface IDisplayPatientInfo
        {
            void Initialize(int patientID);
            bool DisplayPatientInfo();
        }
    }

    I have create the class definition...

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Runtime.InteropServices;
     
    namespace CompanyName.Interop
    {
        [ComVisible(true)]
        [ClassInterface(ClassInterfaceType.None)]
        [ComDefaultInterface(typeof(IDisplayPatientInfo))]
        [ProgId("CompanyName.Interop.DisplayPatientInfo")]
        [Guid("39E6D9BA-F2F9-43EA-8907-D46ED3E358AD")]
        public class DisplayPatientInfo : IDisplayPatientInfo
        {
            private int patientID = 0;
     
            public DisplayPatientInfoFacade()
            {
                // default contructor
            }
     
            public void Initialize(int patientID)
            {
                this.patientID = patientID;
            }
     
            public bool DisplayPatientInfo()
            {
                bool result = false;
     
                using (var patientInfoForm = new frmPatientInfo())
                {
                    if (patientInfoForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        result = true;
                    }
                }
     
                return result;
            }
        }
    }
    

    I have create a strong name key for the assembly and have added it to the project and set it as such in the signing area of the properties for the assembly

    I have also checked the "Make Assembly COM-Visible" in the assembly dialog in the properties for the assembly.

    When I build the project it builds successfully and the DLL is created in the DEBUG directory. However no ProgID, CLSID, etc are created in the registry and no .tlb is found anywhere. 

    In the past I have worked on projects which automatically registered the CCW just by building the project.

    I have found that if I take the DLL and use regasm manually with the codebase and tlb options everything is registered correctly and I can then access the CCW from VB6.

    Can anyone explain to me why Visual Studio is not automatically registering the CCW in COM during the build and also is a .tlb absolutely necessary to access a managed object from VB6?

    Thanks,

    preCompile

    Thursday, March 3, 2016 3:42 AM

Answers

  • Answered my own question.

    Looks like "Make Assembly COM-Visible" is global setting for COM visibility of public members where as "Register for COM Interop" is the option on the build tab which I was looking for.

    Hope this may help someone else.


    Thursday, March 3, 2016 4:08 AM

All replies

  • Answered my own question.

    Looks like "Make Assembly COM-Visible" is global setting for COM visibility of public members where as "Register for COM Interop" is the option on the build tab which I was looking for.

    Hope this may help someone else.


    Thursday, March 3, 2016 4:08 AM
  • Hi precompile,

    Thanks for sharing your answer here.

    Please mark your reply as an answer so that it would be helpful for other members who get the same issue as yours to research and find the answer directly, and I could close this case.

    Have a nice day.

    Best Regards,

    Lake Xiao

    Friday, March 4, 2016 2:27 AM
    Moderator