An unhandled exception of type 'VideoOS.Platform.MIPException' occurred in VideoOS.Platform.dll

Hello,I used MIP SDK to develope a window form for export video.

I have a problem.

The code is as follows:

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VideoOS.Platform;
using VideoOS.Platform.SDK.Export;
using VideoOS.Platform.UI;
using VideoOS.Platform.Util;
using AVIExporter = VideoOS.Platform.Data.AVIExporter;
 
namespace ExportTest
{
    public partial class MainForm : Form
    {
        private Item _cameraItem = null;
        private string _path = null;
        private Timer _timer = new Timer() { Interval = 100 };
        VideoOS.Platform.Data.IExporter _exporter;
 
        public MainForm()
        {
            InitializeComponent();
        }
 
        private void OnClose(object sender, EventArgs e)
        {
            if (_exporter != null)
            {
                _exporter.Cancel();
                _exporter.EndExport();
                _exporter.Close();
            }
            VideoOS.Platform.SDK.Environment.RemoveAllServers();
            Close();
        }
 
        /// <summary>
        /// Open the ItemPicker to let user select a camera
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonCameraSelect_Click(object sender, EventArgs e)
        {
            ItemPickerForm form = new ItemPickerForm();
            form.KindFilter = Kind.Camera;
            form.AutoAccept = true;
            form.Init(Configuration.Instance.GetItems());
            if(form.ShowDialog() == DialogResult.OK)
            {
                _cameraItem = form.SelectedItem;
                buttonCameraSelect.Text = _cameraItem.Name;
 
                if(_cameraItem != null && _path != null)                
                    buttonExport.Enabled = true;                
            }
        }       
        private void buttonDestination_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            if(dialog.ShowDialog() == DialogResult.OK)
            {
                _path = dialog.SelectedPath;
                buttonDestination.Text = _path;
 
                if (_cameraItem != null && _path != null)
                    buttonExport.Enabled = true;
            }
        }        
        private void buttonExport_Click(object sender, EventArgs e)
        {
            bool isStarted = false;
            List<Item> audioSources = new List<Item>();
            String destPath = _path;
 
            if(dateTimePickerStart.Value > dateTimePickerEnd.Value)
            {
                MessageBox.Show("Start time need to be lower than end time");
                return;
            }
            if (textBoxVideoFilename.Text == "")
            {
                MessageBox.Show("Please enter a filename for the MKV file.", "Enter Filename");
                return;
            }
            _exporter = new VideoOS.Platform.Data.MKVExporter
            {
                Filename = textBoxVideoFilename.Text
            };
            destPath = Path.Combine(_path, "Exported Images\\" + MakeStringPathValid(_cameraItem.Name));
 
            _exporter.Init();
            _exporter.CameraList = new List<Item>() { _cameraItem };
            _exporter.Path = destPath;
            _exporter.AudioList = audioSources;
 
            isStarted = _exporter.StartExport(dateTimePickerStart.Value.ToUniversalTime(), dateTimePickerEnd.Value.ToUniversalTime());
 
            try
            {
                if (isStarted)
                {
                _timer.Tick += ShowProgress;
                _timer.Start();
                buttonExport.Enabled = false;
                }
                else
                {
                int lastError = _exporter.LastError;
                string lastErrorString = _exporter.LastErrorString;
                labelerror.Text = lastErrorString + "  ( " + lastError + " )";
                _exporter.EndExport();
                }
            }catch( Exception ex)
            {
                EnvironmentManager.Instance.ExceptionDialog("Start Export", ex);
            }           
 
        }   
        private static string MakeStringPathValid(string unsafeString)
        {
            char[] invalidCharacters = Path.GetInvalidFileNameChars();
            string result = unsafeString;
            foreach (var invalidCharacter in invalidCharacters)
            {
                result = result.Replace(invalidCharacter, '_');
            }
            return result;
        }
 
        private void ShowProgress(object sender, EventArgs e)
        {
            if (_exporter != null)
            {
                int progress = _exporter.Progress;
                int lastError = _exporter.LastError;
                string lastErrorString = _exporter.LastErrorString;
                if (progress >= 0)
                {
                    progressBar.Value = progress;
                    if (progress == 100)
                    {
                        _timer.Stop();
                        labelerror.Text = "Done";
                        _exporter.EndExport();
                        _exporter = null;                       
                    }
                }
                if (lastError > 0)
                {
                    progressBar.Value = 0;
                    labelerror.Text = lastErrorString + "  ( " + lastError + " )";
                    if (_exporter != null)
                    {
                        _exporter.EndExport();
                        _exporter = null;                        
                    }
                }
            }
        }
 
        private void OnCancel(object sender, EventArgs e)
        {
            if (_exporter != null)
                _exporter.Cancel();
        }
 
    }
}

window form:

Press the export button.The following error message appears.

I execute exportsample with success. But I develope this window form can not be execute. what is the problem?

Thanks!

My guess is that you did not do VideoOS.Platform.SDK.Export.Initialize()

Please see if the Export Sample works, if it works compare the code, try to focus on the initializations as they are probably where the problem happens.

https://doc.developer.milestonesys.com/html/index.html?base=samples/export_sample.html&tree=tree_2.html

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

Thank you for your answer.I really forget to do VideoOS.Platform.SDK.Export.Initialize()

But after I add this code, new error message appears.

What’s the problem?

My guess is that you have not done the copy of the dependent files.

Please read the second link that I sent yesterday. This might be helpful for you. Hint: CopyExportFiles.bat