Wyświetl dll dla COM Interop

Myślałem, że wiem, jak to zrobić, ale oczywiście nie, więc będę wdzięczny za pomoc! Nie mogę zmusić dll do rejestracji, więc mogę utworzyć instancję w VBS lub gdziekolwiek indziej.

Napisałem następującą klasę przykładową, zaznaczyłem „Make COM COM widoczny”, zaznaczyłem „Register for COM Interop”, a następnie go zbudowałem. Kiedy próbuję utworzyć instancję z VBS, pojawia się błąd „Składnik ActiveX nie może utworzyć obiektu”.

To jest kod klasy:

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

namespace Smurf
{
    public class Pants
    {
        public string Explode(bool Loud)
        {
            string result;
            if (Loud)
                result = "BANG";
            else
                result = "pop";
            return result;
        }
    }
}

... a to jest VBS:

Dim a

Set a = CreateObject("Smurf.Pants")

msgbox("ok")

Co jeszcze muszę zrobić?

Dzięki :)

[edytować]

Zapomniałem wspomnieć, że po pierwszej awarii próbowałem REGSVR32 i REGASM - bez pomocy!

[/edytować]

Zauważ, że gdy próbuję REGSVR32, otrzymuję następujący komunikat:

Moduł „C: ... Smurf.dll” został załadowany, ale nie znaleziono punktu wejścia DllRegisterServer. Upewnij się, że „C: ... Smurf.dll” jest prawidłowym plikiem DLL lub OCX, a następnie spróbuj ponownie.

Jak pomocne jest to?

To jest najnowsza wersja kodu:

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

namespace Smurf
{
    [Guid("EAA4976A-45C3-4BC5-BC0B-E474F4C3C83F")]
    public interface IPants
    {
        [DispId(1)]
        string Explode(bool Loud);
    }

    [Guid("7BD20046-DF8C-44A6-8F6B-687FAA26FA71"),
        InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface IPantsEvents
    {
        string Explode(bool Loud);
    }

    [ComVisible(true)]
    [Guid("0D53A3E8-E51A-49C7-944E-E72A2064F938"),
        ClassInterface(ClassInterfaceType.None),
        ComSourceInterfaces(typeof(IPantsEvents))]
    public class Pants : IPants
    {
        public Pants() { }

        [ComVisible(true)]
        [ComRegisterFunction()]
        public static void DllRegisterServer(string key) { }
        [ComVisible(true)]
        [ComUnregisterFunction()]
        public static void DllUnregisterServer(string key) { }

        [ComVisible(true)]
        public string Explode(bool Loud)
        {
            string result;
            if (Loud)
                result = "BANG";
            else
                result = "pop";
            return result;
        }
    }
}

questionAnswers(1)

yourAnswerToTheQuestion