jy00257874 发表于 2022-1-23 13:42:26

为什么会报“80040154 没有注册类”

本帖最后由 jy00257874 于 2022-1-23 13:47 编辑


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

using UFIDA.U8.MomServiceCommon;
using UFIDA.U8.U8MOMAPIFramework;
using UFIDA.U8.U8APIFramework;
using UFIDA.U8.U8APIFramework.Meta;
using UFIDA.U8.U8APIFramework.Parameter;
using MSXML2;

namespace Hermes
{
    public class Comm

    {
      public string connect(string msg)
      {
            Console.WriteLine(msg);
            U8Login.clsLogin u8Login = new U8Login.clsLogin();
            String sSubId = "AS";
            String sAccID = "(default)@001";
            String sYear = "2021";
            String sUserID = "demo";
            String sPassword = "demo1";
            String sDate = "2021-11-11";
            String sServer = "192.168.0.195";
            String sSerial = "";
            if (!u8Login.Login(ref sSubId, ref sAccID, ref sYear, ref sUserID, ref sPassword, ref sDate, ref sServer, ref sSerial))
            {
                Console.WriteLine("登陆失败,原因:" + u8Login.ShareString);
                return "";
            }
            return "";
      }
    }
}

异常信息如下:System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {72A6FADA-FE26-46BD-A921-BFD1179C1E1E} failed due to the following error: 80040154 没有注册类 (0x80040154 (REGDB_E_CLASSNOTREG)).
   at System.RuntimeTypeHandle.AllocateComObject(Void* pClassFactory)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type)
   at Hermes.Comm.connect(String msg) in E:\cpj\Hermes\Comm.cs:line 23
   at Program.<Main>$(String[] args) in E:\cpj\debug\Program.cs:line 5

jy00257874 发表于 2022-1-24 09:15:16

有没有人帮一下忙啊,一天时间没得什么思路,我做java的,对c#不熟啊,网上说的注册和用x86都试过了,不行

standime24 发表于 2022-5-19 16:04:11

我看看

kaikai7902 发表于 2022-6-10 13:12:22

不懂,来看看

DEAN2021 发表于 2022-9-1 16:22:10

感谢楼主,学习!

200229 发表于 2023-3-27 19:55:50

“80040154 没有注册类”是一个常见的 Windows 错误代码,通常表示您尝试访问的 COM 组件没有正确地在系统中注册。这可能是由于以下原因之一导致的:

1. 该组件未被安装或已损坏。
2. 注册表中存在错误或丢失的信息。
3. 使用32位应用程序时,在64位操作系统上运行。

要解决此问题,可以尝试以下步骤:

1. 确认该组件是否已正确安装,并检查其版本和兼容性。
2. 执行“regsvr32”命令重新注册该组件。打开命令提示符窗口(管理员权限),输入“regsvr32 文件路径”,其中文件路径为需要重新注册的COM组件所在位置。
3. 如果使用32位应用程序,请确保它们与操作系统架构相匹配。

如果以上方法都无法解决问题,则建议联系软件供应商或技术支持团队以获取更多帮助。

rollbin 发表于 2023-6-5 09:34:22

谢谢分享!

Marco-1988 发表于 2023-7-3 16:00:06

感谢分享!!
页: [1]
查看完整版本: 为什么会报“80040154 没有注册类”