Dll Problem...

Dark Kai

Freshman
Joined
Sep 3, 2003
Messages
48
Hi, I've wrote a class library in VB.net and compiled it in to a dll. Is it possible to use that dll in VB6 ?? If so how ??
Thanks in advance.
 
If i remember reading about it somewhere (don't remember exactly where).

You would have to genereate strong name key using sn.exe utility then include that snk file into your project. Make the setup project for your DLL and when adding primary output select Global Cache Folder as destination folder.


Hope to help.
 
You can use the "New ComClass" in the New Class box for adding a COM based class to you're project, COM based classes can be imported into VB6 uses a Type Library(I think it is generated automatically)
 
Jitesh, I've tried using this sn.exe utility but what parameters should I pass in ? And bout the other steps could you give me a more detail explanation couze I've really don't know where to find the options(Sorry I just a beginner don't really know much bout settings :rolleyes: ).

Thanks again.
 
AndreRyan, I've3 also tried your method but it always give me an error when accessing functions in the dll. Automation error(i've no idea what is it). AndreRyan, did you test this b4 ? Am I doing something wrong ?
 
Jitesh I've tried this but still no luck.

sn -k c:\demokey.snk

vbc /t:library /keyfile:c:\demokey.snk class1.vb

gacutil -i class1.dll

regasm /tlb:class1.tlb class1.dll

after that i could reference the dll to my vb6 program but still as usual the Automation Error occurred. What is wrong ??
my class only have 1 function :

Option Explicit On
Option Strict Off

Public Class Testingclass
Public Function READTXT() As String
READTXT = "Hello World"
End Function
End Class

Is there anything wrong with my class ??
 
I managed to find the post in one of the forum and it goes like following:

--Start Post--

To do this you must first generate a new strong name key. Locate sn.exe (the default location for this file is c:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin\). Call this file from the command prompt with the following parameters:


sn.exe -k c:\MyStrongNameKey.snk


Note that (ofcourse) you may change the name of the generated file (MyStrongNameKey.snk). To make life easier you should now copy this file to your project's source folder.

To include the file into your project, add the following line of code to the AssemblyInfo:


Code:<Assembly: AssemblyKeyFile("ErrorLog.snk")>



You're done with this project now. Create a setup project for your DLL as you would usually do. When adding the primary output of your DLL project mind that you should select "Global Assembly Cache Folder" as the destination folder.

Build the project and run it, your DLL file will now be automatically installed into the GAC! Hope this helps. If you have any more questions, don't hesitate to let me know.


A few notes:
- You should generate a new SNK for each project you wish to install into the GAC;
- You don't have to generate a new SNK for each version of a project, each project can keep the same SNK throughout updates;

--End Post--

I have not tested this. But if you still couldn't get it working let me know. I would like to give it a shot.

Hope to help.
 
Thanks alot Jitesh but i've found a better way(maybe not:D)...
using interface. Works for me

public interface testinterface
sub subname()
end interface

public class testclass implements testinterface
public sub ABC() implements testinterface.subname
........
endsub
end class

If any1 have any comments or any other better solutions pls let me know(peformance isues etc)..

ps: Btw now i've many dll and tbl loaded in my vb6 reference but i've deleted the files. Is there anyway to remove it from the reference list ?? i've tried to run regsvr32 with the -u parameter but could not remove it becouze I've deleted the file :(.
 
Arrrrrrhhhhhhhh!!!!

problems with the data types now...
uhhh i can't pass an array to my functions in the dll
could some1 check this code out pls :)


This is in VB.net

Option Explicit On

Public Interface iCommonImageProcessing
Function test(ByRef temp() As Short)
End Interface

Public Class CommonProcessingFunctions : Implements iCommonImageProcessing

Public Function test1(ByRef temp() As Short) Implements iCommonImageProcessing.test
Dim te as string
Dim i, j As Integer
For j = 0 To UBound(temp, 2)
For i = 0 To UBound(temp, 1)
te = te & temp(i, j)
Next
Next
MsgBox(te)
End Function

End Class




This is in vb6

Private Sub Command1_Click()

Dim b As CommonImageProcessing.iCommonImageProcessing
Set b = New CommonImageProcessing.CommonProcessingFunctions
Dim mask(2, 2) As Integer

For j = 0 To 2
For i = 0 To 2
mask(i, j) = -1
Next
Next

b.test (mask)

end sub

PS : short in vb.net is equal to integer in vb6
 
Back
Top