簡體   English   中英

.NET中的ActiveX,mscoree.dll

[英]ActiveX in .NET, mscoree.dll

我在c#VS2013中制作了一些activeX進行報告。 我注冊了(營業大樓,也通過regasm),我做了一個msi安裝程序,基本上我的插件正在工作。 我在VBA上使用它。 我可以引用它並使用控件包裝,但是問題是,僅當我將其放在顯示器(或winForm)上時,我才能使用它。 稍后,當我保存,關閉,再次打開時,我得到以下消息:

無法加載ActiveXcontrol進行顯示。 原因:ClassLibrary1.UserControl1:服務器上缺少CAB文件: http://localhost/RSViewActiveXControlSetup/mscoreedll.CAB

(RSView是一個編程環境,可以使用VBA代碼進行顯示)

然后,我必須刪除並再次放置。 無法在僅運行時測試中使用。

我的代碼中的注冊部分:

[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);
            }
        }
    }

寄存器已更新,我認為是正確的。 我已經紅了mscoree.dll,但我還沒有找到解決方法。 我會很想得到任何幫助,我有點不高興。 .NET 4.5.51209

出於某些原因,FT View SE(RSView SE)找不到mscoree.dll,該文件在我們運行加氣時已注冊為InprocServer32。 放入完整路徑(“ C:\\ Windows \\ SysWow64 \\ mscoree.dll”)為我解決了此問題。

您必須使用系統寄存器中mscorre.dll的完整路徑來更改鍵“ InprocServer32”。 系統注冊圖片

或者您更改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
            {
            }
        }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM