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.dllFor 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);
}
}
}
Tomor
FOLLOW US
Get the latest news in Application Packaging