我正在使用事务性 NTFS 读取和写入文件系统上的文件,并且我注意到应用程序遇到间歇性故障,这只能通过重新启动应用程序来解决。错误的堆栈跟踪是:
System.Runtime.InteropServices.COMException (0xD0190052): Exception from HRESULT: 0xD0190052
at ...KtmTransactionHandle.IKernelTransaction.GetHandle(IntPtr& handle)
at ...KtmTransactionHandle.CreateKtmTransactionHandle(Transaction managedTransaction)
at ...KtmTransactionHandle.CreateKtmTransactionHandle()
at ...TransactedFile.Open(String path, FileMode mode, FileAccess access, FileShare share)
at ...TransactedFile.ReadAllText(String path)
IKernelTransaction 是一个 COM 接口,我可以使用它来处理:
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("79427A2B-F895-40e0-BE79-B57DC82ED231")]
private interface IKernelTransaction
{
void GetHandle([Out] out IntPtr handle);
}
这里
IKernelTransaction tx = (IKernelTransaction)TransactionInterop.GetDtcTransaction(Transaction.Current);
我的代码与http://msdn.microsoft.com/en-us/library/cc303707.aspx非常相似
问题是我找不到此 COM 错误 0xD0190052 的任何信息。只要知道这个错误代码是什么就会有很大帮助。
谢谢