Solved

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

Posted on 2003-11-06
7
385 Views
Last Modified: 2010-05-03
Hello,

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

Expert Comment

by:AzraSound
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?
0
 
LVL 5

Author Comment

by:IThema
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.
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 100 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.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 5

Author Comment

by:IThema
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.


Luc
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 9797029
Post a question in Community Support and ask them to reduce the points here to 100.
0
 
LVL 5

Author Comment

by:IThema
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.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now