我正在一個項目中,實體正在通過NHibernate映射屬性(如[Property]和[Class])進行修飾。不幸的是,RIAServices似乎不支持大部分這些屬性,這些屬性在RIAServices嘗試生成Silverlight客戶端代碼時導致失敗。RIA服務不支持由NHibernate映射屬性裝飾的實體?
當我嘗試構建一個使用裝飾用[類別]一個實體或[屬性]屬性的DomainService,我得到了以下錯誤消息的ArgumentNullException:
Error 2 The "CreateRiaClientFilesTask" task failed unexpectedly. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null. Parameter name: TypeName at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) at System.Type.GetType(String typeName) at NHibernate.Mapping.Attributes.ClassAttribute.get_NameType() --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) at System.Web.DomainServices.Tools.StandardCustomAttributeBuilder.GetPropertyValues(IEnumerable`1 propertyMaps, Attribute attribute) at System.Web.DomainServices.Tools.StandardCustomAttributeBuilder.GetAttributeDeclaration(Attribute attribute) at System.Web.DomainServices.Tools.CustomAttributeGenerator.GenerateCustomAttributes(ClientProxyGenerator proxyGenerator, CodeTypeDeclaration referencingType, IEnumerable`1 attributes, CodeCommentStatementCollection comments) at System.Web.DomainServices.Tools.CustomAttributeGenerator.GenerateCustomAttributes(ClientProxyGenerator proxyGenerator, CodeTypeDeclaration referencingType, IEnumerable`1 attributes, CodeAttributeDeclarationCollection outputCollection, CodeCommentStatementCollection comments) at System.Web.DomainServices.Tools.EntityProxyGenerator.Generate() at System.Web.DomainServices.Tools.ClientProxyGenerator.GenerateProxyClass(String& generatedCode) at System.Web.DomainServices.Tools.CreateRiaClientFilesTask.GenerateClientProxies() at System.Web.DomainServices.Tools.CreateRiaClientFilesTask.Execute() at Microsoft.Build.Framework.ITask.Execute() at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) SL
我知道,使用功能NHibernate應該解決這個問題,因爲它消除了對NHibernate依賴關係的需求,但是我想首先確定在移植到Fluent NHibernate之前沒有任何其他解決方案。任何想法解決這個問題?
看起來異常來自NameType屬性上的NHibernate.Mapping.Attributes.ClassAttribute類,而不是來自RIA Services。 – Bryant 2009-10-21 22:26:38
NHibernate映射屬性確實導致異常。如果我刪除[Class]屬性,那麼[Property]屬性導致相同的異常,這次它從「NHibernate.Mapping.Attributes.PropertyAttribute.get_AccessType()」開始。我發現很難看到問題出在哪裏,因爲 我無法調試客戶端代碼生成(?)。看起來像RIAServices不支持所有NH映射屬性,儘管它們是可序列化的。這些屬性不會在應用程序的其他部分導致問題。 – 2009-10-22 09:06:20