Forum Visual Studio
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Bug in Interpretation

RandomString123RandomString123 Member ✭✭
edited March 2018 in Visual Studio

I get a Visualization Error in the Live Player on code that runs fine in windows:
No body on method System.Void .IStorable::set_Id(System.Guid) (NInterpretException)

I get this when running a modified version of the MockDataStore that comes in the AzureAppService example to be completely generic based and because of this it uses some weird syntax as you can see in this code..

    public interface IStorable
    {
        Guid Id { get; set; }
        string Title { get; set; }
    }

 public class MockDataStore<T> : IDataStore<T> where T : IStorable, new()
    {
        List<T> items;

        public MockDataStore()
        {
            items = new List<T>();
            var mockItems = new List<T>
            {
                new T { Id = Guid.NewGuid(), Title = "First item"},
                new T { Id = Guid.NewGuid(), Title = "Second item"},
                new T { Id = Guid.NewGuid(), Title = "Third item"}
            };

            foreach (var item in mockItems)
            {
                items.Add(item);
            }
        }
     ...
   }

I believe the interpreter is getting confused because I am using a static initializer on a generic which is forced to implement an interface. (It is weird but it works). This code works fine when run on as a native UWP application but does not work in the Live Player.

Tagged:

Posts

Sign In or Register to comment.