Re: App.path - equivalent - in an interop DLL

From: Ellen (bottas_at_kkl.com)
Date: 05/18/04


Date: Tue, 18 May 2004 11:59:53 -0400


[I know it's lame to answer myself, but I figured someone else might
come looking for this later.]

Ellen wrote:
> I want this to work with COM interop too, so
> I can hook it into some existing VB6 apps. AFAIK, part of registering a
> .NET DLL for use with interop is registering it into the GAC with
> gacutil. Is that strictly necessary?

To answer my own question: No. The alternative:

1) Make sure you have a public interface available, and make sure Class1
implements it.
2) set project properties to "Register for COM Interop" = True
3) in AssemblyInfo.cs, add attributes:
        [assembly: ComVisible(true)]
        [assembly: ClassInterface(ClassInterfaceType.None)]
4) generate guids for the interface and the class to keep binary
compatibility (so you can use early binding in your VB6 project).

Beware though, .NET insists on copying the damn thing into C:\Documents
and Settings\{profile}\etc etc... and working from that copy *WHILE
YOU'RE IN THE IDE*. Which is retarded, IMHO, since the final
COM-registered copy does in fact end up where you thought you were
working. But hey.

So comment out all that stuff while you're working on it and uncheck the
Register for Interop property. Set it back when you're ready to
"publish" it to COM.

>
> Because it seems that when I do *that*, the path that gets returned from
> VB6 code like:
>
> dim o as object
> set o = CreateObject("MyTest.Class1")
> msgbox o.FindMe
>
>
> is c:\windows\assembly\gac\test\1.0.1599.14565__d78c501879e5dc01\mytest.dll
>
>
> So it seems gacutil really throws things off. I guess it's because
> that's actually the executing assembly. Is there any way to trace that
> back to its original path (i.e. c:\test\mytest.dll)?
>

See above. If you don't use the GAC, then
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) will
return the path to the DLL.



Relevant Pages

  • vb.net Automation Issues - COM Interop
    ... registering it for com interop and then ... The error I am receiving is happening in VB6 when I go to compile the ... and the project is registered for COM Interop. ... Public Class ClientInterface ...
    (microsoft.public.dotnet.languages.vb)
  • Re: .Net Interop With COM and ActiveX error
    ... The VB6 DLL is still a legacy COM server that needs registering on the ... .NET COM Interop still means that the original COM DLL needs ...
    (microsoft.public.dotnet.framework.interop)
  • Re: vb6 nt service dot net interop error 429
    ... use COM Interop to create your VB6/COM object that contains all of your ... Server.exe references a vb.net dll via com ... I currently have a vb6 application running as an NT service. ... The method I am using to run the vb6 app as a service is through ...
    (microsoft.public.dotnet.framework.interop)
  • System lockup problem when trying to show dialog box
    ... though it also involves interop with VB6. ... By setting a breakpoint on the call to ShowDialog(), I can see that no other ... By reproducing the crash within a virtual machine and using windbg to force ...
    (microsoft.public.win32.programmer.ui)
  • Re: Interop Forms Toolkit - how to determine if worked
    ... to do with any sort of animosity. ... The OP has developed a VB6 application and is using the Interop Forms ... I can't begin to count the number of times ther have been venomous redirects ...
    (microsoft.public.dotnet.languages.vb)