Confguring WPF application to call COM component
- Is there an alternative to
CoI开发者_高级运维nitialize()
inC#/WPF
application to load and useCOM
components? - Is there any settings I need to check while creating the
WPF
application forCOM
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.
精彩评论