Getline错误MFC vs2012(msvcp110.dll) [英] Getline error MFC vs2012 (msvcp110.dll)

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

问题描述

我有一个问题,使用stvs :: getline函数在vs2012与MFC应用程序。同样的代码在vs2010中运行,这就是为什么我确定它不是代码本身的问题。

  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); //这是我的问题
AfxMessageBox(buf.c_str());
file.close();
}
}

第一个AfxMessageBox返回文件路径有效的ASCII文件)。第二个AfxMessageBox从未到达,因为getline产生:


程序中的0x000007FEF7B4AAEE(msvcp110.dll)未处理的异常:0xC0000005:Access违反阅读位置0xFFFFFFFFFFFFFFFF。


和vs11将我重定向到xiosbase行443



< pre =lang-cpp prettyprint-override> locale __CLR_OR_THIS_CALL getloc()const
{// get locale
return(* _Ploc); / * THIS IS LINE 443 * /
}

对于项目属性,我使用在共享dll中使用MFC和多线程DLL和子系统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();
枚举{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);
}
}
}

错误?

解决方案

我现在使用VS10解决了这个问题。有算法工作没有任何问题。但是我不认为这可以是解决方案!



它在同一台电脑上与vs10工作告诉我,这不是一个问题与电脑。 / p>

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();
    }
}

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

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

and vs11 redirect me to the xiosbase line 443

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

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

Additional program code and includes:

#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?

解决方案

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!

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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