What do these Mono/xbuild warnings mean and how do I fix them? - mono

I build VS2010 projects with Mono's xbuild 2.10.5.0. The projects use the '.NET Framework 3.5 Client Profile' as the target framework (they must be 3.5 compatible and I don't need more than the client profile parts).
I'm getting the following warnings:
Build succeeded.
Warnings:
c:\Project\MyProject.csproj (default targets) -> C:\PROGRA~2\Mono\lib\mono\4.0\Microsoft.Common.targets (GetReferenceAssemblyPaths target) ->
C:\PROGRA~2\Mono\lib\mono\4.0\Microsoft.Common.targets: warning : Unable to find framework corresponding to the target framework moniker '.NETFramework,Version=v3.5,Profile=Client'. Framework assembly references will be resolved from the GAC, which might not be the intended behavior.
c:\Project\MyProject.csproj (default targets) -> C:\PROGRA~2\Mono\lib\mono\4.0\Microsoft.Common.targets (ResolveAssemblyReferences target) ->
C:\PROGRA~2\Mono\lib\mono\4.0\Microsoft.Common.targets: warning : Reference 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' not resolved
C:\PROGRA~2\Mono\lib\mono\4.0\Microsoft.Common.targets: warning : Found a conflict between : 'System' and 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using 'System' reference.
C:\PROGRA~2\Mono\lib\mono\4.0\Microsoft.Common.targets: warning : Found a conflict between : 'System.Core' and 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using 'System.Core' reference.
I'm afraid I don't understand these and the only Google hit for "Unable to find framework corresponding to the target framework moniker" is the commit for that error message.
What do these warnings mean and how can I fix them? Is the 'client profile' not supported by Mono at all? If so, I couldn't find anything about that in the Mono documentation. What causes the unresolved mscorlib reference and where are these two System references it reports a conflict between?

You are guessing correctly - Mono does not support the 'Client' profile (e.g. search Mono version of 3.5 Microsoft.Common.targets for any mention of 'Client'), only the full 3.5 and 4.0 profiles. To fix them, you need to specify one of the supported profiles in your project file. Profile selection only restricts the set of references available during build, an assembly compiled with the 'Client' profile will work on the 'Full' profile just fine.
The mscorlib, Version=2.0.0.0 unresolved reference is happening because you are compiling with a 4.0 profile (which is the default fallback). It will disappear once you set your profile to a supported value. If you do not want to change your project file, you can build with xbuild /p:TargetFrameworkProfile="", which correctly chooses the 3.5 set of assemblies.

Related

Service Reference in UWP reusing NetStandard assemblies

In an client/server application I am trying to reuse assemblies targeting NetStandard1.4 in the Server and in an UWP. Communication is done using WCF.
If "Reuse types in referenced assemblies" is unchecked the service references is created. Once I check the option to reuse assemblies I get the following error:
"Custom tool warning: Cannot resolve dependency to assembly 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event."
and warnings saying:
"Custom tool warning: Cannot resolve dependency to assembly 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event."
I found this thread: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/5092755b-e1ed-4496-ae6d-74386ebdac98/uwpservice-references-in-universal-apps-and-portable-class-libraries?forum=wpdevelop it is related to PCL and I hope netstandard has overcome that issue.
I have tried importing frameworks in my UWP app:
"frameworks": {
"uap10.0": {
"imports": [ "netstandard1.4", "netstandard1.6.1" ]
}
},
but it didn't work. It seems like I am really close to have it working but I am missing a detail that makes everything work.

system.design reference issue of WixSharp on .net 4

I'm trying to use WixSharp with .net 4, but I got this warning:
Warning The currently targeted framework ".NETFramework,Version=v4.0,Profile=Client" does not include "System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which the referenced assembly "WixSharp, Version=1.0.39.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL" depends on. This caused the referenced assembly to not resolve. To fix this, either (1) change the targeted framework for this project, or (2) remove the referenced assembly from the project.
I checked that System.Design is not referenced. When I tried to add reference to it, it's actually grayed out in add reference dialog.
As a result, just as the warning says, WixSharp is not resolved, and all namespaces in WixSharp has a missing of reference error.
How should I fix this? compile WixSharp from source?
Fei

NServiceBus appears to take a hard reference to version 2.0.0.0 via Ionic.Zip.dll

