Connecting to specific Inventor instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear reader,
I have built an Inventor tool for Inventor 2010. Since I have dfferent versions of Inventor running, I would like to reach out to a specific version.
This is the C# code I use
try
{
// Attempt to get a reference to a running instance of Inventor.
oApp = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");
}
catch
{
}
if (oApp == null)
{
try
{
// Start Inventor.
System.Type oType = System.Type.GetTypeFromProgID("Inventor.Application");
oApp = (Inventor.Application)System.Activator.CreateInstance(oType);
// Make Inventor visible.
oApp.Visible = true;
}
catch
{
}
}
When I run this code on a system where only Inventor 2010 is installed, it works fine. When I run this on a system that has Inventor 2011 or 2012 installed, it allways opens the most recent version.
I would like to know if it is possible to always let this code start up Inventor 2010, even if 2011 or 2012 is installed.
Your help is much appreciated!
Best regards,
Klaas