我需要在 Windows 窗体和控制台应用程序中注册 DDE 服务器。我已经在 Windows 窗体应用程序的各个点尝试了注册码,但它似乎没有注册。我已经在 frmMain 和 Program.cs Main() 中尝试过了。
当我尝试使用 DDE 服务器时,我收到标准无法连接消息:“MainForm_Load:客户端无法连接到”CRMIntegrator|myservice”。确保服务器应用程序正在运行并且它支持指定的服务名称和主题名称一对。”
这是我的注册码:
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
try
{
// Create a server that will register the service name 'myapp'.
using (DdeServer server = new MyServer("CRMIntegrator"))
{
// Register the service name.
server.Register();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}