开发者

Confguring WPF application to call COM component

  • Is there an alternative to CoI开发者_高级运维nitialize() in C#/WPF application to load and use COM components?
  • Is there any settings I need to check while creating the WPF application for COM compliance?


You could do something like this; you just need to know the ProgID of the COM component.

public static object COMCreateObject (string sProgID)
{
    // We get the type using just the ProgID
    Type oType = Type.GetTypeFromProgID (sProgID);
    if (oType != null)
    {                   
        return Activator.CreateInstance(oType);
    }

    return null;
}

Assuming you're working within the .Net 3.5 or 4.0 Framework, your WPF application can handle the creation and destruction of COM objects out-of-the-box, just make sure you're you're properly disposing of them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