We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

VB6.0 DLL does not fire an Event where running the .VBP does

darkxenn
darkxenn asked
on
Medium Priority
414 Views
Last Modified: 2012-06-22
Hey

Just about at my wit's end, so i figured i'd throw this at y'all and see if anyone knew what i was doin wrong.

Okay, so i have two projects.

Project A creats a DLL
Project B is a Test Project to test that the interface of the DLL is working properly.

Both projects are written in VB

So, when i click "Start" on the DLL project, and then include that .vbp into the test project references, everything works fine, events that the DLL fires up to the test project get caught, and everything works as it should.

However, when i build my DLL, and try to set it as a resource in the Test Project by clicking project->References->Browse and selecting the DLL, the DLL works fine, and does everything it should. However, it does not fire off any events at all.

So, in summary, the compiled DLL will not fire off the necessary events, whereas the DLL project running in 6.0 will.

What am i doing wrong that the compiled code will not fire off those events?

thanks a bunch
--Xen
Comment
Watch Question

Commented:
set your dll to binary compatibility

Project->project properties->component tab

Author

Commented:
Thanks for the input, eddy

that didnt do it, though.

Any other thoughts?

Thanks
--Xen
Commented:
show us some code that you used?
What sp do you use?
what OS?

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
XP Pro SP2

In the DLL:

Public Event CompleteTask(ResultInfo As myResult)

Public Sub TaskCompleted()
    RaiseEvent CompleteTask(AppForm.getReslt)
End Sub


In the TestApp:

Public WithEvents myObj As myDLL.Application

Private Sub myOBJ_CompleteTask(ResultInfo As myDLL.myResult)
'
'  Code to handle the event
'
End Sub




Again, when i click the "start" button in the DLL project, and reference that in my test project, everything works fine. It is when the DLL project is compiled, and the DLL is on its own that the event doesnt fire. The DLL does everything it is supposed to, except for that event.

Thanks a bunch
--Xen

Commented:
I have no problem to create a simple project and test, since i don't know what is your myresult, i use string. Do you have problem to use simple project. Of course i set my dll to binary compatibility

here is my test program

In dll ( use everything by default)
Option Explicit

Public Event CompleteTask(ResultInfo As String)

Public Sub TaskCompleted()
    RaiseEvent CompleteTask("this is test")
End Sub

In exe (rename project to project11)

Option Explicit
Public WithEvents myObj As Project1.Class1

Private Sub myOBJ_CompleteTask(ResultInfo As String)
MsgBox ResultInfo
End Sub

Private Sub Command1_Click()
Set myObj = New Class1
myObj.TaskCompleted
End Sub
EDDYKT,

It sounds like this might be a possibility.

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q237286

The article describes a situation where if you've compiled your DLL it won't fire events in the main project *while in the IDE*, but it will fire them if you're running *both* in the IDE, or if they're *both* compiled.  But it only pertains if the event is being raised from within a modal form in the DLL.  It's a known bug and the only solution appears to be showing the form non-modally when testing the application in the IDE.

Alternatively you could do some stuff with callbacks, like:

(In the DLL)
Option Explicit

Private mCallbackObj As Object

Public Event CompleteTask(CallbackObj As Object, ResultInfo As String)

Public Sub TaskCompleted()
    CallbackObj.CompleteTask "this is a test"
End Sub

(In the main project)
Option Explicit
Public myObj As Project1.Class1

Public Sub CompleteTask(ResultInfo As String)
MsgBox ResultInfo
End Sub

Private Sub Command1_Click()
Set myObj = New Class1
myObj.TaskCompleted
End Sub

HTH-Jon

Commented:
How does the link describe the problem related to you?

1, you are not running modal form ( i guess)
2. >>So, in summary, the compiled DLL will not fire off the necessary events
Does it opposite what you said here?
Oops... by bad.  I read the names wrong and addressed my last comment to EDDYKT when it should have been addressed to darkxenn.  That's just the thing, maybe he's not showing us all the code and maybe there is a modal form involved.  It was just a shot in the dark.

Commented:
Sorry too. I though you are the author.

>>How does the link describe the problem related to >>you?

hehe
I'm embarrassed...  I just noticed my sample callback code (air code) was ridiculously flawed.  The code should be:

(In the DLL)
Option Explicit

Public Sub TaskCompleted(ByVal CallbackObj As Object)
    'do something, then call the CompleteTask procedure on the callback object
    CallbackObj.CompleteTask "this is a test"
End Sub

(In the main project)
Option Explicit
Public myObj As Project1.Class1

Public Sub CompleteTask(ResultInfo As String)
MsgBox ResultInfo
End Sub

Private Sub Command1_Click()
Set myObj = New Class1
myObj.TaskCompleted Me
End Sub

Author

Commented:
... boy, i had just forgotten to register the DLL. Workin too much apparently pushes the simple stuff out of your brain.

Thanks for your help guys, i'll split the points between you.

--Xen
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.