c#调用exe MFC文件报错,单独运行exe文件不报错

---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Debug Assertion Failed!

Program: ...ware_demo_c++_2021-09-25\PCSoftware_demo\Debug\PCSoftware.exe
File: minkernel\crts\ucrt\src\appcrt\stdio\fgets.cpp
Line: 33

Expression: stream.valid()

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)

---------------------------
中止(A) 重试(R) 忽略(I)
---------------------------

问题在MFC程序本身:fgets.cpp与读取文件事件有关,exe在启动时读文件导致,可以屏蔽读取文件事件,再测试。

复制代码
 static public void StartLightSourceEqu(string exe_path)
        {
            //ProcessStartInfo info = new ProcessStartInfo();
            //info.FileName = exe_path;
            //info.Arguments = "";
            //info.WindowStyle = ProcessWindowStyle.Minimized;
            //Process pro = Process.Start(info);
            //pro.WaitForExit();


            string exefile = exe_path;
            if (File.Exists(exefile))
            {
                Process process = new Process();
                ProcessStartInfo startInfo = new ProcessStartInfo(exefile);
                startInfo.UseShellExecute = false;
                startInfo.RedirectStandardOutput = false; 
                startInfo.CreateNoWindow = true;
                process.StartInfo = startInfo;
                process.Start();
               // process.WaitForExit(2000);
               // string output = process.StandardOutput.ReadToEnd();
              //  rtb_analyze.Text = output;
                process.Close();
            }
        }
复制代码

 

posted @   txwtech  阅读(150)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
历史上的今天:
2022-07-04 easymodbus串口模式调试测试
2021-07-04 Oracle VM VirtualBox 虚拟机中桥接模式一直不能用 ,需要安装 VBoxNetLwf.inf
点击右上角即可分享
微信分享提示