可以从命令行运行C++代码,但不能从visual studio中的调试模式运行
can run C++ code from command line but not from debug mode in visual studio
我在调试模式下编译了下面的程序,没有任何错误。我可以从命令行运行.exe文件,但当我尝试在visualstudio中调试代码时,异常会从行抛出
DetectionInternalSettings* internal_settings =
DetectionInternalSettingsFactory::createFromFileSystem(
"C:/data/card_detection_engine.yaml");
任何以前遇到过这种情况的人,在命令行和调试模式下运行时的行为都不同。
int main(int argc, char **argv)
{
DetectionSettings settings;
try
{
DetectionInternalSettings* internal_settings =
DetectionInternalSettingsFactory::createFromFileSystem("../data/card_detection_engine.yaml");
}
catch (const MyException &e)
{
fprintf(stderr, "Exception raised: %sn", e.what().c_str());
return 1;
}
return 0;
}
我还讨论了异常的详细信息,这里是ocrcarddetectionengine_sample.exe:Microsoft C++异常:YAML::TypedBadConversion内存位置0x003FF0D0中0x76E1C41F处的First chance异常。
与createFromFileSystem
相关的更多代码
DetectionInternalSettingsFactory::createFromFileSystem(const std::string &configPath) throw (MyException)
{
return new DetectionInternalSettingsImpl(configPath);
}
struct DetectionInternalSettingsImpl : public DetectionInternalSettings {
DetectionInternalSettingsImpl(const std::string &config_path) {
if (config.ReadFromFilesystem(config_path)) {
throw MyException("Bad configuration path.");
}
}
~DetectionInternalSettingsImpl() { }
Core::Detector::Configuration config;
};
信任调试模式异常。它更彻底地测试代码实际在做什么,而命令行只是在等待问题发生。
在您的情况下,它们似乎不会发生,可能是因为您没有对指针变量执行任何操作。
相关文章:
- 如何在MS Visual Studio 2019中运行QT UI
- 编译并运行后,输出未出现在 Visual Studio 代码中
- Ctrl + 不适用于在 Visual Studio 中运行该程序
- Realloc 两次无法在 Visual Studio 上运行
- Visual Studio 2017 - 调试和 Relese 配置,设置运行时库
- 程序在 Visual Studio 中停止运行时终止
- MinGW是否需要在Visual Studio上运行C++
- 在 Visual Studio 中构建一个没有 C/C++ 运行时的静态库
- 在Visual Studio中运行/调试C ++时,如何在结束时等待输入
- 无法在 Visual Studio 代码中生成和运行 C++ 代码
- 从Visual Studio 2017运行MPI应用程序,每个进程在不同的cmd窗口中
- 如何在 Visual Studio C++ 11 中运行时定义二维数组?
- 为什么我的程序无法在GDB在线编译器/调试器或Visual Studio C++ 2019中运行
- 我可以在不创建项目的情况下在Visual Studio 2019中编译和运行HelloWorld.cpp吗?
- 选择特定版本的 Visual Studio 命令行工具包,并根据特定版本的C++运行时环境编译文件
- 如何使visual studio代码直接运行vcvarsx86_arm64.bat而不是vcvarsall.bat
- Visual Studio代码运行环境
- 如何在visual studio代码的调试中运行c++脚本
- Qt在安装Visual Studio 2019和虚幻引擎后无法运行示例应用程序
- 如何在不受其他文件影响的情况下"by itself" Visual Studio 项目中运行C++文件?