首页 文章

如何在64位操作系统中注册activeX组件(.dll)

提问于
浏览
2

我使用用户控件创建ActiveX控件(.dll)并注册为COM组件 . 它在32位操作系统中运行良好 . 但是当在64位操作系统(窗口服务器2008)中注册相同的activeX控件时,它会抛出以下异常

Could not load file or assembly 'file :////C:\Program Files\STPL\GlobActiveX.dll' or one of its dependencies. an attempt was made to load a program with an incorrect format.

我使用以下代码注册dll组件

filepath=C:\Program Files \STPL\GlobActiveX.dll
            Assembly asm = Assembly.LoadFrom(filePath);
            RegistrationServices regAsm = new RegistrationServices();
            bool bResult = regAsm.RegisterAssembly(asm, AssemblyRegistrationFlags.SetCodeBase);

如何在64位操作系统中注册activeX组件(.dll)?

我想在64位程序文件中安装这个activeX . 我已经安装了我的winform应用程序作为64位设置 . 这个设置将安装在64位平台上 . 因为我在我的activeX加载时使用了一个path.gcon文件来处理我的应用程序然后从注册表HKEY_LOCAL_MACHINE \ SOFTWARE \ APPLICATION_NAME \ LOCATION从我的应用程序安装路径获取数据库路径然后从这个位置读取path.gcon文件然后启动activeX控件

当我将activeX注册为x86平台时,它会成功注册并存储到HKEY_CLASSES_ROOT \ wow6432Node中 . path.gcon无法在activeX控件中读取 . 如何在x64平台上注册ActiveX控件?

1 回答

  • 1

    你的dll是32位,所以exe必须在32位模式下运行 . 在64位Windows中,具有Platform AnyCPU的.NET exe在64位模式下运行 . 在32位Windows中,带有Platform AnyCPU的.NET exe在32位模式下运行 . 我认为你的主机exe是Platform AnyCPU,重新编译到Platform x86,或使用CorFlags.exe来更改exe,强制32位标志 .

相关问题