When using the 2017R2 SDK the first camera selection always seems to fail. All subsequent selections work as expected. Is there an initialization call that is required ? The control appears but just shows a grey rectangle.

Please check if you have called all the “Initialize” methods as you need, like VideoOS.Platform.SDK.UI.Environment.Initialize. Also make sure you have called the LogConfiguration before showing the ItemPicker (if that is the one you use).

Many thanks for the prompt reply. I have double checked and I am pretty sure everything is initialized properly. I have added some additional logging and it appears that the first call to _Viewer.Initialize is throwing an exception that results in the connect call not being made. I have attached the exception below and beneath this is the call sequence that leads to the error. All subsequent calls succeed so it does appear to be an initialization type error.

Showing (@1636876 for 2 on device 1Camera 12 2 1

2017-07-24T13:51:23.073+01:00 → 3804 * WrapperTrace Attempting to show Camera 12 Server:XPCORS:milestone-xpp-p Id:312292c8-f6a5-4a71-8893-437dbe513dca, ObjectId:329ebe65-54ac-4e82-adef-7e1408661959, Type:5135ba21-f1dc-4321-806a-6ce2017343c0

2017-07-24T13:51:23.074+01:00 → 3804 * WrapperTrace Attempting to create ImageViewerControl

2017-07-24T13:51:23.095+01:00 → 3804 * WrapperTrace ImageViewerControl created True

2017-07-24T13:51:23.114+01:00 → 3804 * WrapperTrace ImageViewerControl added to tile.

2017-07-24T13:51:23.115+01:00 → 3804 * WrapperTrace ShowVideo camera FQID Camera 12 Server:XPCORS:milestone-xpp-p Id:312292c8-f6a5-4a71-8893-437dbe513dca, ObjectId:329ebe65-54ac-4e82-adef-7e1408661959, Type:5135ba21-f1dc-4321-806a-6ce2017343c0

2017-07-24T13:51:23.136+01:00 → 3804 * WrapperTrace ImageViewerControl properties set.

2017-07-24T13:51:23.136+01:00 → 3804 * WrapperTrace ImageViewerControl quality set.

2017-07-24T13:51:23.136+01:00 → 3804 * WrapperTrace ImageViewerControl Bounds.{X=0,Y=0,Width=1133,Height=614}

2017-07-24T13:51:23.193+01:00 → 3804 * WrapperTrace ShowVideo error Camera 12 Overflow or underflow in the arithmetic operation. Overflow or underflow in the arithmetic operation. at System.Double.Equals(Object obj)

at System.Object.Equals(Object objA, Object objB)

at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)

at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)

at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)

at System.Windows.FrameworkElement.set_Height(Double value)

at System.Windows.Forms.Integration.ElementHost.InitializeChildProperties()

at System.Windows.Forms.Integration.ElementHost.set_Child(UIElement value)

at VideoOS.Platform.SDK.UI.DirectX.ImageViewerDirectX..ctor()

at VideoOS.Platform.SDK.UI.SDKImageViewerControl.Create()

at VideoOS.Platform.SDK.PlatformImageViewerControl.Initialize()

at MilestoneWrapper.MilestoneViewer.ShowVideo(IMilestoneItem item, IMilestonePlaybackController playbackController)

2017-07-24T13:51:23.193+01:00 → 3804 * WrapperTrace End of ShowVideo.

public void ShowVideo(IMilestoneItem item, IMilestonePlaybackController playbackController)

