问题
Solved, see comments!
I have a simple .NET DLL written in c#.
In asp-classic or VB.NET i can create the object and call a member function in the DLL without any problem. But, and this is my stumbling point, i can't access class properties.
Here's the sample code:
[Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(IComEvents))]
public class Com : IComInterface
{
public string MyProperty{ get; set; } // <-- NOT ACCESSIBLE
public void MyFunction() // <-- ACCESSIBLE
{
}
}
Here's the server-side script:
Set com = Server.CreateObject("ns.Com") // WORKS
com.MyProperty = "abc" // GIVES ERROR
com.MyFunction // WORKS
I get the following error-message:
Microsoft VBScript Runtime Error "800a01b6'
Object Doesn't Support This Property or Method: MyProperty
Can anybody tell me, why i can call the function 'MyFunciton', but if i want to set the property-value, i get the error above?
回答1:
Properties must be included in the interface definition to make them visible to COM.
Example:
[Guid("... some GUID ...")]
[ComVisible(true)]
public interface MyClassInterface
{
string MyProperty { get; set; }
bool MyMethod();
}
来源:https://stackoverflow.com/questions/37207659/how-to-make-properties-visible-to-com-in-a-net-dll-methods-do-work