Getline 错误 MFC vs2012 (msvcp110.dll)

Getline error MFC vs2012 (msvcp110.dll)(Getline 错误 MFC vs2012 (msvcp110.dll))

本文介绍了Getline 错误 MFC vs2012 (msvcp110.dll)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将 vs2012 中的 std::getline 函数与 MFC 应用程序一起使用时遇到问题.相同的代码在 vs2010 中运行,这就是为什么我确信它不是代码本身的问题.

I have a problem to use the std::getline function in vs2012 with an MFC application. The same code was running in vs2010 that's why I am sure that it is not a problem with the code itself.

void AddImage::OnClickedIdbAiRegistration(){
CFileDialog file(TRUE, NULL, NULL, OFN_OVERWRITEPROMPT, "(*.dat)|*.dat||");
file.DoModal();
UpdateData();
m_ai_file=file.GetPathName();
UpdateData(FALSE);
std::string buf=m_ai_file;
if(filecnt(buf, "Dat")){
    std::ifstream file(buf);
    AfxMessageBox(buf.c_str());
    std::getline(file, buf);//Here is my problem
    AfxMessageBox(buf.c_str());
    file.close();
    }
}

第一个 AfxMessageBox 返回文件路径(正确且有效的 ASCII 文件).我永远无法到达第二个 AfxMessageBox,因为 getline 产生:

The first AfxMessageBox returns the filepath (which is correct and a valid ASCII-file). The Second AfxMessageBox do i never reach because getline produces:

program.exe 中 0x000007FEF7B4AAEE (msvcp110.dll) 处的未处理异常:0xC0000005:访问冲突读取位置 0xFFFFFFFFFFFFFFFF.

Unhandled exception at 0x000007FEF7B4AAEE (msvcp110.dll) in program.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

vs11 将我重定向到 xiosbase 第 443 行

and vs11 redirect me to the xiosbase line 443

    locale __CLR_OR_THIS_CALL getloc() const
    {   // get locale
    return (*_Ploc);/*THIS IS LINE 443*/
    }

对于项目属性,我使用在共享 dll 中使用 MFC"和多线程 DLL"和子系统Windows"

For the project property i am using "Use MFC in a shared dll" and "Multi-threaded DLL" and Sub-System "Windows"

附加程序代码,包括:

#include <afxwin.h>
#include <afxframewndex.h>
#include <afxcmn.h>
#include <afxdialogex.h>

#include <iostream>
#include <string>
#include <sstream>
#include <regex>
#include <fstream>
#include <time.h>
#include <Windows.h>

usign namespace std;

class AddImage:public CDialog{
        DECLARE_DYNAMIC(AddImage)
    public:
        AddImage(CWnd* pParent = NULL);
        virtual ~AddImage();
        enum {IDD=IDD_ADD_IMAGE};
    protected:
        virtual void DoDataExchange(CDataExchange* pDX);
        DECLARE_MESSAGE_MAP()
    public:
        CString m_ai_file;
    };

AddImage::AddImage(CWnd* pParent):CDialog(AddImage::IDD, pParent){
    m_ai_file=_T("");
    }

AddImage::~AddImage(){
    }



bool filecnt(string path, string type){
    if(filepathcnt(path, type)){
        if(GetFileAttributes(path.c_str())==-1){
            return(FALSE);
            }
        else{
            return(TRUE);
            }
        }
    else{
        return(FALSE);
        }
    }

bool filepathcnt(string path, string type){
    if(type==""){
        tr1::regex regex("[[:print:]]+\.[[:alnum:]]+");
        if(regex_match(path.begin(), path.end(), regex)){
            return(TRUE);
            }
        else{
            return(FALSE);
            }
        }
    else if(type=="-"){
        tr1::regex regex("[[:print:]]+");
        if(regex_match(path.begin(), path.end(), regex)){
            return(TRUE);
            }
        else{
            return(FALSE);
            }
        }
    else{
        string upper=type;
        string lower=type;
        transform(upper.begin(), upper.end(), upper.begin(), toupper);
        transform(lower.begin(), lower.end(), lower.begin(), tolower);
        tr1::regex norm_regex("[[:print:]]+\."+type);
        tr1::regex upper_regex("[[:print:]]+\."+upper);
        tr1::regex lower_regex("[[:print:]]+\."+lower);
        if(regex_match(path.begin(), path.end(), upper_regex) || regex_match(path.begin(), path.end(), lower_regex) || regex_match(path.begin(), path.end(), norm_regex)){
            return(TRUE);
            }
        else{
            return(FALSE);
            }
        }
    }

有人知道出了什么问题吗?

Anyone an idea what is going wrong?

推荐答案

我现在用VS10解决了这个问题.该算法在那里没有任何问题.但我认为这不是解决方案!

I have solved the problem now by using VS10. There the algorithm works without any issues. But I do not think that this can be the solution!

它可以在同一台 PC 上与 vs10 一起使用,这也告诉我这不是 PC 的问题.

That it works with vs10 on the same PC tells me also that it is not a problem with the PC.

这篇关于Getline 错误 MFC vs2012 (msvcp110.dll)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Getline 错误 MFC vs2012 (msvcp110.dll)