ActiveX DLL can't be used when referenced, but CAN in a VB-group
Posted on 2003-11-06
I'm working on a VB projectgroup which consists of a Standard EXE and an ActiveX DLL. While trying to run a VBA-macro for word I built which uses the DLL however, I found that it wouldn't work. It results in the common error "ActiveX component can't create object", which you normally get when the DLL isn't registered under / referenced to its new GUID.
I will continue this question with stating the main properties of the DLL and standard EXE and will explain the steps I take before I try to run the VBA-macro. These are followed by some findings which are the result of my own testing. Finally, I will state my own opinion about what could be wrong.
ActiveX DLL properties & specifications:
- Set binary compatible to it's previously compiled version. I do admit that I often break this compatibility
- No unattended execution, because it contains forms.
- Apartment Threaded
- All other properties are default.
- EVERY class' property 'MTSTransactionMode' is set to 2 - Requires Transaction
Now these are the steps I take before invoking the DLL into the VBA-macro (or any other new standard exe project which I used to test):
- I compile the DLL (I do get an error message right after the compiler writes the DLL. The log states: "LINK : fatal error LNK1104: cannot open file <DLL path & Name>" I think the DLL isn't registered because of this error, so I manually register it using regsvr32.exe.
- I re-insert ALL DLL-classes into component services
Now these are my findings:
- The standard EXE references in its group to the VBA-project which resembles the DLL. Everything works fine that way.
- After my compilation-steps (see above) and when opening the standard EXE VB Project (NOT THE GROUP) and set its reference to the actual (compiled) DLL, it won't work (gives me the error message mentioned above).
- When I compile the EXE too (with its reference to either the compiled DLL or the ActiveX DLL Project), the compiled exe also does not work.
- The error occurs both when using New or CreateObject to create classes.
- Sometimes, before I receive the error message, Microsoft Visual C++ opens and shows me the DLLHost.exe module (no code, just the module name in the project explorer window).
- I set one class' transactionmode property to 0 (no transaction) and followed my compilation steps again. Then I made a new project which references the DLL and creates the specific class. This still did not work.
I personally think that it has something to do with the MTSTransactionMode, because we also have another project that has the same modules and properties (exe and dll) with a VBA and that also works. That DLL does not use MTS.
Please help us out. THIS IS CRITICAL in order to get our project to work. I sought help at my colleages, but they didn't know the answers either.
If you make yourself available to finding a sollution for us and still have many questions for me in order to give us a sollution, you can also give me a call at: +31402472280 and ask for Luc Derckx.
Thanks on beforehand,
Ithema bv (Netherlands)