C#中的Clr20r3错误 [英] Clr20r3 error in C#

查看:250
本文介绍了C#中的Clr20r3错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

My Program does not work on other computers I see this error CLR20r3 System.IO.DirectoryNotFound
I made breakpoint via message box and finally I found the error in the program.cs  

Application.Run(new Mainform());





我尝试过:





What I have tried:

How I can fix this error in the source of my program?

推荐答案

找不到目录非常清楚。

1)记录您的异常并查看代码中的位置。

2)要么在启动时创建目录(即Program.cs)或在使用它之前检查它是否与 Directory.Exists()一起存在。
Directory not found is pretty clear.
1) log your exception and see where in your code it is.
2) either create the directory on start up (i.e. Program.cs) or check if it exists with Directory.Exists() before using it.


Application.Run是执行整个程序的代码 - 它不仅仅是执行一行代码,而是一个巨大的数字!



你需要开始记录MainForm中发生的事情 - 从构造函数和明显的Event handl开始加载和显示。我们的想法是缩小yoru代码中导致异常的位置,因此在最基本的用途 File.AppendText [ ^ ]将我得到这么远的消息添加到文件中,以便在崩溃和工作后进行查看在哪里没有得到!当你知道粗糙区域时,你可以开始专注于使用更详细的日志记录语句,直到你得到一个合理的代码块。



然后你就可以开始找出哪个文件夹缺失,以及为什么。

但我们可以为你做任何事情!
Application.Run is the code which executes your whole program - it's not just a single line of code that that performs, it's a huge number!

You need to start logging what is going on in your MainForm - start with the constructor and the obvious Event handlers Load and Shown. The idea is to "narrow down" where in yoru code the exception is being caused, so at its most basic use File.AppendText[^] to add "I got this far" messages to a file so you can review after teh crash and work out where it didn't get! When you know the rough area, you can start to focus in using more detailed logging statements until you get it down to a reasonable chunk of code.

Then you can start working out which folder is missing, and why.
But we can;t do any of that for you!


这篇关于C#中的Clr20r3错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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