?
Solved

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

Posted on 2003-11-06
7
Medium Priority
?
393 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Suggested Courses

765 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