Fix BizTalk catalog collection and diagnostics
Build und Test / build (push) Has been cancelled

This commit is contained in:
2026-07-28 09:29:57 +02:00
parent 53fcfb84a4
commit 6db6e60121
7 changed files with 683 additions and 148 deletions
@@ -1,6 +1,8 @@
using System;
using System.Globalization;
using System.IO;
using System.Management;
using System.Reflection;
using System.Text;
namespace BizTalkApplicationCatalog.Infrastructure
@@ -19,8 +21,57 @@ namespace BizTalkApplicationCatalog.Infrastructure
}
public void Info(string message) { Write("INFO", message); }
public void Detail(string message) { Write("DETAIL", message); }
public void Warning(string message) { Write("WARNUNG", message); }
public void Error(string message) { Write("FEHLER", message); }
/// <summary>
/// Schreibt die vollständige Ausnahmekette einschließlich HRESULT,
/// WMI-Status und Stacktrace auf Konsole und in die Logdatei.
/// </summary>
public void Exception(string context, Exception exception)
{
if (exception == null)
{
Error(context + ": Unbekannter Fehler ohne Ausnahmeobjekt.");
return;
}
Error(context + ": " + exception.Message);
var current = exception;
var depth = 0;
while (current != null)
{
Detail(string.Format(
CultureInfo.InvariantCulture,
"Ausnahme[{0}]: Typ={1}; HRESULT=0x{2:X8}; Meldung={3}",
depth,
current.GetType().FullName,
current.HResult,
current.Message));
var managementException = current as ManagementException;
if (managementException != null)
{
Detail("WMI-Status: " + managementException.ErrorCode);
}
if (!string.IsNullOrWhiteSpace(current.StackTrace))
{
Detail("Stacktrace[" + depth + "]:" + Environment.NewLine
+ current.StackTrace);
}
// Reflection kapselt Providerfehler häufig in TargetInvocationException.
// Die innere Ausnahme wird deshalb ausdrücklich mit ausgegeben.
var targetInvocation = current as TargetInvocationException;
current = targetInvocation != null && targetInvocation.InnerException != null
? targetInvocation.InnerException
: current.InnerException;
depth++;
}
}
public void Dispose() { writer.Dispose(); }
private void Write(string level, string message)
@@ -52,9 +52,11 @@ namespace BizTalkApplicationCatalog.Infrastructure
Severity = required ? "Fehler" : "Warnung",
Area = name,
Message = "Datenerfassung fehlgeschlagen: " + exception.Message,
RecommendedAction = "Logdatei, WMI-Provider und Leseberechtigungen prüfen."
RecommendedAction =
"Logdatei, WMI-Provider, ExplorerOM-Installation "
+ "und BizTalk-Leseberechtigungen prüfen."
});
logger.Error(name + ": " + exception.Message);
logger.Exception(name, exception);
}
}
}