-1

In Debug Mode, I can successfully obtain the directory of the executable path, and here is a reference link on how that is achieved:

Obtaining Application Folder Path

The problem is that none of these methods are effective in Release Mode. It doesn't error out, but the line of code gets skipped over completely. An example of a code snippet that won't execute is:

Dim strDir as String = Environment.CurrentDirectory

In debug mode, the above executes properly (strDir will contain the appropriate directory). In release mode, the above will skip execution completely, leaving strDir as Nothing or empty. Any ideas on what I can do?

Thanks!

4

1 回答 1

0

发布模式调试不同于调试模式下的调试。由于代码正在优化,逐行执行代码并不那么直接;某些流动路径可能不同。

我会这么说……在调试和发布模式下经常编译你的代码非常重要,这是我没有做过的事情。除了我以某种方式在发布模式下遇到了另一个不相关的错误之外,真的没有任何问题,我试图单步执行代码。我注意到当我试图跨过这条线时:

Dim strDir as String = Environment.CurrentDirectory

它跳过了这条线,我无法观察到这个值。我错误地认为这是一个问题。但是我在发布模式中学到的是,这是正常的。我很抱歉发布这个问题,有人可以关闭它吗?

谢谢你们。

于 2016-12-16T05:09:39.467 回答