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

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
LVL 1
darkxennAsked:
Who is Participating?
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.

EDDYKTCommented:
set your dll to binary compatibility

Project->project properties->component tab
0
darkxennAuthor Commented:
Thanks for the input, eddy

that didnt do it, though.

Any other thoughts?

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

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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

darkxennAuthor 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
0
EDDYKTCommented:
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
0
jmundsackCommented:
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

0
EDDYKTCommented:
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?
0
jmundsackCommented:
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.

0
EDDYKTCommented:
Sorry too. I though you are the author.

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

hehe
0
jmundsackCommented:
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
0
darkxennAuthor 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
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.