Xamarin - Multi-targetting - "'System.ValueTuple`2' is declared in multiple referenced" - c#

As soon as I try to compile code that use C# 7 tuples with multi targets (netstandard2.0 and xamarin.iOS) I got the following error:
Predefined type 'System.ValueTuple`2' is declared in multiple
referenced assemblies

It might've been added automatically as a reference from another package. Just remove that NuGet package to resolve the conflict.
uninstall-package System.ValueTuple is the command for the package manager console.

I don't know which assemblies the conflict occurred in.
However, I realized I had not myself added the ValueTuple nuget package so I explicitly did and the error went away.

Related

Interaction.InputBox does not exist even though I add reference to project and include Microsoft.VisualBasic

The following line gives an error saying it doesn't exist in the current content.
Interaction.InputBox("Enter Version", "", "default");
I read other questions about this I did every possible way;
Added reference to Microsoft.VisualBasic from project add section, also included;
using Microsoft.VisualBasic;
I don't understand why it creates problem.
Probably you've got an old version of the Microsoft.VisualBasic.dll.
Click on Dependencies > Frameworks > Microsoft.NETCore.App > Microsoft.VisualBasic.
Then look in the Properties window.
There you should see ..\net5.0\Microsoft.VisualBasic.dll.
If you see ..\netcoreapp3.1\Microsoft.VisualBasic.dll - that's too old.
To get the new Microsoft.VisualBasic.dll you have to base your App on .NET 5.0.
I have the same error as yours. I solved it by adding Microsoft.VisualBasic reference through Nuget package tool instead of by myself.
Propably the dll version in our system is too old, and Nuget can install the correct one.

Linq2db issue witth linqtodb.ttinclude

Hello I've have a project created with linqtodb with a database in MySQL and make an upgrade so I can work with the Windows 10, the problem grow and I've been forced to remove the linq2db and all dependencies and now when I've reinstalled and try to run the connection with the database the system give me this error:
Severity Code Description Project File Line Suppression State Error Compiling transformation: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type ~\..\contentFiles\any\any\LinqToDB.Templates\LinqToDB.ttinclude 1012
UPDATE
I've made a clean of cache give me an error updating the entityframework aparently there's no way to installed because of this:
Error Could not install package 'MySql.Data 8.0.16'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0
Any help thanks in advance.
Taking into account that those templates work for everyone, I will suspect that somemething lead to corruption of templates in nuget cache from where they referenced. I would first recommend to clear nuget cache (check this link How to clear NuGet package cache using command line?) and reinstall linq2db packages. If issue still persist - it will be better if you will fill issue with environment/versions details.

.NET Core - MSB3277: Found conflicts between different versions

I am having difficulty getting rid of the build warning:
warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved
specifically in .NET core projects.
In a full .NET framework project I would add some binding redirects so I googled around that issue and found this answer suggesting adding the following to the .csproj file:
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
I have done this but to no avail - I still get the build warnings. Anything else I can do?
I had a look at your project and the problem seems to be a conflict with the versions that Rssdp was built against and the assembly version that the referenced System.Net.Http version (4.3.0) provides as compile-time reference.
This can be fixed by updating System.Net.Http to 4.3.2.
<PackageReference Include="System.Net.Http" Version="4.3.2"/>
Run Update-Package via Package Manager Console, this will fix MSB3277, what it does it reinstall all the packages with highest version possible.
More info on official docs https://learn.microsoft.com/en-us/nuget/consume-packages/reinstalling-and-updating-packages
I had the same issue. Got several warnings on one of the projects. I updated all packages from the solution level and warnings went away.
I used the Visual Studios for Mac to update the package.
Right click the solution, then Update Nuget Packages.
Does any of you dependencies use <PrivateAssets>?
If project A has a private reference, and both the private reference and another reference requires some package X, but the private one requires a higher version of package X, then the assembly for project A will also require the higher version of package X.
However you end up with a situation where any other project, e.g. project B, that references project A will only see the lower version of package X as a dependency - hence select the lower version of the assembly of package X to be copied to the output directory. The good news is that this DLL-HELL is detected at build time, where it sees that assembly projectA.dll requires a different projectX.dll than the one already designated as primary, and thus it logs some very unhelpful output about packageX being required by itself, which makes no sense... and gives up the build.

