E3 COM library and E3 already running

Hi everybody!

I am experiencing a very strange problem... This is the scenario:

1) I launch E3 and open project file "A"

2) I execute a .NET app I am developing (using E3 COM interface) and I open project file "B"

This is the C# code:

e3App = Activator.CreateInstance(Type.GetTypeFromProgID("CT.Application")) as IApplicationInterface;

if (e3App != null)
{
e3Job = e3App.CreateJobObject() as IJobInterface;
jobId = e3Job.Open(f);
if (jobId == 0) throw new Exception("Error while opening " + f);
}

When I execute this line:

int devicesCount = e3Job.GetAllDeviceIds(ref lstDevices);

I get the devices of project "A"!! The one I opened earlier via E3 user interface...

What I am doing wrong?

 

Thanks a lot

mm

0

Comments

8 comments
  • Just add that when I execute:

    e3App = Activator.CreateInstance(Type.GetTypeFromProgID("CT.Application")) as IApplicationInterface;

     

    a new instance of E3 appears in the Windows task bar...

    0
    Comment actions Permalink
  • In believe somewhere in the COM Help there's an example of how to connect to E3 written in VBScript where you check to see how many job IDs exist. If more than one, then tell user that script only works with single instance of E3. I've been burned so many times by this that I'm somewhat religious of only having only one instance if E3 running. 

    But you can connect to the right job. There's a cryptic section in COM help called Running Objects Table. It's written in C#. It will help direct your script to the right job. It's not automatic. I think you need a GUI to list jobs that are open.

    E3 Plugins are special in that the Application object will bind to the current instance of E3.  

     

    1
    Comment actions Permalink
  • I like this sentence, quite a lot:

    I've been burned so many times by this that I'm somewhat religious of only having only one instance if E3 running. 

    Actually even I have designed the code to check for E3 already running instances..

     

    Anyway I will  check the Help file for "Running Objects Table" to deepen the matter.

    Thanks (again and again) for your help

    0
    Comment actions Permalink
  • Hi Bob, it's me again..

    Do you also know if it is possible to "hide" the E3 instance (launched via COM) so users can't mess with it using the Windows taskbar?

    Thanks again

     

    0
    Comment actions Permalink
  • There is a startup parameter in the command line called Automation that might work:

    Set WshShell = WScript.CreateObject("WScript.Shell")
    Dim exeNamem, statusCode
    exeName = """C:\Program Files (x86)\Zuken\E3.series_2018\E3.series.exe"" /Automation"
    statusCode = WshShell.Run (exeName, 1, true)


    Not sure how else to do it.

    0
    Comment actions Permalink
  • This a nice piece of advice.. I did not know that parameter.. Unfortunately, in this case, I am not developing a VB script but I'm using Visual Studio and C# and I "launch" E3 using this line of code:

    e3App = Activator.CreateInstance(Type.GetTypeFromProgID("CT.Application")) as IApplicationInterface;

     

    With Excel (by example) there is a way like .Visible = False but, here with E3 COM I did not found anything similar... The object e3App does not have such property.. :(

    Thanks again Bob!

    mm

    0
    Comment actions Permalink
  • Maybe you can pass the Automation parameter to the Activator.CreateInstance?

    0
    Comment actions Permalink
  • Why not?

    I saw that .CreateInstance() method has a lot of overloads so maybe there is also the one I need to pass the parameter you suggested to me and then "hide" the E3 instance launched via COM...

    Thanks again

    0
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post