{

  if (\_viewer == null)

  {

    try

    {

      try

      {

        \_api.AddTrace("Attempting to create ImageViewerControl");

        \_viewer = ClientControl.Instance.GenerateImageViewerControl();

        \_api.AddTrace("ImageViewerControl created " + (\_viewer != null).ToString());

        if (\_viewer != null)

        {

          \_viewer.Dock = DockStyle.Fill;

          this.Controls.Clear();

          this.Controls.Add(\_viewer);

          \_api.AddTrace("ImageViewerControl added to tile.");

          \_viewer.CameraFQID = item.FQID;

          \_api.AddTrace("ShowVideo camera FQID " + [item.Name](https://item.Name) + " " + \_viewer.CameraFQID.ToString());

          if (playbackController != null)

          {

            \_viewer.PlaybackControllerFQID = playbackController.playbackFQID;

            \_api.AddTrace("ShowVideo Playback" + playbackController.playbackFQID.ToString());

          }

          \_viewer.EnableVisibleHeader = true;

          \_viewer.EnableVisibleCameraName = \_showCameraName;

          \_viewer.EnableVisibleLiveIndicator = true;

          \_viewer.EnableVisibleTimeStamp = \_showTimestamp;

          \_viewer.EnableMousePtzEmbeddedHandler = false;

          \_viewer.SetBounds(0, 0, this.Width, this.Height);

          //\_viewer.SetVideoQuality(100);

          //\_viewer.SetVideoResolutionAndFPS(\_viewer.Size, ImageViewerControl.FPSRate.High);

          \_viewer.SetVideoQuality(0, 1);

          \_api.AddTrace("ImageViewerControl properties set.");

          //      \_imageViewerControl1.ImageOrPaintInfoChanged += ImageOrPaintChangedHandler;

          \_api.AddTrace("ImageViewerControl quality set.");

          \_api.AddTrace("ImageViewerControl Bounds." + \_viewer.Bounds.ToString());

          \_viewer.Initialize();

          \_viewer.Connect();

          \_api.AddTrace("ImageViewerControl Initialized.");

          \_viewer.Selected = true;

          \_viewer.BringToFront();

          \_viewer.ConnectResponseEvent += new ConnectResponseEventHandler(\_viewer\_ConnectResponseEvent);

        }

      }

      catch (Exception E)

      {

        \_api.AddTrace("ShowVideo error " + [item.Name](https://item.Name) + " " + E.Message + " " + ExceptionExtensions.GetAllInnerExceptions(E));

      }

    }

    finally

    {

      \_api.AddTrace("End of ShowVideo.");

    }

  }

  else

  {

    \_viewer.Connect();

  }

}

Are you calling this method from your window constructor?

Otherwise could you start the app in VS, and check-mark the specific exception (Overflow or underflow in the arithmetic operation) - and see what the Double values actaul are - I can only guess that some size is invalid.

The strange thing is I dont get the issue on a Win10 64 bit laptop but with the exact same binaries this issue occurs on several win7 64 bit workstations. I have captured a crash dump and the call stack to error originates from the sequence

PlatformImageViewerControl.Initialize()

SDKImageViewerControl.Create()

videoOS.Platform.SDK.UI.dll!VideoOS.Platform.SDK.UI.DirectX.ImageViewerDirectX.ImageViewerDirectX()

This then seems to go in to a setter for a FrameworkElement.Height.Set() with a double that evaluates to NaN.

I dont understand why this would only fail on certain platforms and only the very first time of calling. Given that the call seems to originate from ImageViewerDirectX is there an API initialization for the DirectX layer that I should be calling somewhere ?

Is it possible this might be DirectX version or graphics card specific ?

Best regards,

Damien.

This sounds like missing C++ library or .Net version. For most of the C++ libraries, I thing we include this with MIPSDK - but I am not sure if the installer or app checks for .Net version.

In general we use .Net 4.0 and up to .Net 4.5.2

I can reproduce this on other Win7 64 bit platforms using .Net 4.5.2 with the 32Bit SDK. If I change the initialization to set

EnvironmentManager.Instance.EnvironmentOptions[“UseActiveX”] = “Yes”;

instead of “No”

then the problem is not observed. This would suggest that there is something wrong in the initialization order when this flag is set to no but I cannot see anything in the way I am utilizing the SDK that might affect this. If you have any suggestions or tests I can try to identify the exact nature of the problem please let me know.

Best regards,

Damien.

When the UserActiveX flag is set to yes, the SDK will expect the ImageViewerDotNet.dll to be registered, otherwise it fails - e.g. register with “RegSvr32 ImageViewerDotNet.dll” – or that the app config is defined to load it from local directory. Also, the registration will need to be performed once for 32-bit and once for 64 bit, and the 64-bit must be executed by a window that “runs as administrator” - wird stuff.

All this is not required if you set UserActiveX = No

With regard to this issue I have installed

Windows 6.1-KB2670838-x64 and

NDP47-KB3186497-x86-x64-ALLOS-ENU

and this seems to have resolved the issue (at least so far).

The very first camera selection is still a little slow to connect but no longer throws any errors and does start displaying video after a second or so. All subsequent selections are more or less instantaneous.

Best regards,

Damien.