Visual Studio 2019 C# Polimago Project

Hi Everyone:

I create a new Visual studio 2019 C# windows form to try Polimago Handwriting sample. I imported iCVCImg.dll, iPolimago.dll and iSil.dll . I build the project successfully, but when the program running it will has an exception when th program load classifier file(.pcc) and Sil File(.xsil). The exception is an attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B).

My Program is below:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PolimagoTest
{
    public partial class Form1 : Form
    {
        private Cvb.SharedPolimagoClf theClassifier_;// The Polimago classifier to be used.
        private Cvb.SharedSil theSIL_;
        public Form1()
        {
            InitializeComponent();

            LoadClassifier(@"%CVB%\Tutorial\Polimago\Images\Handwriting\USDigits6000.pcc");
            LoadSampleList(@"%CVB%\Tutorial\Polimago\Images\Handwriting\TestDigits.xsil");
        }

        private void LoadClassifier(string fileName)
        {
            try
            {
                Cvb.SharedPolimagoClf tmp = Cvb.Polimago.OpenClf(fileName);

                if (tmp != null)
                {
                    theClassifier_ = tmp;
                    Console.WriteLine("Loaded classifier '" + fileName + "'");
                }
                
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }

        private void LoadSampleList(string fileName)
        {
            
            try
            {
                Cvb.SharedSil tmp = null;
                Cvb.Sil.Load(fileName, out tmp);
                if (tmp != null)
                {
                    theSIL_ = tmp;
                    Console.WriteLine("Loaded sample image list '" + fileName + "'");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }

    }///////////////////////////////////////////////////////////////////
}

Hi @Jesse :slight_smile:

This is a very common error with :cvb: .NET programming. Just go to your Project Properties and untick the Prefer 32-bit checkbox in the Build tab.

2 Likes

Besides what @rtp_derahs said, I recommend using the latest API. For your application the DLLs would be Stemmer.Cvb.dll, Stemmer.Cvb.Polimago.dll and Stemmer.Cvb.SampleDatabase.dll.

4 Likes

Hi rtp_derahs:

Thanks for giving suggestion to me. I rebuild it and check the file path again.Now the project cant load the classifier file(.pcc) and Sil File(.xsil).

1 Like

Hi Frank:

Thanks for your suggestion.
Now I reinstall CommonVisionBlox 13.02.002 (x64). I will try to use Stemmer.Cvb.dll, Stemmer.Cvb.Polimago.dll and Stemmer.Cvb.SampleDatabase.dll.

1 Like