当我尝试使用 NRefactory 时,我仍然收到 System.IO.FileNotFound 异常。 我尝试了很多方法让它发挥作用: - 使用NuGet包,自动安装Mono.Cecil - 下载了 NRefactory 和 Mono.Cecil,并从 VS2010 编译了所有 DLL。
我做错了什么? 这是错误转储:
[System.IO.FileNotFoundException]
{"Could not load file or assembly 'ICSharpCode.NRefactory, Version=4.2.0.8783,
Culture=neutral, PublicKeyToken=efe927acf176eea2' or one of its dependencies.
The system cannot find the file specified.":"ICSharpCode.NRefactory,
Version=4.2.0.8783, Culture=neutral, PublicKeyToken=efe927acf176eea2"}
System.IO.FileNotFoundException
编辑: 这是导致问题的代码:
List<CodeElement> methodsInvokedByGivenMethod = GetInvokedMethods(methodName, fileName);
这是方法体:
private List<CodeElement> GetInvokedMethods(string methodName, string itemWhereMethodIs)
{
MessageBox.Show("I am here");
try
{
using (var fs = File.OpenRead(itemWhereMethodIs))
{
using (var parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StreamReader(fs)))
{
parser.Parse();
}
}
}
catch (System.IO.FileNotFoundException fnf)
{
// This exception arises in Nrefactory...WTF? 0_0
SetToolStripText("There is exception :(");
return null;
}
}
更重要的是,异常没有被该方法内的 try-catch 块捕获,而是发生在该方法之外 -> 调用该方法时,但在该方法内的任何代码行之前。