Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 401
  • Last Modified:

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
0
darkxenn
Asked:
darkxenn
  • 5
  • 3
  • 3
2 Solutions
 
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
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.

 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now