9 Replies Latest reply on Apr 22, 2013 3:33 PM by mhamel

    Programatically registered context doesn't work


      Hi, I'm adding a context to module programaticcaly using this code (Before this I create a module in the Mdb with needed aliases):


      public bool ApplyAceSchedule(string executableName, string moduleName, string fullContextModulePath, double offset, double period)
      var contextRegistrationPath = MdbHelpers.GetContextPath(_serverName, executableName, moduleName, fullContextModulePath);
      var isOk = PIACEMDBFunctions.AddPIACEContextSchedule(contextRegistrationPath, CreateContextScheduleInfo(offset, period));
      return isOk;


      private NamedValues CreateContextScheduleInfo(double offset, double periodInSeconds)
      var values = new NamedValuesClass();
      values.Add("Type", 0);
      values.Add("Offset", offset);
      values.Add("Period", periodInSeconds);
      values.Add("Priority", 3);
      return values;


      The context module and also the context itself is created, visible in ACE Manager and in Mdb. But although i tried to restart the module many times - the context stays in "Starting" ot "Error" mode.. While debugging everything seems fine - the module is calculating. While testing the module with the test tool using new context - it is also calculating at first and during second test - message appears that context (context path) is unknown server which is not included in servers table - despite the message the values are calculated.

      Do I need to do something else when adding context programatically? Do I need to restart the module (not that this helps)? Any ideas why this isnt working will be higly appreciated


      Best Regards 

        • Re: Programatically registered context doesn't work

          Hi Varban!  Have you looked at this vCampus post titled Managing ACE Context by program? vcampus.osisoft.com/.../10932.aspx


          Please look through this thread - it looks very similar to what you're doing, but I cannot pick out all the differences.  Also, can you provide a screenshot of your MDB?  Let me know if the above thread helps!





            • Re: Programatically registered context doesn't work

              Kevin, thank you for your reply! The thread you have posted is helpfull, there are also some similar threads which I have found such as:



              I found the problem after i wrote this post - there was an exception thrown in ModuleDependantInitilization method when starting the calculations with the newly registered context. Still in this regard there is some thing that confuses me - as I said in debug mode the module was working properly and the test tool showed results as well - but this was misleading me. The reason for this is that these right calculation were based not on the selected context, but on the server context. The interesting thing is that even when i choose the context i want to debug or test (as i did before posting the thread) the debug or test tool is calculating allways based on the Server context. If i delete this context, i cannot debug anymode - message appears - Cannot load context "Server name", although i could have many other contexts and they are visible. Is this behaviour normal? Can somebody advise me how it could be changed?