首页 > 解决方案 > 2020 年 2 月微软更新后 COM+ 异常“类未注册”

问题描述

我有一个在 Delphi 中的应用程序,它通过旧的 COM+ 组件与其他 .NET 应用程序交互。该组件是从 Delphi 代码调用的,直到 Microsoft 于 2020 年 2 月 11 日(今年)推出了一些安全补丁,才出现问题。

它现在抛出的问题是“类未注册”在谷歌上搜索了很多之后,我尝试了以下事情:

  1. 由于这个 COM+ 组件是用 .NET 编写的(ComVisible 属性,假设它需要再次注册。因此尝试使用以下方式注册它使用 RegAsm:

    再高潮

但它没有工作

  1. 确认程序集是否在 GAC 中。它确实放在那里。
  2. 项目清单
  3. 删除 DLL 的注册,然后使用 regasm /u 注册,但这也没有运气。
  4. 谷歌上的一些博客提出了关于 COM+ 安全性的建议。试着玩那个。
  5. 禁用 COM+ 组件以测试 COM+ 组件是否有任何影响,是的,确实它转向了不同的错误。像组件这样的东西不存在。
  6. 有人建议运行 DCOMCNFG 并遍历 DCOM 配置树,如果有警告记录注册表中的异常,请按“是”。仍然没有运气。
  7. 使用 RegEdit 打开注册表并尝试允许对包括 Microsoft Ole 在内的相关注册表进行完全控制。仍然没有工作
  8. 另外,关于 COM 安全性也有一些想法,它也被检查并被很好地允许。需要注意的是,如果我们恢复微软补丁,它会再次运行良好。我匹配了看起来相同的补丁之前和之后的所有安全设置。

如果有人对此有充分的了解,请提出建议。

它显示的错误

添加更多细节:

COM+ 组件

COM 组件属性

这是 .NET COM 组件代码:

    using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.EnterpriseServices;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Text;
using System.Threading;
using System.Xml.XPath;

using Acclipse.Config;
using Acclipse.FileSystem.Shared;
using Aspose.Words;

[assembly: ApplicationActivation(ActivationOption.Library)]
[assembly: ApplicationAccessControl(false)]
[assembly: ApplicationName("Acclipse FileSystem Client")]
[assembly: Description("Client to communicate with the Acclipse FileSystem server.")]

namespace Acclipse.FileSystem
{
    class Singleton
    {
        private static Singleton m_Instance = new Singleton();

        private Singleton()
        {
            Trace.WriteLine("Singleton.Create");
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
        }

        private IRemotedFS m_IRemotedFS;

        public static Singleton Instance
        {
            get
            {
                return m_Instance;
            }
        }

        internal static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            Trace.WriteLine("CurrentDomain_AssemblyResolve", "Acclipse.FileSystem");
            try
            {
                string[] parts = args.Name.Split(',');
                string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), string.Format("{0}.dll", parts[0]));
                //Trace.WriteLine(string.Format("Loading resolved assembly at {0}", path), "Acclipse.Licencing");

                Assembly a = Assembly.LoadFile(path);
                Trace.WriteLine(string.Format("Assembly is {0}, looking for {1}", a.FullName, args.Name), "Acclipse.FileSystem");
                if (a.FullName != args.Name)
                {
                    throw new ApplicationException("Unable to load correct assembly");
                }

                return a;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format("Failed to resolve with error {0}", ex.Message), "Acclipse.FileSystem");
            }

            return Assembly.GetExecutingAssembly();
        }

        public IRemotedFS FS
        {
            get
            {
                Trace.WriteLine("Get IRemotedFS", "Acclipse.FileSystem");
                if (m_IRemotedFS == null)
                {
                    try
                    {
                        Trace.WriteLine("Creating IRemotedFS", "Acclipse.FileSystem");

                        Trace.WriteLine("Configfile at " + Path.GetFullPath("Config.file"), "Acclipse.FileSystem");
                        ConfigFile config = ConfigFile.FromFile("Config.file");

                        Trace.WriteLine("Loading url", "Acclipse.FileSystem");
                        string url = config["FileStore.Url"];


                        if (string.IsNullOrEmpty(url))
                        {
                            throw new ApplicationException("Url of server is not configured in Config.file");
                        }

                        Trace.WriteLine(string.Format("Url is {0}", url));

                        TcpClientChannel chan = new TcpClientChannel();
                        ChannelServices.RegisterChannel(chan, false);
                        m_IRemotedFS = Activator.GetObject(typeof(IRemotedFS), url) as IRemotedFS;

                        if (m_IRemotedFS == null)
                        {
                            Trace.WriteLine("Oops, RemoteFS is null!!");
                        }
                    }
                    catch (Exception e)
                    {
                        Trace.WriteLine(string.Format("Error in getting FS *** {0} - {1}", e.Message, e.StackTrace));
                        throw;
                    }
                }

                Trace.WriteLine("..Done");
                return m_IRemotedFS;
            }

            internal set
            {
                m_IRemotedFS = value;
            }
        }
    }

    [ComVisible(true)]
    [ProgId("Acclipse.FileSystem.SqlZipClient.SqlZipFileSystemRemote")]
    [Guid("5A940543-24EF-4f31-B45B-6832C8211986")]
    [ClassInterface(ClassInterfaceType.None)]
    [JustInTimeActivation(true)]
    public class SqlZipFileSystemRemote : ServicedComponent, IFileSystem
    {
        private IConfigFile m_Config;

        public SqlZipFileSystemRemote()
        {
            Trace.WriteLine("SqlZipFileSystemRemote Created", "Acclipse.FileSystem");
            m_Config = DefaultConfigFile.FromFile("Config.file");
        }

        static SqlZipFileSystemRemote()
        {
            Trace.WriteLine("Set Aspose.Words license info", "Acclipse.FileSystem");
            try
            {
                new License().SetLicense("Acclipse.FileSystem.SqlZipClient.Aspose.Words.lic");
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format("Exception encountered setting license details: {0}", ex.StackTrace), "Acclipse.FileSystem");
                throw;
            }

            Trace.WriteLine("Done", "Acclipse.FileSystem");
        }

        internal void AttachConfigFile(IConfigFile config)
        {
            this.m_Config = config;
        }

    }
}

标签: c#.netdelphicom+

解决方案


推荐阅读