[Last Call] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2003-11-06
Medium Priority
Last Modified: 2010-05-03

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)
Question by:IThema
  • 3
  • 3
LVL 28

Expert Comment

ID: 9694290
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?

Author Comment

ID: 9694506
All GUIDs are found in HKEY_CLASSES_ROOT, so that would be correct. I find ONE guid connected to ONE prog.id 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 prog.id --> 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.
LVL 28

Accepted Solution

AzraSound earned 400 total points
ID: 9694557
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.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 9796024
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.

LVL 28

Expert Comment

ID: 9797029
Post a question in Community Support and ask them to reduce the points here to 100.

Author Comment

ID: 9809046
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.

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question