For the following Situation:
In Table 18 Customer
Trigger OnModify:
(…)
FMXIntegrationManagement.CreateMessage(Customer);
(…)
Where:
CreateMessage(Customer : Record Customer)
InitNavComCom();
IF NOT XMLPORT.EXPORT(XMLPORT::ACCMOD,OutS,Customer) THEN BEGIN
MESSAGE(Text002,XMLPORT::ACCMOD);
END;
IF NOT OutMsg.Send(0) THEN BEGIN
MESSAGE(Text003,XMLPORT::ACCMOD)
END;
Where :
InitNavComCom()
IF ISCLEAR(MQBus) AND ISCLEAR(CC2) THEN BEGIN
IF ISSERVICETIER THEN BEGIN
IF (NOT CREATE(MQBus,TRUE,TRUE)) OR (NOT CREATE(CC2,TRUE,TRUE)) THEN BEGIN
ERROR(Text001);
END;
END ELSE BEGIN
IF (NOT CREATE(MQBus,TRUE)) OR (NOT CREATE(CC2,TRUE)) THEN BEGIN
ERROR(Text001);
END;
END;
END;
CC2.AddBusAdapter(MQBus,1);
CompanyInformation.GET;
MQBus.OpenWriteQueue(CompanyInformation.“FMX Trigger Queue Name”,0,0);
OutMsg := CC2.CreateoutMessage(‘Message queue://’+CompanyInformation.“FMX Trigger Queue Name”);
OutS := OutMsg.GetStream();
Variables:
Name DataType Subtype
MQBus Automation ‘Navision MS-Message Queue BusAdapter’.MSMQBusAdapter
CC2 Automation ‘Navision Communication Component version 2’.CommunicationComponent
OutMsg Automation ‘Navision Communication Component version 2’.OutMessage
OutS OutStream
CompanyInformation Record Company Information
In Classic Client, results are as expected: modifying a Customer creates a Message.
But In RoleTailored Client, when pressing OK button after modfying a Customer record, the error:
“The Server net.tcp://localhost:7046/DynamicsNAV/Service is either unavailable or oyur connection has been lost. Do you want to attempt to reconnect?”
When choosing yes or no, the following error occurs: “The connection to the servers has been lost. The application will close.”
Investigating a litle bit further, Computer Management → System Tools → Event Viewer → Windows Logs-> Application, found the following error:
Service: MicrosoftDynamicsNavServer#### User: FR8\aluna#### Type: System.InvalidCastException#### Message: Unable to cast object of type ‘Microsoft.Dynamics.Nav.Runtime.NavAutomation’ to type ‘Microsoft.Dynamics.Nav.Runtime.NavStream’.#### StackTrace:#### at Microsoft.Dynamics.Nav.Runtime.NavAutomation.InvokeMethod[T](String methodName, Object[] arguments)#### at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit50002.InitNavComCom()#### at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit50002.CreateMessageACCMOD(INavRecordHandle customer)#### at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit50002.OnInvoke(Int32 memberId, Object[] args)#### at Microsoft.Dynamics.Nav.Runtime.NavApplicationObjectBase.Invoke(Int32 methodId, Object[] arguments)#### at Microsoft.Dynamics.Nav.BusinessApplication.Record18.OnModify()#### at Microsoft.Dynamics.Nav.Runtime.NavRecord.Modify(DataError errorLevel, Boolean runApplicationTrigger, Boolean runGlobalTrigger)#### at Microsoft.Dynamics.Nav.Service.NsDataAccess.Modify(DataError errorLevel, Boolean runApplicationTrigger)#### at Microsoft.Dynamics.Nav.Service.NsFormDataAccess.Modify(DataError errorLevel, Boolean runTrigger)#### at Microsoft.Dynamics.Nav.Service.NSRecord.Modify(NavConnection con)#### at Microsoft.Dynamics.Nav.Service.NSService.<>c__DisplayClass2b.b__2a(Connection connection)#### at Microsoft.Dynamics.Nav.Service.NSService.ExecuteOperation[T](String operationName, ServiceOperation`1 operation, Connection connection, Boolean revertLanguageChanges, WindowsIdentity impersonationIdentity)#### Source: Microsoft.Dynamics.Nav.Ncl
we think this exception is caused in InitNavComCom, Line OutS := OutMsg.GetStream();