Home > Software engineering >  C call C # write COM
C call C # write COM

Time:09-26

C + + call c # write COM, run on different computers, some normal, some complains, system is Windows 7 32 bit,
Error message is as follows:
System. Exception {System. Reflection. TargetException}
+ [System. Reflection. TargetException] {" Object does not match target type. "} System. Reflection. TargetException
+ Data {System. Collections. ListDictionaryInternal} System. Collections. IDictionary {System. Collections. ListDictionaryInternal}
The Message "Object does not match target type."
The Source "mscorlib string"
StackTrace " at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)\r\n at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)\r\n at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& MsgData) \ r \ n at Client1. IOleTestEvents. OnNewData (Object NewData) \ r \ n at Client1. OleTest. NewData (String [] NewData) in d: \ \ source code \ \ Centurion \ \ the Main \ \ source \ \ Libraries \ \ OpenApps \ \ KicClient \ \ KicClient cs: line 547, "

Help!!!!!!

CodePudding user response:

Use the depends. Exe view exe or DLL relies on other DLL version number,

CodePudding user response:

reference 1st floor zhao4zhong1 response:
using the depends. Exe view exe or DLL relies on other DLL version number,
I use depends to look at the COM DLL, find it relies on mscoree. DLL, I compared to normal and abnormal running the file on the computer, found that are all the same.

CodePudding user response:

reference 1st floor zhao4zhong1 response:
using the depends. Exe view exe or DLL relies on other DLL version number,

Entrust the function of the c # COM:
Public delegate void DelNewData (object NewData);
The public event DelNewData OnNewData;
Public void NewData (object NewData)
{
Try
{
If (OnNewData!=null)
{
OnNewData (NewData);
}
}
The catch (Exception ex)
{
System. Diagnostics. Debug. Print (ex. ToString ());
}
}
Call COM used in c + + program:

CodePudding user response:

Capture should capture all exceptions, all the return value judgment should be judgment,...
Caution is the ship, ten thousand,

CodePudding user response:

reference 4 floor zhao4zhong1 response:
capture should capture all exceptions, all the return value judgment should be judgment,...
Caution is ship ten thousand,
is the original exception caught in c #, I think should be thrown in the c + +, what do you think the teacher?

CodePudding user response:

Must first with 32 bit or 64 bit, I think,

CodePudding user response:

I guess the VS2010 compiled? C # DLL right attribute - "generated -" target platform anycpu into x86
  • Related