MissingRuntimeArtifactException when changing IEnumerable to IQueryable on Universal Windows

In Release mode, when changing the IEnumerable source to IQueryable using the AsQueryable method, which throws a System.Reflection.MissingRuntimeArtifactException. This code works fine in debug mode, see the code snippet below.

    ObservableCollection<object> data;
    IEnumerable source;
    public MainPage()
    {
        this.InitializeComponent();
        data = new ObservableCollection<object>();
        source = data as IEnumerable;
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        var querab1 = data.AsQueryable();
        var querab2 = source.AsQueryable();
    }

Is there any solution for this exception?

+4
source share
1 answer

Add the following line in <Application>node to the runtime directive file (usually named Default.rd.xmland found in the folder Properties).

<Namespace Name="System.Linq" Dynamic="Required All" Serialize="Required All" XmlSerializer="Required All"/>

Release .NET Native. , . , . runtime .

PS: runtime :

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
  <Application>
    <Assembly Name="*Application*" Dynamic="Required All" />
    <Namespace Name="System.Linq" Dynamic="Required All" Serialize="Required All" XmlSerializer="Required All" />
  </Application>
</Directives>
+2

Source: https://habr.com/ru/post/1598867/


All Articles