问题
i create the ActiveX control(.dll) using user control & register as COM component . it working fine in 32 bit OS . but when register the same activeX control in 64 bit os (window server 2008) it throws following exception
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.
i have used the following code to register the dll component
filepath=C:\Program Files \STPL\GlobActiveX.dll
Assembly asm = Assembly.LoadFrom(filePath);
RegistrationServices regAsm = new RegistrationServices();
bool bResult = regAsm.RegisterAssembly(asm, AssemblyRegistrationFlags.SetCodeBase);
how to register the activeX component(.dll) in 64 bit OS?
i want to installed this activeX in 64 bit program files.I have install my winform application as setup 64 bit.i.e this setup will be installed in 64 bit platform . because i have used the one path.gcon file to working with my application when my activeX loaded then it take databse path from the my application installation path from the registry HKEY_LOCAL_MACHINE\SOFTWARE\APPLICATION_NAME\LOCATION then from this location read the path.gcon file then start the activeX control
when i have register the activeX as x86 platform then it register successfully & stored into the HKEY_CLASSES_ROOT\wow6432Node. path.gcon can not read in activeX control. How to register the ActiveX control in x64 platform?
回答1:
Your dll is 32-bit, so exe must run in 32-bit mode. In 64-bit Windows, .NET exe with Platform AnyCPU runs in 64-bit mode. In 32-bit Windows, .NET exe with Platform AnyCPU runs in 32-bit mode. I think you host exe is Platform AnyCPU, recompile it to Platform x86, or use CorFlags.exe to change the exe, force 32-bit flag on.
来源:https://stackoverflow.com/questions/9407229/how-to-register-the-activex-component-dll-in-64-bit-os