如何在实例化的COM对象中自动打开窗体?

时间:2017-03-02 09:02:39

标签: c# com

美好的一天。我有这个任务,我需要创建一个Windows调试器表单,接受来自uiagent运行的javascript文件的请求。它将使用COM对象实现。我已经使用c#创建了一个COM对象并成功注册了它。我还成功地在java脚本文件中实例化了COM对象,并且cal已经从我的COM对象执行了一个函数。我的问题是,从我的COM对象,我如何实例化一个窗体并在我的COM对象实例化时自动打开该窗体?

我尝试过:

名称空间是RouterInterface

表单名称是DebuggerforMexUI

[Guid("xxxxxxx")]
public interface IConnection
{
    void SendToDebugger(string rawData);
}

[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("xxxxxx")]
[Guid("xxxxxx")]
public class XConnection : IConnection
{
    static XConnection instance;

    public static XConnection Singleton
    {
        get { return instance; }
    }

    public XConnection()
    {
    #if STRICT_INSTANCE
        if (instance != null)
        {
            throw new InvalidOperationException("AppRouter should be singleton");
        }
    #endif
        instance = this;

        try
        {
            DebuggerforMexUI dbgr = new DebuggerforMexUI();  **// This will    generate an error. "Object reference not set to an instance of an object."**
        }
        catch(Exception ex)
        {
        }
    }

public void SendToDebugger(string rawData)
{

}

0 个答案:

没有答案
相关问题