2012-01-24 2 views
2

일반 DLL에서 MFC DLL을로드하면 역 직렬화가 작동하지 않습니다.일반 DLL에서 MFC DLL을로드하면 역 직렬화가 작동하지 않습니다.

나는 이전에이 질문을 해왔지만 그 당시에는 복잡한 것이기 때문에 문제를 해결하지 못했습니다. 참조 C# .NET User Control inside native app. Resource chain problems

이제 동일한 문제를 나타내는 테스트 응용 프로그램을 만들었습니다. 압축 된 코드 파일은 https://skydrive.live.com/?#cid=0977B1167FE01BB3&id=977B1167FE01BB3%21105&sc=documents입니다.

일반 DLL에서 MFC 확장 DLL을로드하는 경우 응용 프로그램에서 직접 MFC 확장 DLL을 호출하면 deserialization이 작동하지 않습니다.

enter image description here

나는 다음과 같은 CArchiveException를 얻을 수 역 직렬화 할

"이름이없는 파일이 예상치 못한 개체가 포함되어 있습니다."

"경고 : 아카이브에서 CSerializableClass를로드 할 수 없습니다

는 또한 비주얼 스튜디오 2008의 출력은 내가 SerializeTest의 디버그 버전을 실행 다음과 같은 정보를 제공합니다. 클래스가 정의되지 않았습니다. CArchive 예외 : badClass입니다. SerializeTestD.exe에서 0x7c812afb에서 첫 번째 예외 : 마이크로 소프트 C++ 예외 :. 메모리 위치 0x0012edf8에서 CArchiveException "

다음 테스트 코드가 CMFCDLL :: DOIT에서 실행

무효 CMFCDLL :: DOIT (무효)

{

BYTE * pBuf = (BYTE *)new char [1024]; 
    { 
     CSerializableClass *pSerializableClass = new CSerializableClass; 

     CMemFile mf; 
     mf.Attach(pBuf, 1024); 

     CArchive ar(&mf, CArchive::store); 
     ar << pSerializableClass; 
     ar.Close(); 
     mf.Detach(); 

     delete pSerializableClass; 
    } 
    { 
     CSerializableClass *pSerializableClass = NULL; 

     CMemFile mf; 
     mf.Attach(pBuf, 1024); 
     CArchive ar(&mf, CArchive::load); 
     try 
     { 
      ar >> pSerializableClass; 
      ar.Close(); 
      mf.Detach(); 

      ASSERT(pSerializableClass && pSerializableClass->GetText() == _T("This is a serialize test")); 

      delete pSerializableClass; 
     } 
     catch(CArchiveException *p) 
     { 
      char str[500]; 
      p->GetErrorMessage(str,500); 
      AfxMessageBox(str); 
      p->Delete(); 

      ar.Abort(); 
      mf.Detach(); 
     } 
    } 
    delete pBuf; 

}

실패 코드 "AR >> pSerializableClass 인 ". 이 문제가 발생하는 이유는 무엇입니까?

왜 일반 DLL을 사용해야합니까?
.NET 래퍼를 쓰고 있으며 혼합 모드 DLL은 MFC 확장 DLL에서 직렬화에 액세스하는 일반 DLL입니다.

답변

관련 문제