Home > Back-end >  C builder 6 import (emgu) c # COM error
C builder 6 import (emgu) c # COM error

Time:09-22

Using c + + builder 6 to use the Import the Type Library into c # TLB file (command prompt character registered DLL)

Part of using c # emgucv library to do some image processing, using c # class library don't write COM components, according to the law of the Internet to do basic processing operations

Basic operation function can be normal execution results in c + + builder 6 call

But the call to emgu part will have the error occurred, want to ask do you have any elder encountered similar problems, and solve the

C # code
 
using System;
using System.Collections.Generic;
//using System. Linq;

Using System. Drawing;
Using Emgu. CV;//Emgu
Using Emgu. CV. Structure;
Using System. The Runtime. InteropServices;


The namespace DectFunct
{
B4ed5b9 [Guid (" 6-5356-42 e3 - a242f91583a A6CA - 1 ")]

Public interface IComInterface

{
//[DllExport (" Dect, "CallingConvention=CallingConvention. StdCall)]

[DispId (1)]

Int Dect (int x_allspace, int y_allspace, int x_space, int dead_sum, int pic_name);

[DispId (2)]

String COMINFO {get; }

[DispId (3)]

Int the add (int x_allspace, int y_allspace);

}

[Guid (" 1 a8eb38c - E732-49 b2 - A897 - B40FFD744E3D ")]

Public class Class1: IComInterface
{
Public int Dect (int x_allspace, int y_allspace, int x_space, int dead_sum, int pic_name)
{
Int result=0;
Float hexagon_L=x_space;
Image Image_Source;

//String openFile=pic_name + "PNG";
String name=the Convert. ToString (pic_name);
String openFile=name + ". BMP ";
Image_Source=new Image (strongest);

If (image_Source!=null)
Result=1;

return result;
}
Public string COMINFO
{
The get
{
Return "com test";
}
}

Public int the add (int x, int y)
{
Int z=0;
Z=x + y;
Return the z;
}
}


 
# pragma hdrstop
# include & lt; Iostream>
# include & lt; The VCL. H>
# include "Dectfunct_tlb. H"
using namespace std;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma argsused
Int main (int arg c, char * argv [])
{
Retrieves the hr;

//initialize the COM

CoInitialize (NULL);


Dectfunct_tlb: : IComInterfacePtr PTR.

Hr=PTR. CreateInstance (__uuidof (Dectfunct_tlb: : Class1));

If (hr==S_OK)
{
Cout & lt; & lt; PTR - & gt; Add (32, 16) & lt; & lt; endl;

Cout & lt; & lt; PTR - & gt; Dect (16, 32, 3, 1, 1) & lt; & lt; endl;


BSTR outp=NULL;
PTR - & gt; Get_COMINFO (& amp; Outp);
cout<& lt; AnsiString (outp) & lt; & lt; endl;
}

CoUninitialize ();

system("pause");
return 0;
}


Due to some c # COM components, to c + + builder 6 method I will skip, a lot of online teaching me not to mention

To attach my own computer to perform the correct results


After execution, however, I now use the computer to Windows 7-64 bits can normal compilation of return value, but if the DLL, TLB file to the other computer is used, the results will be


Simple operation can be had, but use to emgu part of the problem is there on the system with uncertain or which side have write wrong, this is my portable to other computer result of execution of


Want to ask is there any predecessors have encountered this error, and has a solution, not sure is a program error, or a software system problems

CodePudding user response:

This part of the error have been solved on their own, in other computer need to install the third class library components and set path
  • Related