Re: COM interop, pathing from .NET

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: jwallison (jwallison_at_nospam.net)
Date: 07/28/04


Date: Wed, 28 Jul 2004 10:41:33 -0400


"Troy" <Troy@discussions.microsoft.com> wrote in message
news:38949575-98A8-48FF-9701-5664DCED9E4E@microsoft.com...
> I am having a problem which does not occur on all machines. I have a C#
DLL that is being accessed by a VB6 app. After specifying COM interop on
the C# project, and also using regasm /tlb on the deployed machine, the VB6
app will only 'find' the C# DLL if it located in the same directory. The C#
DLL has been registered and resides in the winnt\system32 directory, which
is in the path.
>
> Apologies if this is basic, but I could not find anything on this and only
recently ran into this problem.

===============================================
See the following:

MSDN: Working with Assemblies and the Global Assembly Cache
"In addition, you do not have to install assemblies into the global assembly
cache to make them accessible to COM interop or unmanaged code."

The following also apply:

MSDN: Exposing .NET Framework Components to COM
MSDN: Registering Assemblies with COM

If you want the down and dirty on the process that takes place when the CLR
probes for assemblies, try the Fusion Log View tool (fuslogvw.exe) - it will
show the assembly probing that takes place when an app tries to "find" a
.Net assembly.

If you are using an Installer class for your assembly, you can set the path
to your assembly by the following:

// Override the 'Install' method of the Installer class.
public override void Install( IDictionary mySavedState )
{
    base.Install( mySavedState );
    ...
    RegistrationServices rs = new RegistrationServices();
    // get refererence to your assembly
    Assembly asm;
    ... (use Assembly.GetAssembly("yourtypename") etc. here to get a
reference to your assembly)
    // set the CodeBase for your assembly
     rs.RegisterAssembly( asm, AssemblyRegistrationFlags.SetCodeBase); //
allows CLR to find the assembly when invoked from COM
    ...
}

-- 
Regards,
Jim Allison
jwallison.1@digitalcollimation.com(de-mung by removing '.1')


Relevant Pages

  • Re: I have seen some fat client Dot Net apps
    ... How do you install the CF SDK if you don't have VS? ... install CF on a device was to write a trivial CF app in VS and install ... "Borland does not have license to ship the CF assemblies. ... assemblies and run the app unchanged on the CF platform. ...
    (borland.public.delphi.non-technical)
  • Re: COM interop, pathing from .NET
    ... DLL that is being accessed by a VB6 app. ... path when locating assemblies. ...
    (microsoft.public.dotnet.framework.interop)
  • RE: Troubles deploying my application
    ... You say that you supply COM interop wrappers - does your install also install and register the COM components? ... One time I succeeded to run the app by making ... > execution and privileges to the required assemblies. ... > CodeBase: ...
    (microsoft.public.dotnet.general)
  • Re: .NET JITTing - AOT compiling - Choice?
    ... > install or at least have a choice.. ... If you know the app is going to be ... Thorpe the jitter compiles about as fast as D7. ... assemblies make a LOT of inter-module calls - System. ...
    (borland.public.delphi.non-technical)
  • Re: Namespace Question
    ... I think that now my understanding about the namespace, GUC and compilation ... >>used to install production assemblies into the global assembly cache. ... > developed a dll, if we have made a product and the product will use the ...
    (microsoft.public.dotnet.languages.vb)