Build Error in Mono Develop

I tried to build my existing Mvc application with Mono by changing targeting framework to Mono/.Net 4.5 in Mono Develop.
That gives me build error
Build failed. Item has already been added. Key in dictionary: 'Path' Key being added: 'PATH'
Build: 1 error, 0 warnings
I tried to make new project that also gave the same error.
I also tried to updating nuget package but that also did not works.
This question is somewhat out of date, but I thought I'd include an answer to give folks a thread to follow.
I found several VS 2015 templates had elements in the projects that would cause this type of issue in sub-build files for mono. For example, references related to Rosyln or Microsoft.CodeDom.Providers.DotNetCompilerPlatform. My particular project didn't need the latter, and I removed the related references to resolve the issue. The full error was
Error building target IncludeRoslynCompilerFilesToItemGroup:
Item has already been added. Key in dictionary: 'Link' Key being added: 'Link'
I figured out that this was related to my Microsoft.CodeDom.Providers.DotNetCompilerPlatform by greping for the target, e.g.
grep IncludeRoslynCompilerFilesToItemGroup * -R
to find the offending package and figuring out if I could remove the code reference.

Ninject.Web.Mvc.FluentValidation and FluentValidation.MVC4

I have tried setting up Ninject.Web.Mvc.FluentValidation in my ASP.NET MVC4 project
as shown below:
var ninjectValidatorFactory = new NinjectValidatorFactory(kernel);
//ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(new NinjectValidatorFactory(kernel)));
FluentValidationModelValidatorProvider.Configure(x => x.ValidatorFactory = ninjectValidatorFactory);
DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
but I am getting the below errors:
Error 1 The type 'FluentValidation.ValidatorFactoryBase' is defined in an assembly that is not referenced. You must add a reference to assembly 'FluentValidation, Version=2.0.0.0, ...
Error 2 Cannot implicitly convert type 'Ninject.Web.Mvc.FluentValidation.NinjectValidatorFactory' to 'FluentValidation.IValidatorFactory'. An explicit conversion exists (are you missing a cast?)
I can see the NuGet Package for Ninject.Web.Mvc.FluentValidation is version 3.0.0.0
and the error is telling me it is looking for version 2 of FluentValidation for its dependency.
If I install the NuGet package just for Ninject.Web.Mvc.FluentValidation then it installs the FluentValidation v2 dependency rather than version 3.4.6
but I can also see here: https://github.com/ninject/ninject.web.mvc.fluentvalidation/commit/82096d0afd15c41d01c09fd47f4247682261768e
a note about the project being updated for version 3.4.6
I am currently using NuGet to add the FluentValidation.MVC4 package to my project and then adding Ninject.Web.Mvc.FluentValidation after it (which finds it's dependency already exists and doesn't add it).
I can see that the NuGet package was last published on the 1st April 2013 but when I look at the .nuspec file in my project it shows
<dependency id="FluentValidation" version="3.2.0.0" />
Is there anything I have done wrong with this setup? or a way I can get this working through the package manager console to update the dependency version?
UPDATE: The reason for this is because Ninject.Web.Mvc.FluentValidation is using the signed version of FluentValidation which is strongly named.
David Ebbo has a good post about strong names and binding redirects here
http://blog.davidebbo.com/2011/01/nuget-versioning-part-3-unification-via.html
I still did not bother doing this to fix my problem, the NuGet package only has 1 class, the NinjectValidatorFactory, so it's worth just implementing your own.
To fix my problem for now I have put the NinjectValidatorFactoryclass into my own project. This looks to me like the current NuGet package needs to be updated further before it uses FluentValidation 3.4.6.
enter these codes in Package Manager Console :
Install-Package FluentValidation-Signed
Install-Package FluentValidation.MVC3-Signed -IgnoreDependencies
Install-Package Ninject.Web.Mvc.FluentValidation -IgnoreDependencies
-IgnoreDependencies is important .

Categories

Resources