I'm trying to use a .NET assembly from VB6 via interop without placing it in the GAC and without using the /codebase argument for regasm.exe.
From what I understand, when I run regasm.exe on a .NET class library, it creates a registry entry for each class in the class library telling the COM clients they should load mscoree.dll that serves as a proxy wrapping .NET objects for COM use. Mscoree.dll uses the InprocServer32/Assembly key in the registry for the class to determine which class library contains the implementation of the class.
If I use /codebase with regasm.exe or put my class library in the GAC, everything works OK; but as far as I can figure out from the scattered documentation, mscoree.dll should look for the assembly in the current directory and in the path if /codebase hasn't been used (and therefore there is no CodeBase entry in the registry for the class) and it can't find it in the GAC.
The C# code is as simple as can be:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace myinterop
{
[Guid("B1D6B9FE-A4C7-11DD-B06B-E93056D89593")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
public class MyServer
{
public int Add(int a, int b)
{
return a + b;
}
}
}
And the problem reproduces with a VBScript one liner that I put in the same directory as the compiled DLL:
object = CreateObject("myinterop.MyServer")
What am I missing here? Is there a definitive description of the way mscoree.dll looks up the assemblies somewhere?
BTW, I'm using .NET 2.0 and yes, I know I should put my assemblies in the GAC, I'm just wondering why this doesn't work as advertised.