 |
|

07-04-2006, 10:50 AM
|
|
Freshman
|
|
Join Date: Jul 2006
Posts: 28
|
|
Calling c# dll in VB 6
|
PLease Need help, I need to call a dll made in c#.. Hope you can give me a way to do this..
I tried a code in VB, I registered the dll of c# thenrefence the dll.
In my code, I put:
Dim testdll as nameobject
set testdll = new nameobject
then I called and set values to property of the nameobject. But when I run the project, It gives me an error of Missing namespace..
|
|

07-04-2006, 11:51 AM
|
 |
Hopelessly confused...
* Expert *
|
|
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,054
|
|
|
Hello, and welcome to the forum :-)
Not every DLL can be directly imported into VB. Did you write the DLL? Are you sure it CAN be imported?
|
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)
For the love of Gold...
|

07-04-2006, 12:29 PM
|
|
Freshman
|
|
Join Date: Jul 2006
Posts: 28
|
|
|
THanks for the reply.. The dll is created in c#.. Can i give me steps to register a c# dll?? i tried the regsvr32 "Dll name" and it didnt work.. Hope you can help me.. I really need to fix it.. Thanks
|
|

07-04-2006, 12:39 PM
|
 |
Hopelessly confused...
* Expert *
|
|
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,054
|
|
it is not just a matter of registering it, the DLL its self has to be capable of being registered and imported into vb. did you write the DLL?
check out http://support.microsoft.com/kb/106553/EN-US/ for a further explanation.
|
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)
For the love of Gold...
Last edited by PrOpHeT; 07-04-2006 at 12:45 PM.
|

07-04-2006, 12:43 PM
|
|
Freshman
|
|
Join Date: Jul 2006
Posts: 28
|
|
|
No. how could i know if it can be registered and imported to vb?
can u give me instruction or ideas on how would i know??
|
|

07-04-2006, 12:46 PM
|
 |
Hopelessly confused...
* Expert *
|
|
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,054
|
|
|
Sorry. apparently you were reading while I was editing, see the link in my last post.
|
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)
For the love of Gold...
|

07-04-2006, 12:52 PM
|
|
Freshman
|
|
Join Date: Jul 2006
Posts: 28
|
|
|
can u give me steps on how to unregister dll? when i click the reference in VB it turns that I have 2 dll(the name of my dll) in the reference.. can u please give me instruction to unregister and remove the 2 dll?? thanks alot
|
|

07-04-2006, 12:58 PM
|
 |
Hopelessly confused...
* Expert *
|
|
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,054
|
|
|
if the dll CAn be registered use regsvr.exe
Register:
regsvr32.exe {path and name of dll}
unregister:
regsvr32.exe /u {path and name of dll}
as for using the dll, if you did not write it, and know it CAN be used in vb, you need to know the function names, the parameters they take, and the return data type so you can properly declare them.
|
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)
For the love of Gold...
|

07-04-2006, 01:30 PM
|
|
Freshman
|
|
Join Date: Jul 2006
Posts: 28
|
|
|
dll was loaded, BUt the DllRegisterServer entry point was not found. The file cannot be registered.. Thats the error whenever I will try to register the dll... :-( The same error when i tried to unregister the dll... Do you have any idea why it gives an error like that??
|
|

07-04-2006, 02:14 PM
|
 |
Hopelessly confused...
* Expert *
|
|
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,054
|
|
|
It is not so much an error as an explanation. it means the dll cannot be registered. Again, did you write the dll? Did you look at the link I gave you? If you did not write it, what is it?
|
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)
For the love of Gold...
|

07-04-2006, 02:35 PM
|
|
Freshman
|
|
Join Date: Jul 2006
Posts: 28
|
|
|
I read the links that you gve me, but I apologized but its not clear to me right now..
I have the code of the c# dll.. When i build the c# project it creates a dll in a given folder.. so what would I do now to be able to use that c# dll??
|
|

07-04-2006, 02:47 PM
|
|
Freshman
|
|
Join Date: Jul 2006
Posts: 28
|
|
|
In my c# dll, I have 4 projects in it, and each project contains subclasses.
project 1: subproj1
myclass1
myclass2
project 2: subproj2
project 3: subproj3
project 4: subproj4
when I complie my project, it creates myGeneric.dll
Can u please give me a way to be able to used it in my VB project??So that I could used the one of the projects in my dll..
|
|

07-04-2006, 02:50 PM
|
 |
Hopelessly confused...
* Expert *
|
|
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,054
|
|
|
The link was an answer to that question, step by step including sample code. What exactly isn't clear? Is there something in there that you do not understand? If so I could possibly explaing a section in more detail, but it pretty much covers it.
|
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)
For the love of Gold...
|

07-04-2006, 03:03 PM
|
|
Freshman
|
|
Join Date: Jul 2006
Posts: 28
|
|
|
Your link explains this:
Declare Sub getdiskinfo Lib "c:\dllartic\diskinfo.dll"
(ByVal mydrive As String, ByVal myvolume As String, free As Long)
where will I put this code?
How about the parameters? what will be the values that I'm going to put in if I will use my dll?
Thanks
|
|

07-04-2006, 03:14 PM
|
|
Freshman
|
|
Join Date: Jul 2006
Posts: 28
|
|
|
I tried it in VB but it gives me an error, runtime 453 'cannot find dll entry point..
can you give me reason why I get that kind of error.. Thanks
|
|

07-04-2006, 03:15 PM
|
 |
Hopelessly confused...
* Expert *
|
|
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,054
|
|
|
That is the import statement for your dll
Private Sub YourSubName Lib "c:\PathToYourDLL\YourDll.Dll" (ByVal WhateverArgumentsYourDllSubTakes)
you declare them at form level in the declarations section, or public in a module.
|
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)
For the love of Gold...
|

07-04-2006, 03:25 PM
|
 |
Hopelessly confused...
* Expert *
|
|
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,054
|
|
|
That is why I posted the above link, there are two sides to the coin, one is the correct use of the dll in VB, the other is that the dll is created to allow vb to use it. Since I know nothing of the DLL's internal workings or the declaration you are using I do not know what else to tell you.
|
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)
For the love of Gold...
|

07-04-2006, 03:32 PM
|
|
Freshman
|
|
Join Date: Jul 2006
Posts: 28
|
|
Quote:
|
Originally Posted by PrOpHeT
That is the import statement for your dll
Private Sub YourSubName Lib "c:\PathToYourDLL\YourDll.Dll" (ByVal WhateverArgumentsYourDllSubTakes)
you declare them at form level in the declarations section, or public in a module.
|
for example I have the name of dll is Main.dll
there are 4 sub projects:
proj1
proj2
proj3
proj4
then proj1 has 3 classes...
The first class gets 2 fields to get the name of filed and the second is the value of the field.
The next class will save the first class...
so can u please give me idea on how am i gonna do that? please... please... Im so hopeless now..
|
|

07-04-2006, 03:37 PM
|
|
Freshman
|
|
Join Date: Jul 2006
Posts: 28
|
|
|
Prophet, is there a way that i could make the dll to be like we usually do in vb, Like Dim mydll as mydllname
set mydll = new mydllname
Thanks
|
|

07-04-2006, 04:04 PM
|
 |
Hopelessly confused...
* Expert *
|
|
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,054
|
|
|
Yes if you expose the dll to com and create a wrapper you could delare it as a new instance in the vb and skip the api import.
|
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)
For the love of Gold...
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|