I have trouble using generated classes in my UWP app. The Xaml compile gives me an error message when I try to compile my solution:
Xaml Internal Error error WMC9999: Cannot determine the item type of collection type 'Google.Protobuf.Collections.RepeatedField`1[System.String]' because it has more than one Add method or ICollection implementation. To make this collection type usable in XAML, add a public Add(object) method, implement System.Collections.IList or a single System.Collections.Generic.ICollection.
My protobuf looks like this:
syntax = "proto3";
option csharp_namespace = "MyNamespace";
package basics;
message TestClass{
string TestProp = 1;
repeated string Names = 2;
}
I used these nugets to generate the class:
<PackageReference Include="Google.Protobuf" Version="3.17.3" />
<PackageReference Include="Grpc.Tools" Version="2.40.0"/>
To produce the error is quite easy. Just put an ObservableCollection or List of Type 'TestClass' into the code behind of a Page:
public sealed partial class MainPage : Page
{
public List<TestClass> TestClasses { get; } = new List<TestClass>(); // <- this causes the error!
public MainPage()
{
this.InitializeComponent();
}
}
My questions:
- Is there a way to get rid of this error or compile the protobuf file without getting RepeatedFields?
- What would be a good workflow to use protobuf and grpc in an UWP app? (Apparently mine isn`t)