ActiveX DLL can't be used when referenced, but CAN in a VB-group


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

Standard EXE-properties:
  - Default

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,

Luc Derckx
Ithema bv (Netherlands)
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you do a search in the registry for your DLLs ProgID, how many instances do you find?  Are there multiple entries under the HKEY_CLASSES_ROOT hive?
IThemaAuthor Commented:
All GUIDs are found in HKEY_CLASSES_ROOT, so that would be correct. I find ONE guid connected to ONE for each class that's part of the DLL. So each class is listed only once and therefore has ONE Guid. I also find ONE entry for the DLL itself (no class names listed in that registry entry)

I'm quite positive that this DLL is registered correctly. Not only does the registry seem right, I can also see a DLL class' functions and properties while programming.

For example:

Project 1 references to the new DLL.

Sub Main()
  Dim obj as OBSServerDLL.cOptions
  set obj = CreateObject("OBSServerDLL.COptions")  'Right --> Checked the registry
  MsgBox obj.Option("DocPath", strDSN, strDSNLogin, strDSNPass)
  set obj = nothing
End Sub

when I type "MsgBox obj" and then press "." I can see a list of functions and procedure, meaning that VB recognises the programID as a registered class.

Thanks on beforehand for your attempts to help me out. I'm anxious in reading further comments from anyone.
My question was brought about by the common situation where, after several breaks in compatibility, the former GUID is not properly removed from the registry, thus giving you the same ProgID pointing to possibly two separate GUIDs.  I think your linking error is worth noting.  See Microsoft KB article 166470.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

IThemaAuthor Commented:
I've tried some more things... When rebooting my sytem, I didn't have the component request pending problem anymore.

How can I close this thread? No real answer has been given so I can't really accept a comment as an answer, but I do want to thank AzraSound for trying to help me out and I want to give him 100 points for that.

Post a question in Community Support and ask them to reduce the points here to 100.
IThemaAuthor Commented:
AzraSound, I posted a 'delete and refund' request in the community support topic. I asked them to take 100 points directly from my account and give them to you. Reducing this thread to 100, means I will have to accept one of your comments as an answer, while actually no answer has been given. This would not add any value to experts exchange and I don't think that this would be the best thing to do.

Thanks for helping me anyway.

btw: I see now that one of my comments has - for some reason - not been stored here. The solution to my problem I found out, was that in the MTS advanced options for the component, an option called 'run in debugger' was set enabled. I disabled this option and was now free to use my DLL where-ever I wanted. The new problem I encountered was a 'component request pending; retry, switch to' when trying to focus an .EXE-form while an .DLL-form was focussed. This 'Comp. Req. Pend.' window then always popped up when clicking somewhere on the actual program and would only vanish when I was able to find the DLL-form. Since this problem is off-topic and I haven't tested this case thoroughly I will not seek an answer here. I might make a new thread for that if I can't seem to tackle the problem myself. I hereby kindly invite you to help me at that time.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.