I'm using NServiceBus in a complicated solution (150+ projects, many of them use NSB). Up until last night, when I couldn't stand it anymore, every project had it's own target directories (./bin/debug and ./bin/release). Because of the dependencies between my projects, I was building and rebuilding the same binaries many times over, so we decided to change to a shared output directory for the whole thing, which dramatically improves the build time of the solution. So far so good...
However, when I tried to start up my project, it fails to start giving me the error:
Warning 1 : Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets 1697 5 My.Assembly.Goes.Here
Uh, oh. So, I dutifully turn up the log verbosity, clean and rebuild the whole mess, to find this in the log output:
30>------ Build started: Project: My.Assembly.Goes.Here, Configuration: Debug Any CPU ------
28>Building with tools version "12.0".
<Lots of stuff omitted...>
28> There was a conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes".
28> "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" was not.
28> References which depend on "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\mscorlib.dll].
<etcetera...>
Out comes Dependency Walker (great tool, btw). OK, so what's depending on the old 2.0 framework? Look for every reference to mscorlib and ... One of these things is not like the other...
NServiceBus.Hosting.Azure takes a dependency on Ionic.Zip.dll which, in turn, takes a dependency on the 2.0.0.0 version of mscorlib.dll. Ouch. FWIW, the version of NServiceBus.Hosting.Azure that does so is 5.3.2.0.
This looks to me to be similar to the issue here: https://github.com/Particular/NServiceBus/issues/664
Can I get around this with an Assembly Binding Redirect? Is there some way for me to tell NSB to tell Ionic.Zip.dll that the 4.0.0.0 version of mscorlib.dll is fine, thank you very much?
Or is this an NSB bug?
Thanks in advance.
A binding redirect on mscorlib should work in my opinion, or you could try a binding redirect on a newer version of dotnetziplib (Ionic) that targets 4.0

Where is the version and publickey token information stored in an application?

I load a project from TFS to my local machine. But it need log4Net libary, and I download it from internet. It is rebuilt successfully. But when it runs, the exception comes.
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral,
PublicKeyToken=1b44e1d426115821' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)
I know this is the problem of mixing the version and publickey token. But my question is, when the code runs in visual studio, how can it know that it need log4net in version1.2 ? Anyone can help? Thank you.
What you have here is an assembly in your project that is referencing the log4net assembly with this version; it can be a direct reference, or an indirect reference (your project references A.dll that references log4net.dll)
Look through your projects to find the referencing assembly, and either satisfy the reference (get the correct version through nuget, that's the easiest) or change it. The referenced assemblies are contained in the project file (*.csproj or whatever extension is applicable to your language) with a Reference tag
When you include a reference, the naming strength will depend on what settings you chose:
<Reference Include="name">
<!-- here no version is specified because no specific version is needed -->
<Reference Include="name, Version=xxx, Culture=neutral, processorArchitecture=MSIL">
<-- version is specified, perhaps because a specific version was referenced at one time -->
Some more info can be found on this very site

Where could I get mono's TPL.Dataflow?

I am working with mono-3.0.10 on a Macbook. In the mono 3.0 release note, Tpl.Dataflow is mentioned, and I also noticed that the source code of Tpl.Dataflow is there in mono's github repo master branch.
But I couldn't find it in my local mono install.
logan#Logans-MBA /Library/Frameworks/Mono.framework
{13-06-04 3:47:48} $ find . -name "*.Dataflow.*"
./Versions/3.0.10/lib/mono/4.5/System.Threading.Tasks.Dataflow.dll
logan#Logans-MBA /Library/Frameworks/Mono.framework
{13-06-04 3:59:55} $ file ./Versions/3.0.10/lib/mono/4.5/System.Threading.Tasks.Dataflow.dll
./Versions/3.0.10/lib/mono/4.5/System.Threading.Tasks.Dataflow.dll: broken symbolic link to ../gac/System.Threading.Tasks.Dataflow/4.0.0.0__b77a5c561934e089/System.Threading.Tasks.Dataflow.dll
I have tried reinstall the mono from installer, but no luck.
Then, I tried the dlls downloaded from nuget, the following errors comes:
/Users/logan/Workspace/Camp/Dragon/ClientEventHandlerDemos/DataflowBlockClientEventHandler.cs(11,13): error CS0012: The type `System.Object' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
/Users/logan/Workspace/Camp/Dragon/ClientEventHandlerDemos/DataflowBlockClientEventHandler.cs(11,34): error CS0012: The type `System.Action`1<TInput>' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
There are 3 editions from nuget, net45, netcore45 and portable-net45. I tried them all, but still no luck.
So, where could I find the right update to date Tpl.Dataflow works with mono?