Use .Net created dll in VB6?

A

awan

I need to call a .net created dll in VB6 project. It always give me this
error, when I create instance of this class

"error 2147024894(80070002) File or assembly name DllName, or one of its
dependencies, was not found."

This error was happened on a machine with .net runtime installed only. It
runs fine in a machine with .net developer version installed.

Does anybody has any idea? Thanks a lot!
 
S

Saradhi

There are the steps to follow:

1) Create a class library in VS choose whatever language you want either Vb.NEt or C#
2) Goto to Project Properties->ConfigurationProperties->build, check the Register for Com Interop checkbox. This creates the COM wrapper for your .NET assembly and hance need not use regasm.
3) Write whatever code you want, expose the classes publicly, expose the properties, functions you want publicly.

Now in your VB project, add the claslibrary.tlb created by the above program.
Now use the classes and fucntions as you want.

you shoudl not have any problem.
I need to call a .net created dll in VB6 project. It always give me this
error, when I create instance of this class

"error 2147024894(80070002) File or assembly name DllName, or one of its
dependencies, was not found."

This error was happened on a machine with .net runtime installed only. It
runs fine in a machine with .net developer version installed.

Does anybody has any idea? Thanks a lot!
 
M

Maher K. Al-Jendasi

Hello awan,

When you deploy a .NET DLL, and you want to use it with COM (such as VB),
you need to register it with "Regasm.exe your_aseembly_file /codebase".
you need to include the /codebase switch when registing assembly in folders
other than GAC.

To use the /codebase switch, the assembly must be strongly-named.
 
Joined
Sep 21, 2006
Messages
1
Reaction score
0
Thanks!!

Just read this thread and it fixes something which I have been trying to crack for a while now!!!
 
Joined
Aug 2, 2008
Messages
2
Reaction score
0
.Net Com Compatible DLL

hi,

I have created a .net dll with Register For Com Introp option to true and also Signed it. I have copied .dll and .tib files to another machine and registered it with Regasm command.

I opened Visual Studio 6.0 and tried to add reference of .dll file, it throws error "Can't add reference" and when I tried to add .tib file, reference added but I cannot see my Namespace/Class though they are public !

Am I missing some step over here?

Thanks

Maher K. Al-Jendasi said:
Hello awan,

When you deploy a .NET DLL, and you want to use it with COM (such as VB),
you need to register it with "Regasm.exe your_aseembly_file /codebase".
you need to include the /codebase switch when registing assembly in folders
other than GAC.

To use the /codebase switch, the assembly must be strongly-named.


--
Please feel free to contact/instant message me at:

Maher
(e-mail address removed)


"awan" <[email protected]> wrote in message
news:eV9o5cz%[email protected]...
> I need to call a .net created dll in VB6 project. It always give me this
> error, when I create instance of this class
>
> "error 2147024894(80070002) File or assembly name DllName, or one of its
> dependencies, was not found."
>
> This error was happened on a machine with .net runtime installed only. It
> runs fine in a machine with .net developer version installed.
>
> Does anybody has any idea? Thanks a lot!
>
>
 
Joined
Aug 2, 2008
Messages
2
Reaction score
0
.Net Com Compatible DLL

Hi,

It was same typical windows problem. We need to restart the machine after Regasm command.

so fixed it.

Thanks

divyesh1432 said:
hi,

I have created a .net dll with Register For Com Introp option to true and also Signed it. I have copied .dll and .tib files to another machine and registered it with Regasm command.

I opened Visual Studio 6.0 and tried to add reference of .dll file, it throws error "Can't add reference" and when I tried to add .tib file, reference added but I cannot see my Namespace/Class though they are public !

Am I missing some step over here?

Thanks
 
Joined
Oct 22, 2010
Messages
2
Reaction score
0
I am working in a development environment, and I have tried all the things discussed on this forum and others. I am using VS2008 and C# to build the dll. In VS for VB6 I can reference the .net tlb file and I can see the exposed functions in the object browser. When running the vb6 code I get a run-time error same as in the first post "-2147024894 File or assembly name MyNamespace, or one of its dependencies, was not found.".

I have a strongly signed assembly and I registered it like this "regasm.exe MyNamespace.dll /codebase /tlb:MyNamespace.tlb". I even tried late binding to the object in VB6.

my .net attributes look like this:

[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("D878834C-306E-4260-905F-BDEBDF14CBDA")]
[ComVisible(true)]
public class MyClass

I tried rebooting, that didn't help. Please help.

Thanks.
 
Joined
Oct 22, 2010
Messages
2
Reaction score
0
VB debug mode was the problem

Noyabronok said:
I am working in a development environment, and I have tried all the things discussed on this forum and others. I am using VS2008 and C# to build the dll. In VS for VB6 I can reference the .net tlb file and I can see the exposed functions in the object browser. When running the vb6 code I get a run-time error same as in the first post "-2147024894 File or assembly name MyNamespace, or one of its dependencies, was not found.".

I have a strongly signed assembly and I registered it like this "regasm.exe MyNamespace.dll /codebase /tlb:MyNamespace.tlb". I even tried late binding to the object in VB6.

my .net attributes look like this:

[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("D878834C-306E-4260-905F-BDEBDF14CBDA")]
[ComVisible(true)]
public class MyClass

I tried rebooting, that didn't help. Please help.

Thanks.


Well, to help someone else out in case they run into this problem. I had to build the EXE in VB6 and then run the exe directly without the debugger. Somehow the debugger wouldn't let me load the assembly no matter what I tried.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top