5 Replies Latest reply on Jul 24, 2012 7:28 AM by andreas

    ActiveView / Rpc server is unavailable




      I am using Active View in C# Application. In fact, it works  but when I close/open some different forms the axPbd components raise an exception like


      "Rpc server is unavailable" in a line:

      MyTrend = (PBSymLib.Trend)Trend1Display.Symbols.Add(PBObjLib.pbSYMBOLTYPE.pbSymbolTrend);

      Sometimes I got  "QI for IEnumVARIANT failed on the unmanaged server"


      I was trying to refresh the component like:

      axPbd3.DisplayURL = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\pdi\\trend3.pdi";

       It didnt help and really, really brings a lot of problem.


      Please help with it.



        • Re: ActiveView / Rpc server is unavailable

          Hi Oleg, can you tell me something more?


          I have a little C# example with two buttons next to the ActiveView ActiveX control that open another form either with .Show or with .ShowDialog and both work fine (no error, I can see my ActiveView display in the original Form still updating).

            • Re: ActiveView / Rpc server is unavailable

              Hi Andreas,


              The problem is that all samples here are supposed to have DisplayURL  pre-defined, so hardcoded when compile time.


              In my case, I am using runtime DisplayURL changed.


              As a result I add some trends on it / remove / add another trend.


              But sometimes COM Object or Display Element  is just losing the connection.


              When I add a trend like :


              MyTrend = (PBSymLib.Trend)Trend1Display.Symbols.Add(PBObjLib.pbSYMBOLTYPE.pbSymbolTrend);


              This string gives me an error (...RPC unavailable)   or other messages.


              When I catch a breakpoint in this place, the "Trend1Display" is null or, if not,


              then says something like: "cannot get a type of  PBSymLib.Trend"


              My program is supposed to stay running for days.


              So if it is not stable, the whole program is not reliable.


              I am using the AxPdb component in C# and compile it to executable file.





                • Re: ActiveView / Rpc server is unavailable



                  I tried to reproduce without luck - as you see below in my case the URL is not hardcoded, and I add a trend. When running the other form (basically only a form with one button to close it) everything continues to work fine. I let it run for hours without any issue. I did load a different PDI and still no issue.

                          private void button1_Click(object sender, EventArgs e)
                              // Open the PDI file using an OpenFileDialog
                              openFileDialog1.Filter = "PI Display Document|*.PDI";
                              openFileDialog1.Multiselect = false;
                              openFileDialog1.InitialDirectory = @"..\..\..";
                              openFileDialog1.CheckFileExists = true;
                              openFileDialog1.FileName = "";
                              // Load the PDI file into the ActiveX
                                  axPbd1.DisplayURL = openFileDialog1.FileName;
                              catch (Exception myEx)
                          private void button2_Click(object sender, EventArgs e)
                              // The Display Object
                              PBObjLib.Display MyDisplay;
                              MyDisplay = (PBObjLib.Display)axPbd1.Display;
                              // A Trend Object
                              PBSymLib.Trend MyTrend;
                              // Adding the Trend Object to the Display
                              MyTrend = (PBSymLib.Trend)MyDisplay.Symbols.Add(PBObjLib.pbSYMBOLTYPE.pbSymbolTrend);
                              // Format the Trend
                              // Set Height, Width to the visible Area
                              MyTrend.Height = (short)MyDisplay.ViewHeight;
                              MyTrend.Width = (short)MyDisplay.ViewWidth;
                              // This is TopLeft of the Display
                              MyTrend.Top = 15000;
                              MyTrend.Left = -15000;
                              // Add traces
                              // Set Timerange
                              MyTrend.SetTimeRange("*-12h", "*");
                              // Set Background
                              MyTrend.BackgroundColor = vbBlack;
                              // The Trendformat
                              PBSymLib.TrendFormat MyFormat;
                              // Load the Trendformat from the Trend
                              MyFormat = MyTrend.GetFormat();
                              // Description
                              MyFormat.ShowDescription = true;
                              // EngineeringUnits
                              MyFormat.ShowEngUnits = false;
                              // The Grid
                              MyFormat.ShowGrids = true;
                              // No Servername
                              MyFormat.ShowServerName = false;
                              // But Tagname
                              MyFormat.ShowTagName = true;
                              // No Title
                              MyFormat.ShowTitle = false;
                              // No markers
                              MyFormat.ShowTraceMarkers = false;
                              // Show the Value
                              MyFormat.ShowValue = false;
                              // The Pen Colors
                              MyFormat.Elements.Item(PBSymLib.pbTrendELEMENT.pbPen1).Color = (uint)vbRed;
                              MyFormat.Elements.Item(PBSymLib.pbTrendELEMENT.pbPen2).Color = (uint)vbBlue;
                              // The Axis and Grid
                              // Horizontal
                              MyFormat.Elements.Item(PBSymLib.pbTrendELEMENT.pbHAxis).Color = (uint)vbLightGrey;
                              MyFormat.Elements.Item(PBSymLib.pbTrendELEMENT.pbHMajor).Color = (uint)vbDarkGrey;
                              MyFormat.Elements.Item(PBSymLib.pbTrendELEMENT.pbHMinor).Color = (uint)vbDarkGrey;
                              // Vertical
                              MyFormat.Elements.Item(PBSymLib.pbTrendELEMENT.pbVAxis).Color = (uint)vbLightGrey;
                              MyFormat.Elements.Item(PBSymLib.pbTrendELEMENT.pbVMajor).Color = (uint)vbDarkGrey;
                              MyFormat.Elements.Item(PBSymLib.pbTrendELEMENT.pbVMinor).Color = (uint)vbDarkGrey;
                              // The Text
                              MyFormat.Elements.Item(PBSymLib.pbTrendELEMENT.pbText).Color = (uint)vbWhite;
                              // Apply the Format to the Trend
                          private void button6_Click(object sender, EventArgs e)
                              Form2 myForm2 = new Form2();
                          private void button7_Click(object sender, EventArgs e)
                              Form2 myForm2 = new Form2();






                    • Re: ActiveView / Rpc server is unavailable

                      Hi Andreas,


                      I used the same logic as you demonstrate it above.


                      Having contacted to Tech Support, they replied me that the problem could be encountered when opening multiple instances of ActiveView in the same application.


                      Actually, I am using 2 ActiveViews on one form.


                      The problem is not consistent. This happened when close/open the form (not application).


                      After some times I get error:  "The RPC server is unavailable".


                      When close/open the form the only I am doing is  playing with Symbols like:




                      MyTrend = null;


                      foreach (PBObjLib.Symbol symbol in TrendDisplay3.Symbols) TrendDisplay3.Symbols.Remove(symbol.Name);


                      MyTrend = (PBSymLib.Trend)TrendDisplay3.Symbols.Add(PBObjLib.pbSYMBOLTYPE.pbSymbolTrend);


                      MyTrend.TrendTitle = ...




                      Technical support asked me to try some beta version.


                      I do not have this link yet but for now want to try to re-initialize the whole ActiveViews - component every time I open a form.


                      That is actually is not correct but could be a solution for me that I am trying to find urgently as customer is worrying about it.