I've seen several messages and read through them and MANY websites and
various MSDN items and still don't have a solution.
I made a dll in C# from the code below for testing
using System;
using System.Runtime.InteropServices; // necessary library to use COM
attributes
namespace mcMath
{
/// <summary>
/// Summary description for Class1.
/// </summary>
///
[ComVisible(true)]
[ProgId("mcMath.mcMath")]
[Guid("2A77EA02-8617-43a7-B5D9-1FE09153AC07")]
[ClassInterface(ClassInterfaceType.None)]
public class mcMathComp
{
private bool bTest = false;
public mcMathComp()
{
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// //This is a test method
/// </summary>
public void mcTestMethod()
{
}
public long Add(long val1, long val2)
{
return val1 + val2;
}
/// <summary>
/// //This is a test property
/// </summary>
public bool Extra
{
get
{
return bTest;
}
set
{
bTest = value;
}
}
}
}
From the various sites and info I've read, I added the interop using
lline and also the three lines
[ComVisible(true)]
[ProgId("mcMath.mcMath")]
[Guid("2A77EA02-8617-43a7-B5D9-1FE09153AC07")]
[ClassInterface(ClassInterfaceType.None)]
The guid string I got from having the code for the dll open and going
to Tools > Create UID and chose Registry Format
I then dropped to command line and ran
C:\Documents and Settings\Tony\My Documents\Visual Studio
2005\Projects\mcmath\mcmath\bin\Debug>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\REGASM.exe
mcmath.dll /tlb:mcmath.pdb
After all that, I could finally see it to add it as a reference to a
vb6 app, but when I do, the actual methods aren't available.. only
thing I have are things like tostring and gethash ..
I did some more reading and found some info to do the below
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin>gacutil.exe /i
"C:\Documents and Settings\Tony\My Documents\Visual Studio
2005\Projects\mcmath\mcmath\bin\Debug\mcmath.dll"
Microsoft (R) .NET Global Assembly Cache Utility. Version2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
Failure adding assembly to the cache: Attempt to install an assembly
without a strong name
----
Did some more reading and then did the below
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin>sn -k
"C:\Documents andSettings\Tony\My Documents\Visual Studio
2005\Projects\mcmath\mcmath\bin\Debug\mcmath.dll"
Microsoft (R) .NET Framework Strong Name Utility Version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
Key pair written to C:\Documents and Settings\Tonyk\My
Documents\Visual Studio
2005\Projects\mcmath\mcmath\bin\Debug\mcmath.dll
----
Great, I thought... Now I can do the gacutil again and be home free.
wrong... :(
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin>gacutil.exe /i
"C:\Docum
ents and Settings\Tonyk\My Documents\Visual Studio
2005\Projects\mcmath\mcmath\b
in\Debug\mcmath.dll"
Microsoft (R) .NET Global Assembly Cache Utility. Version
2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
Failure adding assembly to the cache: The module was expected to
contain an assembly manifest.
---
After every task leading to another task in my effort to get a C# .dll
to run under VB6, I'm begining to think maybe I'm following the wrong
trail of bread crumbs and this should be a lot simplier than I'm
finding?
In the end, I'm looking to use a .Net component in C# and pop the code
into a .dll that a vb6 app can use
Help?
-Tony!-
sloan - 17 Sep 2006 02:21 GMT
This may or may not help.
I had it bookmarked.
http://msdn.microsoft.com/vbrun/vbfusion/usingnet/default.aspx
> I've seen several messages and read through them and MANY websites and
> various MSDN items and still don't have a solution.
[quoted text clipped - 66 lines]
> I then dropped to command line and ran
> C:\Documents and Settings\Tony\My Documents\Visual Studio
2005\Projects\mcmath\mcmath\bin\Debug>C:\WINDOWS\Microsoft.NET\Framework\v2.
0.50727\REGASM.exe
> mcmath.dll /tlb:mcmath.pdb
>
[quoted text clipped - 56 lines]
>
> -Tony!-
Jon Davis - 17 Sep 2006 05:43 GMT
That link is completely dependent upon an "FCL" which appears to be a
downloadable type library that VB6 can call to invoke .NET assemblies. No
offense but I wouldn't recommend that to someone who is trying to learn
fundamentally how to expose their .NET solution directly to COM.
Jon
> This may or may not help.
>
[quoted text clipped - 135 lines]
>>
>> -Tony!-
Jon Davis - 17 Sep 2006 03:03 GMT
Your GAC error related to the missing assembly manifest. Did you look into
that?
Regardless, GAC installation is not used by the COM registration system that
VB6 uses, it is only used by other .NET assemblies for global invocation
rather than file-based invocation. You need to use regasm.exe to register
your .NET solution as a COM component / control that VB6 can use.
Jon
> I've seen several messages and read through them and MANY websites and
> various MSDN items and still don't have a solution.
[quoted text clipped - 127 lines]
>
> -Tony!-
Tony - 17 Sep 2006 04:01 GMT
I tried the regasm bit (see down near bottom of my orig post).
It worked but when I instantiate an object using the dll in vb6 all
the methods and properties object.notation shows is "Equals"
"GetHashCode", "GetType", and "ToString"
-Tony!-
>Your GAC error related to the missing assembly manifest. Did you look into
>that?
[quoted text clipped - 137 lines]
>>
>> -Tony!-
Jon Davis - 17 Sep 2006 05:48 GMT
Sorry, I missed it, see it now.
For what it's worth I'd say restart your research with these links:
http://msdn.microsoft.com/netframework/programming/interop/default.aspx?pull=/li
brary/en-us/dndotnet/html/useframewktools.asp
http://msdn.microsoft.com/msdnmag/issues/01/08/Interop/
http://msdn.microsoft.com/netframework/programming/interop/default.aspx?pull=/li
brary/en-us/dndotnet/html/callnetfrcom.asp
Forgive me for not knowing the quick answer to your problem.
- Jon
>I tried the regasm bit (see down near bottom of my orig post).
>
[quoted text clipped - 146 lines]
>>>
>>> -Tony!-
Phil Wilson - 17 Sep 2006 21:22 GMT
This is what looks wrong to me:
1. If you're using ClassInterfaceType.None it means that no class interface
is generated, and that means you have to define an interface and implement
it. See this:
http://blogs.gotdotnet.com/heaths/archive/2005/03/09/391358.aspx
Define your interface and have the class implement it. This is basically why
none of your methods are showing up.
2. Getting it registered is nothing to do with the GAC. Use regasm to
register using regasm <path to assembly> and add /codebase if you want to
use from a non-GAC location. The GAC is a deploymemt choice, not a
requirement for registered .NET COM classes to be available.
3. Generating a type library is primarily for design time. It so happens
that running regasm to register the assembly will register the COM class
interfaces as well as the type library, but the type library is mainly a
development help in this situation because that's what you browse for in the
VB IDE to find COM references. For a program to use the COM classes at run
time, regasm <assembly> /codebase is fine.

Signature
Phil Wilson
[Microsoft MVP-Windows Installer]
> I've seen several messages and read through them and MANY websites and
> various MSDN items and still don't have a solution.
[quoted text clipped - 127 lines]
>
> -Tony!-
Dule - 27 Sep 2006 20:44 GMT
Hi Tony,
Did you try to extend your class from
System.EnterpriseServices.ServicedComponent ? You should add reference to
System.EnterpriseServices package.
- Dusko
> I've seen several messages and read through them and MANY websites and
> various MSDN items and still don't have a solution.
[quoted text clipped - 127 lines]
>
> -Tony!-