COM interop을 사용하여 C++ 응용 프로그램에서 C# DLL의 메서드를 호출하고 있습니다.COM 인터페이스 포인터 만들기는 개발 컴퓨터에서 작동하지만 다른 컴퓨터에서는 응용 프로그램 충돌이 발생합니다.
C# 코드는 다음과 같습니다
namespace MyLibrary
{
[ComVisible(true)]
[Guid("f08942b1-db20-44aa-9713-7d28fff51e2b")]
public interface IMyLibraryInterface
{
string POSRequest(string request);
}
[ComVisible(true)]
[Guid("4d962dd5-05ed-431b-82e2-378aebe8d0dc")]
public class MyLibraryInterface : IMyLibraryInterface
{
public string myRequest(string request)
{
....
return response;
}
}
}
호출 C++ 코드는 다음과 같습니다
#import "MyLibrary.tlb"
이 모두 작동 디버깅 할 때 : 관련 TLB 파일이 가져온
CoInitialize(NULL);
MyLibrary::IMyLibraryInterfacePtr MyLibraryInterface(__uuidof(MyLibrary::MyLibraryInterface));
myResult = (LPCTSTR) MyLibraryInterface->myRequest(myInput);
CoUninitialize();
내 개발 컴퓨터에서 릴리스 버전을 실행하고 있지만이 때 실행하면 응용 프로그램이 중단됩니다. 다른 기계. 특히, 포인터를 만드는 줄이 문제인 것으로 보입니다.
MyLibrary::IMyLibraryInterfacePtr MyLibraryInterface(__uuidof(MyLibrary::MyLibraryInterface));
다른 컴퓨터에는 뭔가 빠져있는 것 같지만 무엇을 알아 내지 못합니까?
다른 컴퓨터에 C# COM dll을 등록 했습니까? 'regasm.exe'를 사용하여 dll을 등록해야합니다. – pstrjds
은 프로젝트의 작업 디렉토리에있는 dll이거나 작성한 프로그램이 액세스 할 수있는 새 시스템의 어딘가에 있습니까? – holycatcrusher
C# dll을 등록해야한다는 것을 알지 못했습니다. 이것이 설치 될 때마다이 작업을 수행해야합니까? –