"Consider app.config remapping" warnings in brand new project - asp.net-mvc

I've created a brand new ASP.NET Framework MVC project (using the built in project template in Visual Studio 2019). This project was converted to use PackageReference using the answer provided here.
When I do a "Rebuild Solution", everything is fine.
I then add a new ASP.NET Framework Class Library (using the build in project templte in Visual Studio 2019) to the solution.
I do another "Rebuild Solution" and everything is still fine.
Now, when I add a reference to the class library project in the web project I get the following warnings when rebuilding the solution:
Consider app.config remapping of assembly "System.Buffers, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" from Version "4.0.2.0" [] to Version "4.0.3.0" [C:\Users\Me\.nuget\packages\system.buffers\4.5.0\ref\net45\System.Buffers.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.Memory, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" from Version "4.0.1.0" [] to Version "4.0.1.1" [C:\Users\Me\.nuget\packages\system.memory\4.5.3\lib\netstandard2.0\System.Memory.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.Numerics.Vectors, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.1.3.0" [] to Version "4.1.4.0" [C:\Users\Me\.nuget\packages\system.numerics.vectors\4.5.0\ref\net46\System.Numerics.Vectors.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.Runtime.CompilerServices.Unsafe, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.4.1" [] to Version "4.0.5.0" [C:\Users\Me\.nuget\packages\system.runtime.compilerservices.unsafe\4.6.0\ref\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.ValueTuple, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" from Version "4.0.2.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\Facades\System.ValueTuple.dll] to Version "4.0.3.0" [C:\Users\Me\.nuget\packages\system.valuetuple\4.5.0\ref\net47\System.ValueTuple.dll] to solve conflict and get rid of warning.
Here's a selection from the detailed build output:
1> Encountered conflict between 'Reference:C:\Users\Me\.nuget\packages\system.valuetuple\4.5.0\ref\net47\System.ValueTuple.dll' and 'Platform:System.ValueTuple.dll'. Choosing 'Reference:C:\Users\Me\.nuget\packages\system.valuetuple\4.5.0\ref\net47\System.ValueTuple.dll' because AssemblyVersion '4.0.3.0' is greater than '4.0.2.0'.
1> Encountered conflict between 'Platform:System.ValueTuple.dll' and 'CopyLocal:C:\Users\Me\.nuget\packages\system.valuetuple\4.5.0\lib\net47\System.ValueTuple.dll'. Choosing 'CopyLocal:C:\Users\Me\.nuget\packages\system.valuetuple\4.5.0\lib\net47\System.ValueTuple.dll' because AssemblyVersion '4.0.3.0' is greater than '4.0.2.0'.
1> Unified primary reference "System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51".
1> Using this version instead of original version "4.0.2.0" in "C:\Users\Me\.nuget\packages\system.text.json\4.6.0\lib\net461\System.Text.Json.dll" because AutoUnify is 'true'.
1> Resolved file path is "C:\Users\Me\.nuget\packages\system.valuetuple\4.5.0\ref\net47\System.ValueTuple.dll".
1> Reference found at search path location "{RawFileName}".
1> This reference is not "CopyLocal" because at least one source item had "Private" set to "false" and no source items had "Private" set to "true".
1> The ImageRuntimeVersion for this reference is "v4.0.30319".
I haven't done anything other than creating a project, converting to PackageReference, adding a class library, and adding a reference to that library. I haven't made any other changes at all. I haven't even added any new NuGet packages, so everything should be as clean as it can be. Yet I get these warnings!
If I create an identical solution without converting to PackageReference the warnings are never displayed, so it obviously has something to do with PackageReference, but what/why/how?
So why do these warnings appear in a "clean" solution? Is there anything I can do to make them disappear without having to add remappings in the web.config file?
Download a demo solution with the issue

Related

TFS .NET client libraries update causes error in GetItems

We just updated .NET client libraries for TFS to version 15.131.x and which is running on the Azure DevOps 2019 server. After the update we are getting an error when calling GetItems:
using (var tfs = new TfsTeamProjectCollection(uri, cred))
{
var vs = tfs.GetService<VersionControlServer>();
var tfsWorkingFolder = ConfigurationManager.AppSettings["TFSWorkingFolder"];
var items = vs.GetItems($"{tfsWorkingFolder}", RecursionType.OneLevel);
}
The line vs.GetItems($"{tfsWorkingFolder}", RecursionType.OneLevel); gives the error
System.TypeLoadException: 'Method 'get_Properties' in type
'Microsoft.TeamFoundation.Client.HttpWebRequestWrapper' from assembly
'Microsoft.TeamFoundation.Client, Version=15.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' does not have an implementation.'
Has the definition changed?
No, the definition not changed. That package version you are using is qualified for TFS/Azure DevOps Server version.
Actually the error your got indicates a missing dependent assembly.
System.TypeLoadException: Method ‘XXX’ in type ‘YYY’ from assembly
‘ZZZ’ does not have an implementation.
Please double check this related kind of missing dll reference in your project. Remove all the reference and re-add it again, which may do the trick.
Besides, you could also upgrade the package version Microsoft.TeamFoundationServer.Client to latest which your server support and try again.

Using System.Collections.Immutable with F# and Mono

I am trying to make use of the ImmutableDictionary in F# using Mono. I'm using the Xamarin IDE.
I have set my target framework to Mono/.Net4.5 and imported the System.Collections.Immutable using the built in Nuget package manager.
The following line
open System.Collections.Immutable
is generating the following two errors
'/Users/UserName/Projects/Xamarin/OrderInfer/OrderInference/MyTest.fs(34,34): Error FS1109: A reference to the type 'System.Collections.Generic.IEnumerable'1' in assembly 'System.Runtime' was found, but the type could not be found in that assembly (FS1109) (MyTest)'
/Users/UserName/Projects/Xamarin/OrderInfer/OrderInference: Error FS1108: The type 'Lazy'2' is required here and is unavailable. You must add a reference to assembly 'System.ComponentModel.Composition, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. (FS1108) (OrderInference)
The 2nd error suggests I need to reference System.ComponentModel.Composition. Am I able to use it in Mono? If so, is there another assembly I need to reference?
EDIT:
Solution removed and reposted below as an answer
This problem can be solved by adding a reference to: 'System.ComponentModel.Composition'. In Xamarin's IDE, this is done by using the Edit References Dialog which can be found by right-clicking on the reference in your project. Go to the All tab and search for System.ComponentModel and just add the System.ComponentModel.Composition assembly.
I now have the following two assemblies installed:
System.Collections.Immutable.dll
System.ComponentModel.Composition.dll
My code now reads:
open System
open System.ComponentModel.Composition
open System.Collections.Immutable
type wordPairs = { pairs:ImmutableDictionary<string, string>; count:int}
let myPairs = {pairs = ImmutableDictionary.Create<string, string>(); count = 0}
Note: As gradbot pointed out (and Immo Landwerth later nitpicked about ;>> ), ImmutableDictionary is a abstract sealed class. And as such, it has no public constructors. So you need to use the .Create method.
ImmutableDictionary is abstract so new won't work. It does however provide a number of create methods.
ImmutableDictionary.Create<string, string>()

Compiling jabber-net in Xamarin Studio

I am trying to compile jabber-net in Xamarin Studio so I can use it in a Xamarin.iOS app.
From other searches I have done I am told I need to recompile the source.
From command line I can build the dll, but I have no idea what version of .NET/Mono this is targeting.
This makes a jabber-net.dll and a jabber-net.dll.mdb.
If I add jabber-net.dll to my project, add the reqiured
using jabber.client;
...
...
...
JabberClient client = new JabberClient ();
and try to compile I am told.
/Users/brad/Projects/XMPPChat/XMPPChat/AppDelegate.cs(37,47): error CS0584: Internal compiler error: Could not import type jabber.client.JabberClient' fromjabber-net, Version=2.1.0.702, Culture=neutral, PublicKeyToken=924c5b18328d6f09'
/Users/brad/Projects/XMPPChat/XMPPChat/AppDelegate.cs(37,38): error CS0584: Internal compiler error: Could not import type jabber.client.JabberClient' fromjabber-net, Version=2.1.0.702, Culture=neutral, PublicKeyToken=924c5b18328d6f09'
/Users/brad/Projects/XMPPChat/XMPPChat/AppDelegate.cs(37,38): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
I got no idea what is going on here...
When I try to open any of the .sln's (or include any of the existing projects, even the mono specific project) that came with jabber-net into my solution it will either hang trying to convert the project, or will tell me
The file '/Users/brad/Projects/XMPPChat/JabberNet-2.1.0.710/mono-jabber-net.csproj' could not be loaded.
and will spit out this error.
Any idea where to go from here? :|
Start a new solution from scratch, and add all of the .cs files except those in the test and examples directories. Also make sure you don't have an old version of the .dll around somewhere.

Updating to last version of the monodroid and now the solution not builds

Today I update my monodroid to the its last version. Before this my solution works fine but no I got this errors:
MyProjectPath\Classes\Presentation Layer\Class Override\ImageLoaderListener.cs(15,15): Error CS0012: The type 'Java.Lang.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c4c4237547e4b6cd'. (CS0012) (RPLAndroidApp)
and also this:
MyProjectPath\Class Override\ImageLoaderListener.cs(15,15): Error CS0012: The type 'Android.Runtime.IJavaObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c4c4237547e4b6cd'. (CS0012) (RPLAndroidApp)
I tried to recompile my java library that I build by 'JavaBindingLibraryProject' and add them again to project but When I build them I get many errors.
I'm confused what should I do?
Rebuild all your projects with the new version of Mono for Android. You have to do this because of the changes in Assembly strongnames.

Getting Migrate.exe to work

I have been struggling on executing EF Migrate.exe to work.
My Solution has couple of projects. The migrations and the entities live in the project Data. The controllers and views live in Web.
I tried using the migrate.exe - however I am struggling getting the first argument (assembly) to be accepted. Documentations says:
Assembly: Specifies the name of the assembly that contains the
migrations configuration type.
I have tried:
migrate.exe "MySolution\DataProject\bin\Debug\Data.dll"
ERROR: Could not load file or assembly 'D:\\MySolution\\Data\\bin\\Debug\\Data' or one of its dep
endencies. The given assembly name or codebase was invalid. (Exception from HRES
ULT: 0x80131047)
Any idea what is going wrong?
After reading this, this, and this
I have (I think) what you need :
If you use migrate.exe against a .NET 4 assembly you NEED to rename the Redirect.config available in packages\EntityFramework.5.0.0\tools to migrate.exe.config and copy this to the SAME directory as migrate.exe. For running migrate.exe against a .NET 4.5 assembly you DO NOT NEED this copy, the migrate.exe.config must not exist.
The correct version of entity framework DLL must be in the SAME directory as migrate.exe. Correct version is packages\EntityFramework.5.0.0\lib\net40\ for running migrate.exe against a .NET 4 assembly. Correct version is packages\EntityFramework.5.0.0\lib\net45\ for running migrate.exe against a .NET 4.5 assembly
If you specify /StartUpDirectory= do not specify the path for /assembly example : C:\Tools\migrate.exe some.dll /StartUpDirectory=C:\Project\bin\.
If you don't specify a startup directory, then you need to specify the full path in the /assembly example : C:\Tools\migrate.exe C:\Project\bin\some.dll - In this scenario migrate.exe will not be able to load the some.dll's dependencies, unless you put all some.dll's dependencies and put it in the SAME directory as migrate.exe.
If you put the migrate.exe in the same path as your some.dll, then migrate.exe will be able to use the same EntityFramework.dll which your app uses, and can load all dependencies, and can load the some.dll without any path like C:\Tools\migrate.exe some.dll
If you put the migrate.exe in a separate tools folder like Im doing it needs the correct version of the EntityFramework.dll in the SAME directory as migrate.exe, it will need the /StartUpDirectory=<the path where you target dll is present> clause, and you should specify the name of the assembly without the path like : C:\Tools\migrate.exe some.dll /StartUpDirectory=C:\Project\bin\
Heres the powershell commmand I use :
$SolutionPath = (Resolve-Path '..').Path
$ToolsPath = "$SolutionPath\Build\Lib\"
task db {
$migrator = $ToolsPath + 'Migrations\migrate.exe'
$migrateCommand = "$migrator zasz_me.dll /StartUpDirectory=$SolutionPath\zasz.me\bin\ /connectionStringName:FullContext /startUpConfigurationFile:$SolutionPath\zasz.me\Web.config /verbose"
Write-Host $migrateCommand
Invoke-Expression $migrateCommand
}
I answered a similar question here on how to override connectionstring through parameters to migrate.exe. I have yet to get it working without specifying a web/app.config file.
https://stackoverflow.com/a/14138797/134761

Resources