Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.dll needs modifications 2

Status
Not open for further replies.

Palmyra

Programmer
Jan 5, 2007
150
US
I have some experience with Visual Basic 6 that goes back several years. My company has a .dll application written by another programmer. I need to open the project and debug to try to fix an issue. I can probably fix the issue if I can figure out how to debug it.

I can't just put in a break point and run the application, can I? What do I need to do?

I would really like to convert this .dll to an .exe - but that would be icing on the cake.

Can someone give me some pointers or point me to some?

Thanks.
 
Plamyra said:
I would really like to convert this .dll to an .exe
A DLL is simply a library of classes and/or functions. It has no entry point, no real interface except possibly dialog boxes, no flow of control, and no shutdown procedure. Imagine for example taking the DLL that contains the FileSystemObject. If you had the source code for it, simply changing it to an EXE project would not turn it into application.

DLL projects are tested by including them in a project group. You would have one EXE project in the group that references the DLL project, and of course the DLL project. You set the EXE project as the startup project of the group. In the EXE, you use the classes and/or public functions in the DLL - and therefore you could put break points in the DLL code.

Joe Schwarz
Custom Software Developer
 
There is no way to conver .exe to .dll.
Probably if you can get the project or the class module which has been converted to dll then you may be able to figure out the issue
 
Thanks for the response. We have one application that uses a button click to call some additional functionality. The additional functionality is in the compiled .dll. The code that calls the additional functionality is something like this:

Dim appManager As RBTManager.Manager

' launch manager
Set appManager = New RBTManager.Manager
appManager.LaunchManager

I have two tasks - one to try to fix a problem in the compiled .dll(which might be pretty minor) and then 2, to hopeully, compile this .dll into an executable so that it can be launched by itself.

I may not be able to accomplish 2, but I really need to accomplish 1.

So, to be able to debug this .dll, I need to first create a project and then include the .dll in this project? I would be really grateful for some instructions on how to do that or a pointer to some info. that helps me with that.

Thanks.
 
>to debug this .dll, I need to first create a project and then include the .dll in this project

No, you need the source code. No source code, no debugging.
 
<pointer to some info
You may find faq708-5940 a decent primer for how to work with DLL source code. If you have the ActiveX DLL project, then you have the source code. If all you have is the DLL, then you don't have the source code and as strongm says you can't debug it.

