Can't Detect Bt Documents Closed In 10.1 Sr3 S’abonner

0
Avatar
Legacy Poster

Hi,

I have an application that I am currently upgrading to use BT 10.1 SR3 Enterprise Automation from BT 9.4 SR3 EA.  The following code has worked with 9.4 to detect when the user closed the BT application window but it no longer works in 10.1:

 

            Engine btEngine = new Engine(true);
            LabelFormatDocument btDoc = Global.OpenFormatFile(editFormatFile, btEngine);
            if (btDoc == null)
                return;
            btEngine.Window.Visible = true;
            this.Visible = false;
            while (btEngine.Documents.Count != 0)
                    System.Threading.Thread.Sleep(500);
            this.Visible = true;
            btEngine.Dispose();
 
In version 9.4 btEngine.Documents.Count got set to Zero signalling that the user closed the application window (with or without saving the document).  In 10.1 the code gets stuck in the sleep loop even after the window is closed.  If I break in the debugger at that point I get:
 
?btEngine.Documents.Count
1
?btEngine.Documents[0].Status
Loaded
 
When I try accessing:  btEngine.Documents[0].FileName I get an exception:
'btEngine.Documents[0].FileName' threw an exception of type 'System.Runtime.InteropServices.COMException'
    base: {"The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))"}
 
Why is my code not working in 10.1? I found no way of detecting when the user closed the application window (I could poll btEngine.Documents[0].FileName and catch the exception but I am sure there must be a more straight forward approach).
 

 

6 commentaires

0
Avatar
Domingo Rodriguez
Modérateur
Actions pour les commentaires Permalien

You could make use of the IsAlive property of the Engine class of the Seagull.BarTender.Print assembly.

 

In fact, there are some other properties such as "Documents" property and "Window" property which you could also take a look it. You will find this information on BarTender's Help (F1 key) under the "Automating BarTender > Automation with the .NET SDKs" topic.

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

I have looked at all the properties that you are talking about including:

IsAlive (returns true), IsResponsive (returns true), Window.Visible (returns true).  Everything that I look at makes my program think that the user is still editing the label.  The only way that I can tell that the user closed the window is if I access the bEngine.Documents[0].FileName which generates an exception when the application window closes.  This behaviour is completely different than BT 9.4 SR3 and does not make any sense.  I have just upgraded to version 10.1 and I can't use this version without the SDK working properly, please forward this to your developers.

 

Thank you.

0
Avatar
Domingo Rodriguez
Modérateur
Actions pour les commentaires Permalien

Further questions I would like to ask you:

 

  • On which version and service pack of Windows is BT v10.1 SR3 installed?
  • Was BT v9.4 SR3 running on the exact same computer and Windows version?
  • Is the BarTender engine running as an application or under a service context?
0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Bar tender 9.4 and 10.1 were both tested on the same Windows 7 Ultimate machine, in both cases BarTender was installed locally as an application.

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

I also got the same results (with 10.1) on Windows 8.1Pro.

0
Avatar
Domingo Rodriguez
Modérateur
Actions pour les commentaires Permalien

Could you also let me know if the BarTender engine (started by your .NET SDK program) is being started under a service context? This would imply that when you open the Windows task manager, the "bartend.exe" process is being launched under a different Windows user account than the one you're currently logged as.

Vous devez vous connecter pour laisser un commentaire.