quote:
Originally posted by CookieRevised
quote:
Originally posted by felipEx
quote:
COM classes must have a parameterless Public Sub New() constructor, or the class will not register correctly
Walkthrough: Creating COM Objects with Visual Basic .NET
That only applies for VB.NET (right?).
He is using C#...
It doesn't matter at all if it's C#/VB.NET, COM classes must have a parameterless constructor in order to register correctly. Sorry if I wasn't clear in the first place
Just made a quick test and it's working:
Spoiler:
C# code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace MyDLL
{
[ComVisible(true)]
public class Operations
{
/// <summary>
/// Parameterless constructor required in order to register correctly
/// </summary>
public Operations()
{
}
public string getValue1(string sParameter)
{
switch (sParameter)
{
case "a":
return "A was chosen";
case "b":
return "B was chosen";
case "c":
return "C was chosen";
default:
return "Other";
}
}
public string getValue2()
{
return "From VBS String Function";
}
}
}
JScript code:
var x = new ActiveXObject("MyDLL.Operations");
Debug.Trace(x.getValue2());
x = null;
quote:
Originally posted by output
Script is starting
Script is now loaded and ready
Function called: OnEvent_Initialize
From VBS String Function