Exception error occurs in WPF .NET API application and multiple copies of R8WIN.EXE or R2WIN.EXE get incorrectly loaded into memory

  • 7025231
  • 03-Aug-2021
  • 16-Sep-2021

Environment

Reflection Desktop (including Pro, for IBM, or for UNIX and OpenVMS) 16.0 and higher

Situation

An exception error can occur randomly in a Reflection Desktop Windows Presentation Foundation (WPF) .NET API application and multiple copies of R8WIN.EXE or R2WIN.EXE (depending on the host connection type) will appear to get incorrectly loaded into memory.  This situation can occur if the application connects to the host, does some processing, and then disconnects the host session, but eventually reconnects this same host session, without removing the calling WPF application from memory.  When the reconnect occurs, an additional copy of R8WIN.EXE or R2WIN.EXE can get loaded in memory at this time and all internal references to the previous Reflections Desktop processes are lost and the following types of exception errors can then occur:

System.Runtime.Remoting.RemotingException: Requested Service not found   
Server stack trace:     
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)   Exception rethrown at [0]:     
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)    
at Attachmate.Reflection.Emulation.IbmHosts.IIbmTerminal.get_IsConnected()    
at Attachmate.Reflection.Emulation.IbmHosts.IbmTerminal.get_IsConnected() 
   

        or

System.Runtime.Remoting.RemotingException: Object '<object name>' has been disconnected or does not exist at the server.   
Server stack trace:     
at System.Runtime.Remoting.Channels.ChannelServices.CheckDisconnectedOrCreateWellKnownObject(IMessage msg)    
at System.Runtime.Remoting.Channels.ChannelServices.DispatchMessage(IServerChannelSinkStack sinkStack, IMessage msg, IMessage& replyMsg)   Exception rethrown at [0]:     
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)    
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)    
at Attachmate.Reflection.Emulation.IbmHosts.IIbmTerminal.get_IsConnected()    
at Attachmate.Reflection.Emulation.IbmHosts.IbmTerminal.get_IsConnected() 
  

Resolution

To resolve this issue, make sure the Reflection .NET API InitInstance() method is only called one time while a .NET application is loaded, as shown in the example code at:
https://www.microfocus.com/documentation/reflection-desktop/17-0/net-guide/using-wpf-tuc.html

Cause

Certain Windows Presentation Foundation (WPF) applications can cause the Window_Loaded() event to fire more than once. Additional Reflection Desktop terminal controls can thus be unintentionally launched if calling the InitInstance() method every time the Window_Loaded() event is executed. This causes the WPF application to lose its connection to the previously loaded Reflection Desktop terminal control, eventually resulting in an exception error.