S
S
Sergey Gorlanov2014-06-06 13:13:17
.NET
Sergey Gorlanov, 2014-06-06 13:13:17

C# Creating a COM Object

I created my own com-object according to the lessons.
I specified everything in Assembly.
I call:
regasm COMTest.dll
I get:
RegAsm : warning RA0000 : No types were registered

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace COMTest
{
    /// <summary>
    /// 
    /// </summary>
    [Guid("E352B5AF-B38E-4688-AE66-880AB8CC976E")]
    public interface IComObjectClass
    {
        [DispId(1)]
        void Launch(string mymessage);
    }

    /// <summary>
    /// 
    /// </summary>
    [Guid("7F6700DC-93A3-438D-9357-F5076148E89D"), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface IComObjectEvents
    {
    }

    [ClassInterface(ClassInterfaceType.None), 
    Guid("59FF1E93-9C22-4E23-A2EE-27D7270FCAD2"), 
    ComSourceInterfaces(typeof(IComObjectEvents))]
    class ComObject : IComObjectClass
    {
        public ComObject()
        {
            
        }

        public void Launch(string mymessage)
        {
            MessageBox.Show((mymessage.Equals(String.Empty) ? "Hello!" : "Hello " + mymessage), "Тест библиотека", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gorlanov, 2014-06-06
@gorlanovS

The error was class ComObject : IComObjectClass
in
public class ComObject : IComObjectClass

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question