microsoft / dotnet

This repo is the official home of .NET on GitHub. It's a great starting point to find many .NET OSS projects from Microsoft and the community, including many that are part of the .NET Foundation.
https://devblogs.microsoft.com/dotnet/
MIT License
14.37k stars 2.22k forks source link

UWP ShortcutGenericAnalysis cause This object cannot be invoked because it was metadata-enabled for browsing only: #1153

Open TheFo2sh opened 4 years ago

TheFo2sh commented 4 years ago

adding ShortcutGenericAnalysis property in csproj while using automapper to map a struct type cause MissingRuntimeArtifactException.

Steps to reproduce 1- clone the reproducing solution : https://github.com/TheFo2sh/UwpDotNativeIssues 2- run using release 64 bit configuration

Expected result project run successfully

Actual result System.Reflection.MissingRuntimeArtifactException: 'This object cannot be invoked because it was metadata-enabled for browsing only: 'System.Func<Optional.Option,Optional.Option,AutoMapper.ResolutionContext,Optional.Option>.Invoke(Optional.Option,Optional.Option,AutoMapper.ResolutionContext)' For more information, please visit http://go.microsoft.com/fwlink/?LinkID=616867'

More Info if you remove ShortcutGenericAnalysis from the csproj , the project build and run correctly. In a lot of cases using ShortcutGenericAnalysis is mandatory to get the build done as without i get compiler craches.

TheFo2sh commented 4 years ago

any updates regarding this issue ?

premiaware commented 4 years ago

Hi, I have the same problem, in your sample you have missing ClassLibrary3 source. You have fix the problem?

Noemata commented 4 years ago

The bigger question now is whether any UWP related questions get any attention ever? Microsoft needs to clarify it's position on UWP. It's starting to look like UWP is dead within the company and so it's now ok to let questions like this languish. Doesn't look good.

tipa commented 4 years ago

I also cannot compile my project and am considering using ShortcutGenericAnalysis - however this issue makes me question if it is safe to use. How can I test my app to go sure there won't be any runtime errors? Are there any other drawbacks using it?

MichalStrehovsky commented 3 years ago

System.Reflection.MissingRuntimeArtifactException: 'This object cannot be invoked because it was metadata-enabled for browsing only: 'System.Func<Optional.Option,Optional.Option,AutoMapper.ResolutionContext,Optional.Option>.Invoke(Optional.Option,Optional.Option,AutoMapper.ResolutionContext)' For more information, please visit http://go.microsoft.com/fwlink/?LinkID=616867'

The ShortcutGenericAnalysis option shortcuts analysis of generics that might result in the compiler missing some dynamic patterns.

The exception message has this URL in it: http://go.microsoft.com/fwlink/?LinkID=616867. Does the URL not help?

Based on the URL, I think you need to add following fragment to your RD.XML to help where the analysis failed:

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
  <Application>
    <Type Name="System.Func{Optional.Option{TestAutomapper.OA},Optional.Option{TestAutomapper.OB},AutoMapper.ResolutionContext,Optional.Option{TestAutomapper.OB}}" Dynamic="Required All" />
  </Application>
</Directives>