C#中的访问冲突错误

时间:2015-08-09 07:19:12

标签: c# c++ .net dll access-violation

我在VS2013上有C#windows表单项目。 我的图形支持MFC C ++项目通过DLL。 当我使用32位dll和32位C#项目时,它的工作正常。 但是当使用64位dll和64位C#项目时,只能使用.net framework 4客户端配置文件而不能使用.net framework 4.5并在使用dll时获取访问冲突错误。 在C ++ DLL上抛出访问冲突错误的代码。

BOOL ImportElevation( CString &csFileName )
{
CString csTmpPath = GetTempFolderName(csFileName.GetBuffer());

int iResult = vtCreateDir(csTmpPath);
if (iResult == 0 && errno != EEXIST)
{
    MessageBox(NULL,_T("Couldn't create temporary directory to hold contents of archive."),
        _T("Error"),MB_ICONERROR);
    return FALSE;   // no layers created
}

CString csUnzipPath = csTmpPath + _T("/");
iResult = ExpandZip(csFileName, csUnzipPath, ProgressCallback);
if (iResult == 1)
{
    // the archive contained a single file
    std::string strPathName = (const char *) csUnzipPath;
    for (dir_iter it(strPathName); it != dir_iter(); ++it)//at this line throw exception
    {
        if (it.is_directory())
            continue;
        csUnzipPath += it.filename().c_str();
        break;
    }
    CElevLayer* pLayer = new CElevLayer(csFileName);
    if(pLayer->ImportElevation(csUnzipPath,TRUE,ProgressCallback))
    {
        m_vecElevLayer.push_back(pLayer);

        m_iActiveLayerIdx = m_vecElevLayer.size()-1;

        pLayer->CreateMap(ProgressCallback);

        return TRUE;
    }
    else
        SAFE_DELETE(pLayer);

    return FALSE;
}

// clean up after ourselves
csTmpPath = GetTempFolderName(csUnzipPath);
vtDestroyDir(csTmpPath);

return TRUE;
}

我在3个不同的项目上运行此dll并收到此错误。

0 个答案:

没有答案