0
首要的事情:沒有源代碼可用錯誤(NLOG Logger.cs),而調試自己的方法
我在2.0.0版本使用Visual Studio 2010與記錄器NLOG。
當我嘗試使用我的單元測試項目來調試我的方法之一出現一個特定的錯誤:
`Locating source for 'c:\NLogBuild\src\NLog\Logger.cs'. (No checksum.)
The file 'c:\NLogBuild\src\NLog\Logger.cs' does not exist.
Looking in script documents for 'c:\NLogBuild\src\NLog\Logger.cs'...
Looking in the projects for 'c:\NLogBuild\src\NLog\Logger.cs'.
The file was not found in a project.
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\'...
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\'...
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl\'...
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: c:\NLogBuild\src\NLog\Logger.cs.
The debugger could not locate the source file 'c:\NLogBuild\src\NLog\Logger.cs'`
我試圖在這裏找到此錯誤的計算器,但發現解決問題的對策沒有解決它。我已經試過幾件事情:
- 重新安裝記錄儀NLOG
- 更新到Nlog.dll並向NLogExtended.dll
- 引用不包括引用,並在卸載n日誌
- 後重新啓動我的操作系統從項目中排除文件,再次將其包括並重建項目,如同在此問題中所述的那樣Link on Stackoverflow
該錯誤不會發生在我所有的遇到部門首長。我可以調試到某種方法,但如果我嘗試進入一些其他方法,我得到這個錯誤。
編輯:當我嘗試進入方法Check(outputPath, append)
發生錯誤。 我不得不在這種情況下使用記錄器,並且我在其他一些方法中使用記錄器,但是我沒有收到錯誤。
[TestMethod()]
public void RunMethodCheckTest()
{
string[] cmdArgs = { };
WebserviceReader.RunMethodCheck(cmdArgs);
}
public static void RunMethodCheck(string [] cmdArgs)
{
string xmlPath = null;
string outputPath = null;
bool noRun = false;
bool append = false;
if (cmdArgs != null)
{
for (int i = 0; i < cmdArgs.Length; i++)
{
cmdArgs[i] = cmdArgs[i].ToLowerInvariant();
if (cmdArgs[i].Equals("/?"))
{
ShowHelpText();
return;
}
if (cmdArgs[i].Substring(0, 7).Equals("/output:"))
{
outputPath = cmdArgs[i].Substring(cmdArgs[i].Length - 4).Equals(".xml") ? cmdArgs[i].Substring(8) : cmdArgs[i].Substring(8) + ".xml";
}
else if (cmdArgs[i].Substring(0, 7).Equals("/input:"))
{
outputPath = cmdArgs[i].Substring(cmdArgs[i].Length - 4).Equals(".xml") ? cmdArgs[i].Substring(8) : cmdArgs[i].Substring(8) + ".xml";
}
else if (cmdArgs[i].Substring(0, 10).Equals("/changeout"))
{
Properties.Settings.Default.OutputDefaultFileName = cmdArgs[i].Substring(cmdArgs[i].Length - 4).Equals(".xml") ? cmdArgs[i].Substring(11) : cmdArgs[i].Substring(11) + ".xml";
noRun = true;
}
else if (cmdArgs[i].Substring(0, 9).Equals("/changein"))
{
Properties.Settings.Default.InputDefaultFileName = cmdArgs[i].Substring(cmdArgs[i].Length - 4).Equals(".xml") ? cmdArgs[i].Substring(10) : cmdArgs[i].Substring(10) + ".xml";
noRun = true;
}
else if (cmdArgs[i].Substring(0, 7).Equals("/append")) { append = true; }
}
}
if (noRun) { return; }
if (String.IsNullOrEmpty(xmlPath))
{
xmlPath = MethodCheck.WebserviceReader.GetApplicationFolderName() + "\\" + MethodCheck.Properties.Settings.Default.InputDefaultFileName;
}
if (String.IsNullOrEmpty(outputPath))
{
outputPath = MethodCheck.WebserviceReader.GetApplicationFolderName() + @"\" + MethodCheck.Properties.Settings.Default.OutputDefaultFileName;
}
MethodCheckType methodCheck = new MethodCheckType(xmlPath);
methodCheck.Check(outputPath,append);
}
public void Check(string outputPath, bool append)
{
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
double time;
StringBuilder output = new StringBuilder();
String valueExecute;
String newLine = Environment.NewLine;
for (int i = 0; i < this.WebService.Length; i++)
{
try
{
watch.Reset();
watch.Start();
valueExecute = this.WebService[i].Execute();
watch.Stop();
time = watch.ElapsedMilliseconds;
output.Append("Executed:\n" + this.WebService[i].URL + newLine + "Time: " + time + " Milliseconds");
Console.WriteLine(output.ToString());
output.Append(newLine + "Expected:\t" + this.WebService[i].ReturnValue + newLine + "Got:");
output.Append(newLine + valueExecute + newLine + newLine);
}
catch (Exception ex)
{
output.Append("Failed Webservice:\n" + this.WebService[i].URL + newLine);
Console.WriteLine(output.ToString());
logger.LogException(LogLevel.Error, "Failed Webservice:\t" + this.WebService[i].URL, ex);
continue;
}
}
MethodCheck.WebserviceReader.WriteToFile(output.ToString(),outputPath,append);
}
如果我不在方法Check(string, bool)
中使用記錄器,也會發生錯誤。
這不是錯誤,您可以跳過'NLog'調用。 –
如何跳過NLog調用? – FluepkeSchaeng
向我們顯示您的代碼。 –