.Net assembly not registered correctly or COM Interop - Advanced Installer Community
tomor
Posts: 1
Joined: Thu Sep 12, 2013 12:32 am

.Net assembly not registered correctly or COM Interop

Hello,

I have a .dll file that I need to register for COM Interop (as I would do with regasm) during setup. I've checked the "Register .Net Assembly for COM Interoperability" option. The setup runs fine, and I see that some entries are created in the Registry. However, when I try to embed it in PowerPoint as OLE Object, I receive an HRESULT_FAIL error. The strange thing is that if I do a

Code: Select all

regasm Library.dll
, it works fine. When I compare the registry keys created during both operations, I notice that the one run by installer does not create some keys created in my ComRegisterFunction, contrary to what regasm.exe does. Among them is a key called TypeLib.

For debugging purposes, I'm providing the code of ComRegisterFunction below:

Code: Select all

        [ComRegisterFunction]
        static void ComRegister(Type t)
        {
            string keyName = @"CLSID\" + t.GUID.ToString("B");
            using (RegistryKey key =
                Registry.ClassesRoot.OpenSubKey(keyName, true))
            {
                key.CreateSubKey("Control").Close();
                using (RegistryKey subkey = key.CreateSubKey("MiscStatus"))
                {
                    // 131456 decimal == 0x20180.
                    long val = (long)
                        (OLEMISC.OLEMISC_INSIDEOUT
                        | OLEMISC.OLEMISC_ACTIVATEWHENVISIBLE
                        | OLEMISC.OLEMISC_SETCLIENTSITEFIRST);
                    subkey.SetValue("", val);
                }
                using (RegistryKey subkey = key.CreateSubKey("TypeLib"))
                {
                    Guid libid =
                        Marshal.GetTypeLibGuidForAssembly(t.Assembly);
                    subkey.SetValue("", libid.ToString("B"));
                }
                using (RegistryKey subkey = key.CreateSubKey("Version"))
                {
                    Version ver = t.Assembly.GetName().Version;
                    string version =
                      string.Format("{0}.{1}", ver.Major, ver.Minor);
                    subkey.SetValue("", version);
                }
            }
        }
Thanks in advance,

Tomor
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: .Net assembly not registered correctly or COM Interop

Hello Tomor and welcome to Advanced Installer forums,

Thank you for your interest in Advanced Installer.

I apologize for my delayed reply. We are quite busy at the moment.

Can you please send us your Library.dll file (and its dependencies files if it is the case) to support at advancedinstaller dot com so we can investigate? Also, if your file contains private data you can try to isolate the behavior in a sample .dll file and send it us.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”