无法打开 VB 项目,出现错误“C:\windows\system32\mscomctl.ocx”无法加载
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13948897/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
not able to open VB project, getting error "C:\windows\system32\mscomctl.ocx" could not be loaded
提问by jyothis
I have a VB project was able to work without any issues, but now when i open the project i am getting the error with mscomctl.ocx. I have re-registered the ocx but still am not able to load the project.
我有一个 VB 项目能够正常工作,但是现在当我打开该项目时,我收到了 mscomctl.ocx 的错误。我已经重新注册了 ocx,但仍然无法加载该项目。
How can I fix this problem?
我该如何解决这个问题?
回答by user1272267
I was having this issue when I open the project on Windows 7 64-bit environment, it works correctly on win XP machine. I did a very simple change in project file earlier it says
我在 Windows 7 64 位环境中打开项目时遇到了这个问题,它在 win XP 机器上正常工作。我之前在项目文件中做了一个非常简单的更改,它说
Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0; MSCOMCTL.OCX
I changed 2.1
to 2.0
because I have seen it like that in many forums and it worked like charm.
The updated reference in VBP
file is
我改用了2.1
,2.0
因为我在很多论坛上都看到过它,而且它的效果非常好。VBP
文件中更新的参考是
Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; MSCOMCTL.OCX
回答by Nathan Hadley
I had the same problem. user1272267 answer worked (thanks), but it bothered me that I didn't understand why, I also wasn't sure if I would end up breaking the project for my colleagues who it worked fine for.
我有同样的问题。user1272267 的回答有效(谢谢),但让我感到困扰的是我不明白为什么,我也不确定我是否最终会为我的同事打破这个项目,因为它工作得很好。
So I did a bit more digging and found that in the registry there was a key; reg hkcr\typelib{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}\2.0 (Note the 2.0)
所以我做了更多的挖掘,发现在注册表中有一个键;reg hkcr\typelib{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}\2.0(注意2.0)
I changed the 2.0 to 2.1 and hey presto, everything worked fine. I also checked the DLL and it turned out my copy was older than my colleagues copy. I think this may be because when I installed service pack 6 I kept some of the original files when asked since the replacement files were for American english and I had the UK version, but i'm not 100% certain of this
我将 2.0 更改为 2.1,嘿,很快,一切正常。我还检查了 DLL,结果发现我的副本比我同事的副本旧。我认为这可能是因为当我安装 Service Pack 6 时,我保留了一些原始文件,因为替换文件是针对美国英语的,而我有英国版本,但我不是 100% 确定这一点
回答by Kresimir Pendic
Try re-registering MSCOMCTL.OCX
:
尝试重新注册MSCOMCTL.OCX
:
- download the file: http://www.ocxdump.com/ocxfiles/M/MSCOMCTL.OCX
- copy it in location
c:\windows\system32\
open command prompt and run this:
cd c:\windows\system32 regsvr32 MSCOMCTL.OCX
- 下载文件:http: //www.ocxdump.com/ocxfiles/M/MSCOMCTL.OCX
- 复制到位置
c:\windows\system32\
打开命令提示符并运行:
cd c:\windows\system32 regsvr32 MSCOMCTL.OCX
Than try to run your application again.
比尝试再次运行您的应用程序。
回答by Hrqls
it seems to me your project has lost its reference to the ocx (while it still tries to use some of the controls)
在我看来你的项目已经失去了对 ocx 的引用(虽然它仍然试图使用一些控件)
click on 'components' in the 'project' menu in the ide
单击ide中“项目”菜单中的“组件”
in the list make sure 'microsoft windows common controls 6.0 (sp6)' is checked ... if it already is, try removing it, close (and save) the project, open the project, and turn it on again
在列表中确保选中“microsoft windows common control 6.0 (sp6)”...如果已经选中,请尝试删除它,关闭(并保存)项目,打开项目,然后再次打开
回答by Hrqls
you can also open the project file (.vbp file) in notepad where you see something like the following :
您还可以在记事本中打开项目文件(.vbp 文件),您会在其中看到如下内容:
Type=Exe
Form=frmComFX.frm
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\Windows\SysWOW64\stdole2.tlb#OLE Automation
Object={648A5603-2C6E-101B-82B6-000000000014}#1.1#0; MSCOMM32.OCX
Object={5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0; MSFLXGRD.OCX
Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; MSCOMCTL.OCX
Form=frmSetup.frm
Module=modFX; modFX.bas
IconForm="frmComFX"
Startup="frmComFX"
HelpFile=""
Title="ComFX"
Command32=""
Name="comFX"
the lines that start with 'object-' contain the registry key with which the ocx is registered ... you can now open regedit (start - execute - regedit) and search for this key .. be careful though what you do in regedit, you might screw up your visual basic installation or even your complete windows :)
以“object-”开头的行包含注册 ocx 的注册表项……您现在可以打开 regedit(开始 - 执行 - regedit)并搜索此密钥 .. 尽管在 regedit 中执行的操作要小心,你可能会搞砸你的可视化基本安装,甚至你的整个窗口 :)
of course you can also remove visual basic and reinstall it to get the registrations back
当然你也可以删除visual basic并重新安装它以恢复注册
回答by Sunjen
I had this same error. These 2 things worked for me:
我有同样的错误。这两件事对我有用:
- Start Visual Studio 6 by right-click Run as Admin
- 通过右键单击以管理员身份运行启动 Visual Studio 6
or
或者
- Disable the UAC prompt.
- 禁用 UAC 提示。
hope it helps.
希望能帮助到你。
回答by Chris
Windows 7 64 bit; just installed VS6 and VS6 SP6 (with difficulty)but my project from Win XP gave the "MSCOMCTL.OCX could not be loaded" error.
Windows 7 64 位;刚刚安装了 VS6 和 VS6 SP6(有困难)但我的 Win XP 项目给出了“无法加载 MSCOMCTL.OCX”错误。
I found Nathan Hadley's answer gave me the clue and allowed me to open the project.... My userinterface.vbp file for the project (copied from Win XP) had #2.2 next to the MSCOMCTL.OCX reference but my registry class id had only 2.1. So I changed my userinterface.vbp entry to 2.1 and the project opened ok.
我发现 Nathan Hadley 的回答给了我线索,并允许我打开项目......我的项目的 userinterface.vbp 文件(从 Win XP 复制)在 MSCOMCTL.OCX 引用旁边有 #2.2,但我的注册表类 ID 有只有 2.1。所以我将我的 userinterface.vbp 条目更改为 2.1,并且项目打开正常。
However the next day I ran the VB6 SP6 cumulative update VB60SP6-KB2708437-x86-ENU again (may have not installed properly the first time) and now I have version 2.2 in the registry. So I changed my userInterface.vbp file back so the OCX reference has #2.2 once more and now the project still opens correctly and all runs ok.
然而,第二天我再次运行了 VB6 SP6 累积更新 VB60SP6-KB2708437-x86-ENU(第一次可能没有正确安装),现在我在注册表中有 2.2 版。所以我改回了我的 userInterface.vbp 文件,所以 OCX 引用再次具有 #2.2,现在项目仍然可以正确打开并且一切运行正常。
回答by Don
I had a similar problem when my Windows 7 32 bit laptop crashed and the company replaced it with a 64 bit machine... first I tried registering the .ocx using regsvr32 - on the 32 bit machine it would get unloaded from time to time... this did not work at all on the refurbished 64 bit machine...
当我的 Windows 7 32 位笔记本电脑崩溃并且公司用 64 位机器替换它时,我遇到了类似的问题......首先我尝试使用 regsvr32 注册 .ocx - 在 32 位机器上它会不时卸载。 .. 这在翻新的 64 位机器上根本不起作用......
I tried changing the .vbp file settings as noted in some of the earlier responses without success... I set the .vbp back to 2.0 and later on another issue I was searching the registry and decided to search for mscomctl.ocx and found 3 keys - 2.0, 2.1 and 2.2... since it wasn't working I decided to delete the 2.1 and 2.2 keys and voila! the controls loaded without a problem. Clearly the .vbp and registry have to match.
我尝试更改 .vbp 文件设置,如之前的一些响应中所述,但没有成功......我将 .vbp 设置回 2.0,后来在另一个问题上我正在搜索注册表并决定搜索 mscomctl.ocx 并找到 3键 - 2.0、2.1 和 2.2... 因为它不起作用我决定删除 2.1 和 2.2 键,瞧!控件加载没有问题。显然 .vbp 和注册表必须匹配。