471,570 Members | 906 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,570 software developers and data experts.

Interop call

Tim
I have a vb6 Exe. I need to call a C# dll's methods from the VB Exe. I have
used RegAsm to register the C# dll. If the VB6 Exe and the C# dll are in the
same folder, then everything is fine. But I want to place them in different
folders. When I place the VB6 Exe in a folder called 'A' and the C# dll in a
folder called 'B', the VB6 Exe throws the following error when it tries to
invoke the c# dll's method.

-2147024894 - Automation error.
The system cannot find the file specified.

What do I have to do to make it work?
Dec 22 '05 #1
6 3053
Put the asm in the new folder and reregister it. When you register dll,
actually you register a COM component ( VB6 sees your dll as a COM ).
Registration means that appropriate aliases a placed to the windows
registry. You can think of alias as
GUID <-> assembly path.

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"Tim" <Ti*@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
I have a vb6 Exe. I need to call a C# dll's methods from the VB Exe. I have
used RegAsm to register the C# dll. If the VB6 Exe and the C# dll are in
the
same folder, then everything is fine. But I want to place them in
different
folders. When I place the VB6 Exe in a folder called 'A' and the C# dll in
a
folder called 'B', the VB6 Exe throws the following error when it tries to
invoke the c# dll's method.

-2147024894 - Automation error.
The system cannot find the file specified.

What do I have to do to make it work?

Dec 22 '05 #2

"Tim" <Ti*@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
I have a vb6 Exe. I need to call a C# dll's methods from the VB Exe. I have
used RegAsm to register the C# dll. If the VB6 Exe and the C# dll are in
the
same folder, then everything is fine. But I want to place them in
different
folders. When I place the VB6 Exe in a folder called 'A' and the C# dll in
a
folder called 'B', the VB6 Exe throws the following error when it tries to
invoke the c# dll's method.

-2147024894 - Automation error.
The system cannot find the file specified.

What do I have to do to make it work?


Use regasm with the /codebase option. Another option is to install the
assembly in the GAC.

Willy.
Dec 22 '05 #3
Yes, but you should register the assembly with the /codebase option set or
you have to install the assembly in the GAC. Remember that your assembly
classes are no COM objects and they don't become COM objects even after you
register them. What you do by running regasm is effectively registering
mscoree.dll as COM server, and it's up to this server to load the assembly
(and the CLR). To make it possible to load the assembly the assembly must be
stored in the GAC, or the assembly path must be registered as well, this is
achieved by the /codebase option.
Willy.

"Vadym Stetsyak" <va*****@ukr.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Put the asm in the new folder and reregister it. When you register dll,
actually you register a COM component ( VB6 sees your dll as a COM ).
Registration means that appropriate aliases a placed to the windows
registry. You can think of alias as
GUID <-> assembly path.

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"Tim" <Ti*@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
I have a vb6 Exe. I need to call a C# dll's methods from the VB Exe. I
have
used RegAsm to register the C# dll. If the VB6 Exe and the C# dll are in
the
same folder, then everything is fine. But I want to place them in
different
folders. When I place the VB6 Exe in a folder called 'A' and the C# dll
in a
folder called 'B', the VB6 Exe throws the following error when it tries
to
invoke the c# dll's method.

-2147024894 - Automation error.
The system cannot find the file specified.

What do I have to do to make it work?


Dec 22 '05 #4
Tim

Thank you for the response.

I tried the codebase option. But, now I am getting error at the next stage.

The process that I followed is as follows:

To explain in detail, the VB Exe refers a C# dll say 'A.dll'. 'A.dll' in
turn references another c# dll 'B.dll' and a C# exe 'C.exe'. I used VS2005
IDE to generate a strong name for 'A.Dll' , B.Dll and C.exe. I have used the
same strong name key file - say abc.snk. Is that okay or do I need to have
separate strong name key files for each of the assemblies?

Then I used the RegAsm utility with /Codebase option and /tlb option to make
the necessary registry entries and generate the tlb file.

Then I re-compiled the VB exe. When I run the VB exe from the same folder as
the Managed Dll's, everything works fine.

But, if I place the VB Exe in a folder say 'FolderA' and the managed
binaries in a different folder say 'FolderB', it throws an error.
The VB exe invokes methods on A.dll, A.dll in turn accesses methods on B.dll.

At that time, error occurs.
Error: -2147024894. Could not load file or assembly 'B', version=1.0.0.0,
Culture=neutral, PublicKeyToken=b941z50222f55471' or one of its dependencies.
The system cannot find the file specified.

And as per the requirement, I shouldn't place my modules in the GAC.

Where Am I going wrong?

"Willy Denoyette [MVP]" wrote:

