C# NET本机问题
我使用Prism 6进行UWP和Microsoft.NetCore.UWP 5.2.2。在发布版本中,我遇到了无法使用反射的问题C# NET本机问题,c#,.net,uwp,prism,.net-native,C#,.net,Uwp,Prism,.net Native,我使用Prism 6进行UWP和Microsoft.NetCore.UWP 5.2.2。在发布版本中,我遇到了无法使用反射的问题 我有像IDictionary这样的对象。如何在default.rd.xml中为它们添加策略 我无法复制您的问题。我在包含IDictionary对象的发布模式下运行一个项目,没有遇到任何错误或异常。我的操作系统版本是build 14393,我在本地机器上进行了测试 由于我不确定您遇到了什么错误或异常,您可以尝试将以下集合相关策略添加到default.rd.xml <
我有像
IDictionary
这样的对象。如何在default.rd.xml中为它们添加策略 我无法复制您的问题。我在包含IDictionary
对象的发布模式下运行一个项目,没有遇到任何错误或异常。我的操作系统版本是build 14393,我在本地机器上进行了测试
由于我不确定您遇到了什么错误或异常,您可以尝试将以下集合相关策略添加到default.rd.xml
<Assembly Name="*Application*" Dynamic="Required All" />
<!--Add your application specific runtime directives here.-->
<Namespace Name="System.Collections.ObjectModel" >
<TypeInstantiation Name="ReadOnlyCollection"
Arguments="ContosoClient.DataModel.ProductGroup" Serialize="Public"/>
<TypeInstantiation Name="ObservableCollection"
Arguments="ContosoClient.DataModel.ProductItem" Serialize="Public" />
<TypeInstantiation Name="ReadOnlyObservableCollection"
Arguments="ContosoClient.DataModel.ProductGroup" Serialize="Public" />
</Namespace>
。如果您在某些反射场景中遇到MissingMetadataException
,您可以按照此解决问题。我无法重现您的问题。我在包含IDictionary
对象的发布模式下运行一个项目,没有遇到任何错误或异常。我的操作系统版本是build 14393,我在本地机器上进行了测试
由于我不确定您遇到了什么错误或异常,您可以尝试将以下集合相关策略添加到default.rd.xml
<Assembly Name="*Application*" Dynamic="Required All" />
<!--Add your application specific runtime directives here.-->
<Namespace Name="System.Collections.ObjectModel" >
<TypeInstantiation Name="ReadOnlyCollection"
Arguments="ContosoClient.DataModel.ProductGroup" Serialize="Public"/>
<TypeInstantiation Name="ObservableCollection"
Arguments="ContosoClient.DataModel.ProductItem" Serialize="Public" />
<TypeInstantiation Name="ReadOnlyObservableCollection"
Arguments="ContosoClient.DataModel.ProductGroup" Serialize="Public" />
</Namespace>
。如果您在某些反射场景中遇到MissingMetadataException
,您可以按照解决问题。在我的项目中,我们最近在IDictionary
中遇到了类似问题,请参阅。我不知道错误消息是否与您的类似,但我们的解决方案是在.rd.xml文件中添加类似于以下内容的运行时指令:
<Type Name="System.Collections.Generic.IDictionary{System.String,System.Collections.ObjectModel.ReadOnlyCollection{System.String}}" MarshalStructure="Excluded" />
在我的项目中,我们最近在IDictionary上遇到了类似的问题,请参阅。我不知道错误消息是否与您的类似,但我们的解决方案是在.rd.xml文件中添加类似于以下内容的运行时指令:
<Type Name="System.Collections.Generic.IDictionary{System.String,System.Collections.ObjectModel.ReadOnlyCollection{System.String}}" MarshalStructure="Excluded" />
谢谢。我试试看。问题是,当应用程序挂起和终止时,我使用此属性保存它。我不知道您是否熟悉Prism库,但我使用[ReatorableState]
属性来保存所有要保存的属性。prism会话状态服务使用此属性。我收到InvalidDataContractAttribute异常
谢谢。我试试看。问题是,当应用程序挂起和终止时,我使用此属性保存它。我不知道您是否熟悉Prism库,但我使用[ReatorableState]
属性来保存所有要保存的属性。prism会话状态服务使用此属性。我收到了InvalidDataContractAttribute异常
谢谢,这很有帮助。问题不完全在MarshalStructure策略中,我只需要知道语法。谢谢,这很有帮助。问题不完全在MarshalStructure策略中,我只需要知道语法