Automation error while creating .Net COM visibility class

I created COM-interop.dll using this simple class:

using System.Runtime.InteropServices;

namespace ClassLibrary1
{
    [ComVisible(true)]
    [Guid("795ECFD8-20BB-4C34-A7BE-DF268AAD3955")]
    public interface IComWeightedScore
    {
        int Score { get; set; }
        int Weight { get; set; }
}

[ClassInterface(ClassInterfaceType.None)]
[Guid("9E62446D-207D-4653-B60B-E624EFA85ED5")]
public class ComWeightedScore : IComWeightedScore
{

    private int _score;

    public int Score
    {
        get { return _score; }
        set { _score = value; }
    }
    private int _weight;

    public int Weight
    {
        get { return _weight; }
        set { _weight = value; }
    }

    public ComWeightedScore()
    {
        _score = 0;
        _weight = 1;
    }
  }

} I registered it using: C: \ WINDOWS \ Microsoft.NET \ Framework \ v4.0.30319 \ regasm C: \ ComClasses \ Classlibrary1.dll / tlb: Classlibrary1.tlb

Finally, I successfully added a link to the .dll, after which VB6 gave me intellisense for the object.

Private Sub Form_Load()
    Dim score1 As ComWeightedScore

    Set score1 = New ComWeightedScore
    score1.Score = 500

End Sub

An Set score1=new ComWeightedScoreautomation error occurs on the line .

It can hardly be simpler than this ... Where is the mistake ?!

+5
source share
2 answers

You forgot the / codebase option on the Regasm.exe command line.

GAC gacutil.exe. , .

+7

64- , "CPU-Any", x86, dll 64- COM + .

32, 64- :

% windir%\Microsoft.NET\Framework\v4.0.30319\regasm "Contoso.Interop.dll" /tlb:Contoso.Interop.tlb /codebase Contoso.Interop

% windir%\Microsoft.NET\Framework64\v4.0.30319\regasm "Contoso.Interop.dll" /tlb:Contoso.Interop.tlb/codebase Contoso.Interop

+3

All Articles