I wrote a simple ServicedComponent
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.EnterpriseServices;
namespace ComPlusServer
{
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("9C674ECA-1B71-42EA-9DB2-9A0EA57EC121")]
[Description("Hello Server")]
public class HelloServer : ServicedComponent
{
[Description("Say Hello!")]
public String SayHello()
{
return "Hello!, ";
}
}
}
and a Windows Forms application
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ComPlusServer;
namespace Client
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
HelloServer server = new HelloServer();
MessageBox.Show(server.SayHello(), "Message from HelloServer");
}
}
}
on the Component Services MMC, on the application properties, security tab I lowered Authentication Level for Calls to None and Impersonation Level to Identify and Unchecked Enforce access checks for this application on Authorization.
I keep getting a ServicedComponentException exception saying
Method-level role based security requires an interface definition for class method.
Any idea on this?
I believe that it means that methods of your Component class needs to be defined in an interface.
[ComVisable(true)]
public interface IHelloServer
{
public String SayHello();
}
Now have your componet class implement the interface:
[ComVisable(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComDefaultInterface(typeof(IHelloServer))]
[Guid("9C674ECA-1B71-42EA-9DB2-9A0EA57EC121")]
[Description("Hello Server")]
public class HelloServer : ServicedComponent, IHelloServer
{
[Description("Say Hello!")]
public String SayHello()
{
return "Hello!, ";
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.