-1

在存储实现INotifyPropertyChanged接口或包含任何事件的对象时,通常会出现以下异常:

NDatabase.Exceptions.OdbRuntimeException: 
NDatabase has thrown an Exception
Error:275:Class Introspectpr error for class MS.Internal.Text.TextInterface.Generics.NativeIUnknownWrapper<MS::Internal::Text::TextInterface::Native::IDWriteFont>, PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 ---> NDatabase.Exceptions.OdbRuntimeException: 
NDatabase has thrown an Exception
Error:275:Class Introspectpr error for class MS.Internal.Text.TextInterface.Generics.NativeIUnknownWrapper<MS::Internal::Text::TextInterface::Native::IDWriteFont>, PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 ---> NDatabase.Exceptions.OdbRuntimeException: 
NDatabase has thrown an Exception
Error:275:Class Introspectpr error for class MS.Internal.Text.TextInterface.Generics.NativeIUnknownWrapper<MS::Internal::Text::TextInterface::Native::IDWriteFont>, PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 ---> System.TypeLoadException: Could not load type from string value 'MS.Internal.Text.TextInterface.Generics.NativeIUnknownWrapper<MS::Internal::Text::TextInterface::Native::IDWriteFont>, PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at NDatabase.TypeResolution.GenericTypeResolver.Resolve(String typeName) in c:\TeamCity\Agents\A\BuildAgent\work\5f9a44f79ee7a25c\src\TypeResolution\GenericTypeResolver.cs:line 44

首次存储对象或更新现有对象时会发生这种情况

我使用此代码来存储对象:

long newid = 0;
using (var db = NDatabase.OdbFactory.OpenLast())
{
    newid = db.Store(st).ObjectId;
}
4

1 回答 1

0

只需将[field: NonPersistent]属性添加到事件中。
所以这

public event PropertyChangedEventHandler PropertyChanged;

应该改为

[field: NDatabase.Api.NonPersistent]
public event PropertyChangedEventHandler PropertyChanged;
于 2017-08-10T19:07:47.097 回答