Is it necessary to manually add <AutoGenerateBindingRedirect> metadata to the Core project file to correctly reference assemblies?

StackOverflow https://stackoverflow.com/questions/21218712

Question

I'm using Visual Studio 2013 and MvvmCross to create an Android application using Portable Class Libraries.

I notice in my first view model, CatalogViewModel, some code is highlighted as not referencing the correct assemblies or unable to be resolved (the code builds fine even with these issues).

enter image description here

Examining the .NET Portable Subset assembly in the Object Browser shows various System assemblies included (2.0.5.0 v2.0.50727 & v4.0.30319, 4.0.0.0, 5.0.5.0). Automatic binding redirection for assemblies in .NET Framework 4.5.1 can be enabled or disabled by adding this line to the .csproj file.

<AutoGenerateBindingRedirect>true</AutoGenerateBindingRedirect>

or

<AutoGenerateBindingRedirect>false</AutoGenerateBindingRedirect>

This seems to solve the referencing and redirection issues in the IDE. I haven't found any information about this manual modification to the Core project file in any of the MvvmCross info online I reviewed so I wanted to post a question here to see if anyone had some information or best practices.

enter image description here

Was it helpful?

Solution

No, you shouldn't need AutoGenerateBindingRedirect. This feature is intended to generate binding redirects for non-platform assemblies, such as NuGet packages. Platform assemblies should be unified automatically by Visual Studio / MSBuild.

Which seems to work, since you pointed out:

the code builds fine even with these issues

So this looks like a bug in ReSharper. The fact that adding AutoGenerateBindingRedirect fixes your ReSharper issues might be a side effect of something else.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top