ImageViewerWpfControl implementation not loaded

I’m trying to add a ImageViewerWpfControl into my WPF Visual Studio project but the following image shown.

I added it in by copying the following xmlns from the Milestone SDK example program: “PlaybackWpfUser”

xmlns:platformclient=“clr-namespace:VideoOS.Platform.Client;assembly=VideoOS.Platform”

and

<platformclient:ImageViewerWpfControl

x:Name=“IVCwpf”

Height=“200”

Background=“LightYellow”

FontSize=“24”

BorderBrush=“Black”

BorderThickness=“5” />

In the code behind:

IVCwpf.CameraFQID = VMS_FQIDSelectedCamera; //FQID of selected camera

IVCwpf.Initialize();

IVCwpf.Connect();

Bitmap bitmap = IVCwpf.GetCurrentDisplayedImageAsBitmap();

Thanks in advance.

This is expected, I have the same. The ImageViewerControl does not load in the Visual Studio but works at runtime.

Thanks for the reply.

The example project is still showing

"ImageViewerWpfControl implementation not loaded"

at runtime.

I found out that I was using the MIPSDK from 2017 R3,

which I then installed both the:

  1. MIP SDK 2018 R3 - Redistributable Installer x64

  2. MIP SDK 2018 R3 - Redistributable Installer x86

From https://www.milestonesys.com/my-milestone/msp/mip-sdk/

Problem still exists.

--------------------------------------------------------------------------------

I suspect the compatibility between those versions,

so I uninstalled both the x64 and x86 MIPSDK of 2017 R3,

and DELETED all the SDK files left in both Program Files and Program Files(x64)

before I reinstall MIPSDK_Installer_2018R3.msi

Now that I have a working example of PlaybackWpfUser from this SDK, but

I’m still have problem porting the code into my working project where

ImageViewerWpfControl is needed.

--------------------------------------------------------------------------------

The program throws the following exception when I try to initialize:

VideoOS.Platform.SDK.Export.Environment.Initialize();

System.IO.FileNotFoundException: ‘Could not load file or assembly ‘VideoOS.Toolkit.dll’ or one of its dependencies. The specified module could not be found.’

--------------------------------------------------------------------------------

I’m using the same set of Milestone VideoOS *.dll files as in the

PlaybackWpfUser project, except that my project is running in

.NetFramework v4.6.1 instead of v4.5 in PlaybackWpfUser.

PlaybackWpfUser has a Main() function to initialize the following:

VideoOS.Platform.SDK.Environment.Initialize();

  VideoOS.Platform.SDK.UI.Environment.Initialize();

  VideoOS.Platform.SDK.Export.Environment.Initialize();  

in its App.xaml.cs

while in my case, the Main() function is auto generated in App.g.i.cs

when I build the project.

Regards,

BC Chang

******* Update *****************

I just found that the entry point of the program has nothing to do

with the version of .NetFramework, it is configurable in Visual Studio.

Details:

https://bengribaudo.com/blog/2010/08/26/136/wpf-where-is-your-static-main-method

Regards,

BC Chang

It is important that the Initialize methods have been performed before you construct the controls. It is unclear if the last update from you means you have found a way to resolve the issue?

Sorry for not being clear on my previous update.

It is to clarify that the set of *.dll files I used have nothing to do

with the version of .NetFramework I used.

My current status is:

  1. Found a working example for ImageViewerWpfControl in

PlaybackWpfUser from MIPSDK 2018 R3. (working in

x64 platform, BadImageFormatException when built with x86.)

  1. When porting the function code into my developing code,

the following error prompted when I build it in x86 platform:

System.BadImageFormatException: ‘Could not load file or assembly ‘VideoOS.Platform.SDK.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bc60fba4a7969f89’ or one of its dependencies. An attempt was made to load a program with an incorrect format.’

No error is prompted when I run it in x64 platform, but the UI just won’t started and it crashed itself within seconds.

In short, I’m still trying to make it work.

Any information is appreciated.

Regards,

BC Chang

This is very general what I am about to say but I hope it might prove useful for you.

When you have installed the MIP SDK you can build all standalone samples in x64.

If you want to build x32:

  • Install the 32 bit redistributable MIP SDK.
  • Change all references in the project from dlls in [C:\Program](file:C:/Program) Files\Milestone\MIPSDK\Bin to dlls in [C:\Program](file:C:/Program) Files (x86)\Milestone\MIPSDK\Bin
  • Change the copy of dependent files from [C:\Program](file:C:/Program) Files\Milestone\MIPSDK\Bin to [C:\Program](file:C:/Program) Files (x86)\Milestone\MIPSDK\Bin

See also -

https://developer.milestonesys.com/s/article/Processor-architecture-compatibility-for-the-Milestone-Integration-Platform-MIP-SDK

http://doc.developer.milestonesys.com/html/index.html?base=reference/architecture/net_library_initialization.html&tree=tree_2.html

Thanks for the reply.

To make thing easy, I decided to work on only x64 instead of struggling

between x64 and x86.

The main problem now is finding the dependencies of certain dll(s).

For instance, when my program try to execute the following statement in

Main() from MainWindow.xaml.cs:

  **VideoOS.Platform.SDK.Export.Environment.Initialize();** 

The following error prompt.

Message=Could not load file or assembly ‘VideoOS.Toolkit.dll’ or one of its dependencies. The specified module could not be found.

(I have added both VideoOS.Platform.SDK.Export.dll and

VideoOS.Toolkit.dll into my Visual Studio project references,

although adding VideoOS.Toolkit.dll doesn’t seem to be necessary

as seen in sample project PlaybackWpfUser.)

I found a similar topic in this forum:

https://developer.milestonesys.com/s/question/0D50O00004bQdhcSAC/issues-loading-up-videoostoolkitdll

But the solution is not helping.

The CopyImageViewerActiveX.bat method from https://developer.milestonesys.com/s/article/Dependent-files-in-MIP-SDK

seem only work for x86.

********************************

For now I’m trying to figure out what are those “dependencies” that I’m

missing by comparing the Output log of PlaybackWpfUser with mine

and locate them manually.

Regards,

BC Chang

I will have to update that old knowledge base article, currently it assumes a very old MIP SDK. Thank you for drawing it to my attention.

Two things.

  • The folder is [C:\Program](file:C:/Program) Files\Milestone\MIPSDK\Bin
  • The batch file was renamed to CopyUIFiles.bat

Note that when you have VideoOS.Platform.SDK.Export.Environment.Initialize(); you need to use CopyExportFiles.bat.

http://doc.developer.milestonesys.com/html/index.html?base=reference/architecture/net_library_initialization.html&tree=tree_2.html