“AnyCPU / x64 / x86”清晰度为Class not registered Exception [英] clarity on “AnyCPU/x64/x86” for Class not registered Exception

查看:58
本文介绍了“AnyCPU / x64 / x86”清晰度为Class not registered Exception的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的场景:我正在迁移一个基于VS2005 / VS2008构建的Windows应用程序(不确定它是在哪个构建的)。迁移的目标是Windows应用程序应该在Windows 10 OS系统中运行。我现在正在使用VS2013。将Frame
工作版本从2升级到4.5.1。我们使用interop dll(比如说interop.xyz dll)与MQ进行通信(不知道这是什么)。没有源代码interop.xyz。不知道它是否支持64/32位版本。下面是我获得异常的代码片段

Here is my scenario: I am migrating a windows application which was built on VS2005/VS2008(not sure on which it was built). Objective of the migration is the windows application should run in Windows 10 OS systems.I am using VS2013 now. upgraded the Frame work version from 2 to 4.5.1. We are using an interop dll(lets say interop.xyz dll) for communication with MQ(not sure what this is).Don't have the source code the interop.xyz. Don't know is it supporting both 64/32 bit versions. Below is the code snippet where I am getting an exception

colResults = new xyz.QueryResultCollection();

colResults = new xyz.QueryResultCollection();

以下是例外。

检索具有CLSID {690CFE43-BBB9-11D2-B60E-00203544F994}的组件的COM类工厂由于以下错误而失败:80040154类未注册(HRESULT异常:0x80040154( REGDB_E_CLASSNOTREG))。

Retrieving the COM class factory for component with CLSID {690CFE43-BBB9-11D2-B60E-00203544F994} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

在网上论坛搜索后,我发现我应该注册interop.xyz dll。我尝试了很多方法来注册(在cmd中尝试了regsrv.exe(对于System32 / SysWOW64)。但注册不成功)。我认为interop.xyz dll是为了支持
只有32位机器而构建的。

After searching in online forums I found that I should register the interop.xyz dll. I tried many ways to register(tried regsrv.exe in cmd(for both System32/SysWOW64).But the registration was not successful). I thought the interop.xyz dll was built to support only 32 bit machines.

在做了一些搜索之后,我找到了问题的解决方案。我已经从"anyCPU"更改了平台目标。到"x86"。然后我可以打开问题的应用程序。但是现在我主要担心的是如果我在WINDOWS 10 OS机器中部署这个源代码
,该应用程序是否有效?如果没有那么我怎样才能注册dll而不是更改目标平台。

After doing some more searching I found the solution to the issue. I have changed the platform target from "anyCPU" to "x86". Then i could open the application which out issues. But now my major concern is if I deploy this source code in WINDOWS 10 OS machines,will the application work? If not then how could I register the dll instead of changing the target platform.

我不确定我在做什么是正确的。我现在正在迁移的应用程序最后一次修改于2010年,没有人向我提供有关该应用程序的任何信息。我只是一个人待着。有人请建议我一个正确的方法来
处理我当前的问题,以便它应该在WINDOWS 10 OS系统中工作。提前致谢。注意:我当前的VM规格---> Windows 7 64位操作系统

I am not sure what I am doing is correct. The application which I am migrating now was last modified in 2010 and there is no-one to give me any information about the application. I am just left alone to work with. Someone please suggest me a proper way to handle my current issue so that it should work in WINDOWS 10 OS systems. Thanks in advance. Note: My current VM specs---> Windows 7 64 bit OS

推荐答案

如果dll名称包含interop,则表示它可能是32位dll。您还可以在dll的字节内查看。跳过前128个字节(0x80字节)。跳过另外4个字节。检查接下来的2个字节:

If the dll name contains interop, that is a signal that it might be 32bit dll. You can also check inside the bytes of the dll. Skip the first 128 bytes (0x80 bytes). Skip another 4 bytes. Check the next 2 bytes:


  • 4C 01 = 32bit dll
  • 64 86 = 64bit dll

现在关于AnyCPU / x64 / x86编译...

Now about AnyCPU/x64/x86 compilation...

使用AnyCPU的编译程序将在64位系统上以64位运行,在32位系统上以32位运行。

A compiled program with AnyCPU will run as 64bit on a 64bit system and as 32bit on a 32bit system.

带有x64的编译程序只能在64位系统上运行。

A compiled program with x64 will run only on a 64bit system.

带有x86的编译程序将在两个系统上运行,但即使在64位系统将以32位运行。

A compiled program with x86 will run on both systems, but even on a 64bit system will run as 32bit.

因此这会引发您的问题:

So this raise your issue:

如果您在64位计算机上使用AnyCPU,主程序将以64位和dll是32位,这是一个不匹配。

If you use AnyCPU on a 64bit machine, the main program will run as 64bit and the dll is 32bit and it is a mismatch.

如果你在32位机器上使用AnyCPU,主程序将运行为32位,dll也为32位,应用程序将工作。

If you use AnyCPU on a 32bit machine, the main program will run as 32bit and the dll also as 32bit and the application will work.

解决方案是编译为x86主程序,因此可以在Windows10 32bit或Windows10 64bit上使用dll。您不必担心,它也将在64位系统中运行。有很多应用程序在64位系统上仍然以32位运行。
需要一段时间,直到所有应用程序都是64位。

The solution is to compile as x86 the main program, so you can use the dll on both Windows10 32bit or Windows10 64bit. You don't need to worry, it will run also in a 64bit system. There are plenty of applications that still run as 32bit on 64bit systems. It will take a while until all the applications will be 64bit.

有关COM类的更多信息:

More about COM classes:

注册DLL(32位或64位)时,对于两种体系结构,类都将添加到HKEY_CLASSES_ROOT,但也会存储到dll的路径。因此,dll由主程序访问,架构不匹配将导致"Class
not registered"。

When the DLL (32bit or 64bit) is registered, the class is added to HKEY_CLASSES_ROOT for both architectures, but also the path to the dll is stored. So behind, the dll is accessed by the main program and an architecture mismatch will lead to "Class not registered".


这篇关于“AnyCPU / x64 / x86”清晰度为Class not registered Exception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