2012-03-22 2 views
1

C#에서 COM 개체를 가져 왔으며 C++ DLL에서 사용하고 있습니다. COM 개체가 #import derectiveC# COM 개체 & "ESP의 값이 함수 호출을 통해 제대로 저장되지 않았습니다 ..."

문제로 가져

C에서

는 ++입니다 전화는 내가 런타임 검사 오류 받고 있어요 COM 개체의 함수에 C++ DLL에서 만들어 질 때 :

을 내가에서 declated 한 : 나는 해결책을 발견 한 것처럼 import 지시문 C++에 의해 생성 된 COM 개체 래퍼에서

Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

이 모든 기능을 __stdcall

+0

가능한 중복 http://stackoverflow.com/questions/4104774/the-value- :/출력/MarshalAs는 C#의 COM 인터페이스의 모든 메소드 속성 of-esp-was-not-saved-appropriate) –

+1

COM 호출에서 이례적인 문제입니다. 호출 규칙 및 인수 유형은 모두 시스템에서 생성됩니다. 적어도 C# 선언의 스 니펫 (snippet)과 C++ 호출을 게시하여 코드를보다 잘 설명해야합니다. 간단한 설명은 형식 라이브러리의 이전 버전을 사용하고 있다는 것입니다. –

+0

그것은 해결책을 찾은 것처럼 보입니다 : C# COM의 모든 메소드와 매개 변수에 대해 In/Out/MarshalAs 속성이 거부되었습니다. – ili

답변

1

OK로 선언, 그것은 본다

[Guid("EEB4C1AE-4DB2-4bdb-86D4-A429B27496A3")] 
public interface IAXFarCards 
{ 
    [DispId(1)] 
    void InitDbConnection([In, MarshalAs(UnmanagedType.BStr)] string connectionString); 

    [DispId(2)] 
    [return: MarshalAs(UnmanagedType.I4)] 
    int GetCardInfo(
     [In, MarshalAs(UnmanagedType.BStr)]    string card, 
     [In, MarshalAs(UnmanagedType.VariantBool)]  bool isTemplate, 
     [In, MarshalAs(UnmanagedType.I4)]    int cashDeskId, 
     [Out, MarshalAs(UnmanagedType.VariantBool)] out bool isActive, 
     [Out, MarshalAs(UnmanagedType.I4)]   out int discountNumber, 
     [Out, MarshalAs(UnmanagedType.I8)]   out Int64 amount, 
     [In, Out, MarshalAs(UnmanagedType.BStr)] ref string ownerName, 
     [In, Out, MarshalAs(UnmanagedType.I4)]  ref int clientId 
     ); 
([ESP의 값이 제대로 저장되지 않았습니다]의
관련 문제