0

まず最初に:

バージョン 2.0.0 のロガー NLog で Visual Studio 2010 を使用しています。

単体テスト プロジェクトの使用中にメソッドの 1 つをデバッグしようとすると、特定のエラーが発生します。

`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'`

ここで、stackoverflow でこのエラーを見つけようとしましたが、この問題に対する解決策が見つかりませんでした。私はいくつかのことを試しました:

  • ロガーNLogの再インストール
  • Nlog.dll および NLogExtended.dll への参照の更新
  • 参照を除外して nlog をアンインストールした後にオペレーティング システムを再起動する
  • プロジェクトからファイルを除外し、再度含めて、この質問で述べたようにプロジェクトを再構築します 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)、エラーも発生します。

4

1 に答える 1

-1

私の問題の理由はNLog呼び出しではなく、なぜそれがまだ発生するのかわかりません。

回避策がありますが、これは満足のいくものではありません 。すべての行にブレークポイントを設定すると、デバッグする必要があります。

于 2012-09-12T09:04:06.397 に答える