Perhaps this will help clarify how a DLL works. If you go into the windows system directory, you'll find a file called CARDS.DLL. If you rename this file, you'll find that none of the windows card games work anymore. (They'll say they're looking for CARDS.DLL and can't find it.) Just as in real life, we use the same deck of cards to play all manner of different games, so it makes sense to use a single programmatically-defined deck of cards in a bunch of different computer card games. If, for example, the Ace of Spades was red instead of black (a bug, you see), you'd only have to fix it in CARDS.DLL instead of in every program that has an ace of spades. So, the point about a DLL is it avoids having multiple copies of the same code in different applications, which is very very bad.

So, why do you want to convert the dll to an exe? I like dll's.

Bob
 
There's no reason to "turn the DLL into an application". Just make a new EXE which reference the DLL, and copy the code that you have already posted into it (perhaps into the EXE's Main subroutine, if "appManager.LaunchManager" actually starts a user interface.

Joe Schwarz
Custom Software Developer
 
I have to learn to be more specific. I have the source code and a compiled .dll. Because of my lack of experience, (and because I've forgotten what I used to know) when I opened the souce code in Visual Basic I couldn't see a way to set a break point and debug. I'll look at the FAQ that BobRodes posted and try to understand how to do this.

and also Joe Schwarz' is helpful:

"DLL projects are tested by including them in a project group. You would have one EXE project in the group that references the DLL project, and of course the DLL project. You set the EXE project as the startup project of the group. In the EXE, you use the classes and/or public functions in the DLL - and therefore you could put break points in the DLL code. "

(We have some off-the-shelf industry specific software that was built in VB6, that we have limited ability to customize. We do have the source code for the .dll that I'm referring to, and I can change the call that the button makes to the .dll (or remove the button).
 
I opened my project called RCRManager.vbp. I added a standard .exe and called it TestRCRM.vbp. I renamed the form TestRCRM.frm. I added a command button to the form.

I added a Reference to RCRManager (which is the .dll living on the C: drive)

I right-mouse clicked on Project1(Testrcrm.vbp) and selected 'Set as Start up'

Under general (declarations) for the form I added:
(Intellisense found .Manager)

Dim Test1 As RCRManager.Manager
Dim Test2 As RCRManager.Manager
Option Explicit

On Private Sub Form_Load()

I added:

Set Test1 = New RCRManager.Manager
Test1.Size = 1
Set Test2 = New RCRManager.Manager
Test2.Size = 0

On Private Sub Command1_Click()
I added:
Test1.LaunchManager
Test2.LaunchManager
(LaunchManager came up with Intellisense)

I saved the project as a group and then launched the group.

I clicked on the button on my form.

First, Test1.size gave an error of 'Method or Data Member Not found'. I remarked that out and got:
got an error on Test1.LaunchManager of "Compile Error: Argument Not Optional"

I know I'm stumbling on simple things, but I'd appreciate any help out there.

Thanks.

End Sub
 
You don't want to reference the compiled DLL. What you want to do is add the source code of the DLL to the project group, that is you want to add it's Project (VBP) to the Project Group.

Then select the EXE project, and set a reference to the DLL VBP.

Then, you will be able to debug the DLL code.

Joe Schwarz
Custom Software Developer
 
Thanks. I followed your instructions. But I still get

an error on Test1.LaunchManager of "Compile Error: Argument Not Optional"

when I click my form button


This is the code for Launch Manager:

' LaunchManager
'
' Description:
' launches the records creation requet manager
'
' Arguments:
' appEnterprise Reference to Enterprise Application Object
'
' Dependencies:
' Options.Retrieve
' frmSplash
' frmManager
'
Public Sub LaunchManager(ByRef appEnterprise As Object)

On Error GoTo ErrorHandler

' if application reference specified
10 If Not (appEnterprise Is Nothing) Then

' save enterprise object reference
11 Set g_appEnterprise = appEnterprise
12 Set g_objDBSvr = appEnterprise.DB

' retrieve user options
13 Set g_objOptions = New Options
14 g_objOptions.Retrieve

' if form not present
15 If g_frmManager Is Nothing Then

' load manager form - performs initial load from database
16 Set g_frmManager = New frmManager
17 Load g_frmManager

18 End If

' show manager form
19 g_frmManager.Show vbModeless

' if no application reference specified
20 Else

21 MsgBox "No Enterprise Application Reference Specified", vbCritical + vbOKOnly, App.Title

22 End If

Exit Sub

ErrorHandler:

MsgBox "Error: " & Err.Number & vbCr & _
"Location: " & "Manager.ShowDialog" & vbCr & _
"Line: " & Erl & vbCr & _
Err.Description, vbOKOnly + vbExclamation, _
App.Title

End Sub
 
Well quite clearly LaunchManager is expecting a parameter called appEnterprise to be passed to it, which you are apparently not doing (if I look at your previous post).

What appEnterprise actually is is anyone's guess, since it is declared as a generic object. But apparently it is expected to have a property called DB. My guess would be that appEnterprise is supposed to be the host application (i.e. the one using the DLL), in other words it is making a reference to its parent.

Joe Schwarz
Custom Software Developer
 
Just load up the source for the dll. Click Project, Project Properties, Component. Click Binary Compatibility and enter the path to the registered dll. Now add break-point (F9). If you dont know the entry point but a break-point on each function/subroutine. Now hit F5 to run. Now fire-up you application. It will jump into the source.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top