Lech Wilk
Lech Wilk

Reputation: 9

ActiveX in .NET, mscoree.dll

I made some activeX in c# VS2013 for reporting. I register (doring building, and also by regasm), I made a msi installer, and basically my plugin is working. I use it on VBA. I can make a refference to it and use a control wrapper, but problem is, than I can use it only when i place it on the display (or winForm). Later, when I save, close, open again, then i get the message:

Unable to load ActiveXcontrol for display . cause: ClassLibrary1.UserControl1: CAB file missing on server: http://localhost/RSViewActiveXControlSetup/mscoreedll.CAB.

(RSView is a programming environment with possibility to use VBA code for displays)

Then I have to delete and place again. No possible to use on runtime -only test.

Registration part in my code:

[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"))
            {
                subkey.SetValue("", "131457");
            }
            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);
                if (version == "0.0") version = "1.0";
                subkey.SetValue("", version);
            }
        }
    }

Registers are updated, i think correct. I've red there is some problem with mscoree.dll, but i havent found how to solve. I will be very thinkfull for any help, I am little bit nooby. .NET 4.5.51209

Upvotes: 0

Views: 871

Answers (2)

Emanuele Manca
Emanuele Manca

Reputation: 11

you must change the key "InprocServer32" with the full path of mscorre.dll in the System register. Image of System Register

Or you change the ComRegisterFunction:

    [ComRegisterFunction()]
    public static void RegisterFunction(Type _type)
    {
        // Check your class type here 
        if (_type != null )
        {
            string sCLSID = "CLSID\\" + _type.GUID.ToString("B");
            try
            {
                RegistryKey _key = Registry.ClassesRoot.OpenSubKey(sCLSID, true);
                try
                {
                    Guid _libID = Marshal.GetTypeLibGuidForAssembly(_type.Assembly);
                    int _major, _minor;
                    Marshal.GetTypeLibVersionForAssembly(_type.Assembly, out _major, out _minor);
                    using (RegistryKey _sub = _key.CreateSubKey("Control")) { }
                    using (RegistryKey _sub = _key.CreateSubKey("MiscStatus")) { _sub.SetValue("", "0", RegistryValueKind.String); }
                    using (RegistryKey _sub = _key.CreateSubKey("TypeLib")) { _sub.SetValue("", _libID.ToString("B"), RegistryValueKind.String); }
                    using (RegistryKey _sub = _key.CreateSubKey("Version")) { _sub.SetValue("", String.Format("{0}.{1}", _major, _minor), RegistryValueKind.String); }
                    using (RegistryKey _sub = _key.CreateSubKey("Control")) { }

                    using (RegistryKey _sub = _key.CreateSubKey("InprocServer32")) { _sub.SetValue("", Environment.SystemDirectory + "\\" + _sub.GetValue("", "mscoree.dll"), RegistryValueKind.String); }
                }
                finally
                {
                    _key.Close();
                }
            }
            catch
            {
            }
        }
    }

Upvotes: 1

Glen Clark
Glen Clark

Reputation: 11

FT View SE (RSView SE) for some reason cannot find mscoree.dll which is registered as the InprocServer32 when we run regasm. Putting in the full path ("C:\Windows\SysWow64\mscoree.dll") fixed this for me.

Upvotes: 1

Related Questions