"Tim" <Ti*@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
I have a vb6 Exe. I need to call a C# dll's methods from the VB Exe. I have
used RegAsm to register the C# dll. If the VB6 Exe and the C# dll are in
the
same folder, then everything is fine. But I want to place them in
different
folders. When I place the VB6 Exe in a folder called 'A' and the C# dll in
a
folder called 'B', the VB6 Exe throws the following error when it tries to
invoke the c# dll's method.

-2147024894 - Automation error.
The system cannot find the file specified.

What do I have to do to make it work?


Use regasm with the /codebase option. Another option is to install the
assembly in the GAC.

Willy.

Dec 23 '05 #5

"Tim" <Ti*@discussions.microsoft.com> wrote in message
news:E6**********************************@microsof t.com...

Thank you for the response.

I tried the codebase option. But, now I am getting error at the next
stage.

The process that I followed is as follows:

To explain in detail, the VB Exe refers a C# dll say 'A.dll'. 'A.dll' in
turn references another c# dll 'B.dll' and a C# exe 'C.exe'. I used VS2005
IDE to generate a strong name for 'A.Dll' , B.Dll and C.exe. I have used
the
same strong name key file - say abc.snk. Is that okay or do I need to have
separate strong name key files for each of the assemblies?

Then I used the RegAsm utility with /Codebase option and /tlb option to
make
the necessary registry entries and generate the tlb file.

Then I re-compiled the VB exe. When I run the VB exe from the same folder
as
the Managed Dll's, everything works fine.

But, if I place the VB Exe in a folder say 'FolderA' and the managed
binaries in a different folder say 'FolderB', it throws an error.
The VB exe invokes methods on A.dll, A.dll in turn accesses methods on
B.dll.

At that time, error occurs.
Error: -2147024894. Could not load file or assembly 'B', version=1.0.0.0,
Culture=neutral, PublicKeyToken=b941z50222f55471' or one of its
dependencies.
The system cannot find the file specified.

And as per the requirement, I shouldn't place my modules in the GAC.

Where Am I going wrong?


By using /codebase you solved the COM issue, that is, the VB client can load
the 'assembly' through COM's native DLL load infrastruture (registry
based), but now you encounter an issue with the pure .net assembly loader
which doesn' use the registry to finf the assembly (it uses fusion). If the
GAC is not an option you should place the .NET assemblies in the path of the
client.
For more info on how .NET searches for assemblies, search MSDN for "How the
Runtime Locates Assemblies "

Willy.
Dec 23 '05 #6
Tim
Thanks Willy. That MSDN article provided the answer to my problem.
"Willy Denoyette [MVP]" wrote:

"Tim" <Ti*@discussions.microsoft.com> wrote in message
news:E6**********************************@microsof t.com...

Thank you for the response.

I tried the codebase option. But, now I am getting error at the next
stage.

The process that I followed is as follows:

To explain in detail, the VB Exe refers a C# dll say 'A.dll'. 'A.dll' in
turn references another c# dll 'B.dll' and a C# exe 'C.exe'. I used VS2005
IDE to generate a strong name for 'A.Dll' , B.Dll and C.exe. I have used
the
same strong name key file - say abc.snk. Is that okay or do I need to have
separate strong name key files for each of the assemblies?

Then I used the RegAsm utility with /Codebase option and /tlb option to
make
the necessary registry entries and generate the tlb file.

Then I re-compiled the VB exe. When I run the VB exe from the same folder
as
the Managed Dll's, everything works fine.

But, if I place the VB Exe in a folder say 'FolderA' and the managed
binaries in a different folder say 'FolderB', it throws an error.
The VB exe invokes methods on A.dll, A.dll in turn accesses methods on
B.dll.

At that time, error occurs.
Error: -2147024894. Could not load file or assembly 'B', version=1.0.0.0,
Culture=neutral, PublicKeyToken=b941z50222f55471' or one of its
dependencies.
The system cannot find the file specified.

And as per the requirement, I shouldn't place my modules in the GAC.

Where Am I going wrong?


By using /codebase you solved the COM issue, that is, the VB client can load
the 'assembly' through COM's native DLL load infrastruture (registry
based), but now you encounter an issue with the pure .net assembly loader
which doesn' use the registry to finf the assembly (it uses fusion). If the
GAC is not an option you should place the .NET assemblies in the path of the
client.
For more info on how .NET searches for assemblies, search MSDN for "How the
Runtime Locates Assemblies "

Willy.

Dec 26 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by roy | last post: by
reply views Thread by roy | last post: by
1 post views Thread by Nadav | last post: by
6 posts views Thread by Sudha | last post: by
2 posts views Thread by Steve | last post: by
6 posts views Thread by Nataraj1978 | last post: by
5 posts views Thread by =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.