I have a C# Class Library which I want to use as a COM object in VBScript. I'm using Visual Studio C# 2010 Express.

Here's the class code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace PB_GUID
{
    class PB_GUID_Encode
    {
        private Guid _myGuid;
        private string _myHexGuid;
        private string _myBase64Guid;
      
        public Guid MyGuid
        {
            get { return _myGuid; }
            set { _myGuid = value; }
        }

        public string MyHexGuid
        {
            get { return _myHexGuid; }
            set { _myHexGuid = value; }
        }

        public string MyBase64Guid
        {
            get { return _myBase64Guid; }
            set { _myBase64Guid = value; }
        }

        // Constructor
        public PB_GUID_Encode()
        {
            MyGuid = Guid.NewGuid();

            // HEX
            StringBuilder sb = new StringBuilder();
            foreach (byte b in MyGuid.ToByteArray())
            {
                sb.Append(String.Format("{0:X2}", b));
            }
            MyHexGuid = sb.ToString();

            // Base64
            MyBase64Guid = Convert.ToBase64String(MyGuid.ToByteArray());
        }
    }
}

When I build the Solution, I get the warning that the dll "does not contain any types that can be registered for COM Interop."

The Project is signed with a strong name, is set to "Make assembly COM-Visible", and I have "Register for COM interop" checked.

What more must I do to compile this as a COM object?

I fixed this... problem was using the public properties in the Constructor instead of the private fields.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.