DbApplyChangeFailedEventArgs.Error 属性
获取一个 Exception 对象,其中包含有关在同步期间发生的任何异常的元数据。
命名空间: Microsoft.Synchronization.Data
程序集: Microsoft.Synchronization.Data(在 microsoft.synchronization.data.dll 中)
语法
声明
Public ReadOnly Property Error As Exception
用法
Dim instance As DbApplyChangeFailedEventArgs
Dim value As Exception
value = instance.Error
public Exception Error { get; }
public:
property Exception^ Error {
Exception^ get ();
}
/** @property */
public Exception get_Error ()
public function get Error () : Exception
属性值
一个 Exception 对象,它包含有关在同步期间发生的任何异常的元数据。
示例
下面的代码示例将错误信息写入到日志文件中。
else if (e.Conflict.Type == DbConflictType.ErrorsOccurred)
{
string logFile = @"C:\SyncErrorLog.txt";
Console.WriteLine(String.Empty);
Console.WriteLine("An error occurred during synchronization.");
Console.WriteLine("This error has been logged to " + logFile + ".");
StreamWriter streamWriter = File.AppendText(logFile);
StringBuilder outputText = new StringBuilder();
outputText.AppendLine("** APPLY CHANGE FAILURE AT " + DbConflictDetected.ToUpper() + " **");
outputText.AppendLine("Error source: " + e.Error.Source);
outputText.AppendLine("Error message: " + e.Error.Message);
streamWriter.WriteLine(DateTime.Now.ToShortTimeString() + " | " + outputText.ToString());
streamWriter.Flush();
streamWriter.Dispose();
}
ElseIf e.Conflict.Type = DbConflictType.ErrorsOccurred Then
Dim logFile As String = "C:\SyncErrorLog.txt"
Console.WriteLine(String.Empty)
Console.WriteLine("An error occurred during synchronization.")
Console.WriteLine("This error has been logged to " & logFile & ".")
Dim streamWriter As StreamWriter = File.AppendText(logFile)
Dim outputText As New StringBuilder()
outputText.AppendLine("** APPLY CHANGE FAILURE AT " & DbConflictDetected.ToUpper() & " **")
outputText.AppendLine("Error source: " & e.Error.Source)
outputText.AppendLine("Error message: " & e.Error.Message)
streamWriter.WriteLine(DateTime.Now.ToShortTimeString() & " | " & outputText.ToString())
streamWriter.Flush()
streamWriter.Dispose()
End If
请参阅
参考
DbApplyChangeFailedEventArgs 类
DbApplyChangeFailedEventArgs 成员
Microsoft.Synchronization.Data 命名空间