问题
I'm pulling my hair out on this one...
I have a legacy application I built a few years ago that uses AutoItX - all working fine.
The time has come to try and update the app, so I've upgraded it to VS2012/.NET4 and I simply cannot get a reference to the AutoItX library to work.
I have installed the application, have registered the dll with regsvr32, tried every combination of property settings on the reference itself (Embed Interop Types / Isolated), but no joy.
The error I keep getting whenever I try and create an AutoItX3 object is:
Retrieving the COM class factory for component with CLSID {1A671297-FA74-4422-80FA-6C5D8CE4DE04} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Is it an issue that I'm on a 64-bit machine? I'm not trying to use the 64-bit DLL version.
回答1:
Okay the solution was:
- Open up regedit*32 (c:\windows\syswow64\regedit)
- Search for AutoItX in HKEY_CLASSES_ROOT\AppID
- I found it in HKEY_CLASSES_ROOT\AppID{6E8109C4-F369-415D-AF9A-2AEEFF313234}
- Create a blank REG_SZ (String) entry called DllSurrogate
For some reason, this completely solved the issue.
Reference: How to use a 32 bit COM object on Windows Server 2008 (works on 2008 R2 but non 2008)
回答2:
Hainesy,
do you use a x64-Windows? I had the same problem when I was starting to have a look at COM. If so, you should try to register your class in HKEY_LOCAL_MACHINE\SOFTWARE\WoW6432Node\Classes...
Give it a try!
Greeting
来源:https://stackoverflow.com/questions/14644258/get-autoit-reference-working-in-c-sharp