Bug 54015 - Build error when referencing a netstandard PCL from an Xamarin.Android project
Summary: Build error when referencing a netstandard PCL from an Xamarin.Android project
Status: RESOLVED ANSWERED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 7.1 (C9)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2017-03-27 10:16 UTC by Oliver Weichhold
Modified: 2017-05-05 11:54 UTC (History)
9 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Oliver Weichhold 2017-03-27 10:16:45 UTC
If I create a .NET Standard 1.5 Class Library in Visual Studio 2017 and reference it from a freshly created Xamarin Android Project I receive the following build output:

3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning : Exception of type 'System.OutOfMemoryException' was thrown.
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.MsfDirectory..ctor(PdbReader reader, PdbFileHeader head, BitAccess bits)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, BitAccess bits, Boolean readAllStrings)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, Boolean readAllStrings)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Pdb2Mdb.Converter.Convert(String filename)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Xamarin.Android.Tasks.ConvertDebuggingFiles.Execute()
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning : Exception of type 'System.OutOfMemoryException' was thrown.
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.MsfDirectory..ctor(PdbReader reader, PdbFileHeader head, BitAccess bits)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, BitAccess bits, Boolean readAllStrings)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, Boolean readAllStrings)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Pdb2Mdb.Converter.Convert(String filename)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Xamarin.Android.Tasks.ConvertDebuggingFiles.Execute()
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning : Exception of type 'System.OutOfMemoryException' was thrown.
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.MsfDirectory..ctor(PdbReader reader, PdbFileHeader head, BitAccess bits)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, BitAccess bits, Boolean readAllStrings)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, Boolean readAllStrings)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Pdb2Mdb.Converter.Convert(String filename)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Xamarin.Android.Tasks.ConvertDebuggingFiles.Execute()
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning : Exception of type 'System.OutOfMemoryException' was thrown.
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.MsfDirectory..ctor(PdbReader reader, PdbFileHeader head, BitAccess bits)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, BitAccess bits, Boolean readAllStrings)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, Boolean readAllStrings)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Pdb2Mdb.Converter.Convert(String filename)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Xamarin.Android.Tasks.ConvertDebuggingFiles.Execute()
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning : Exception of type 'System.OutOfMemoryException' was thrown.
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.MsfDirectory..ctor(PdbReader reader, PdbFileHeader head, BitAccess bits)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, BitAccess bits, Boolean readAllStrings)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, Boolean readAllStrings)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Pdb2Mdb.Converter.Convert(String filename)
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Xamarin.Android.Tasks.ConvertDebuggingFiles.Execute()

The application will still deploy to the emulator and run, but breakpoints inside the PCL will not be hit. Probably due to the missing debug information.
Comment 1 martin.robins 2017-03-29 16:02:38 UTC
Same problem here. I have Xamarin.Forms (PCL) project that I have changed to target .NET Standard 1.4 and it builds correctly with no errors.

If I then create an empty .NET Standard class library project (also targeting .NET Standard 1.4) and then reference that class library project from the Xamarin.Forms PCL project, the Android project will build with the warning...

(anonymised)

5>------ Build started: Project: Depot.Android, Configuration: Debug Any CPU ------
5>    Processing: obj\Debug\res\layout\tabbar.xml
5>    Processing: obj\Debug\res\layout\toolbar.xml
5>    Processing: obj\Debug\res\values\styles.xml
5>  Depot.Android -> C:\XXX\Depot\Depot\Depot.Android\bin\Debug\Depot.dll
5>  No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
5>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning : Exception of type 'System.OutOfMemoryException' was thrown.
5>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.MsfDirectory..ctor(PdbReader reader, PdbFileHeader head, BitAccess bits)
5>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, BitAccess bits, Boolean readAllStrings)
5>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, Boolean readAllStrings)
5>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Pdb2Mdb.Converter.Convert(String filename)
5>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1534,2): warning :    at Xamarin.Android.Tasks.ConvertDebuggingFiles.Execute()
5>    Processing: obj\Debug\res\layout\tabbar.xml
5>    Processing: obj\Debug\res\layout\toolbar.xml
5>    Processing: obj\Debug\res\values\styles.xml

If I remove the reference to the new class library project, the warning is no longer shown.

Xamarin   4.3.0.795 (aece090)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   7.1.0.41 (9578cdc)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   10.6.0.9 (a05f40e)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Comment 2 Miha Markic 2017-05-04 17:58:39 UTC
Can confirm OutOfMemory warnings. VS2017, Android project referencing a .NET Standard 1.6 library.
Comment 3 dean.ellis 2017-05-04 19:58:07 UTC
The problem is .net standard is producing a portable pdb file rather than a standard pub file. The PdbReader cannot load it. The Alpha channel should have code [1] in place to ignore the portable pub files rather than try to convert them to mdb.

If this still does not work on the Alpha channel

[1] xamarin-android/master/4e30546f
Comment 4 Miha Markic 2017-05-05 08:43:43 UTC
Well, what exactly does it mean that PdbReader can't load it? No nice debugging experience, actually no debugger experience at all it seems.

And solving problem just by ignoring the error won't help, besides hiding the problem in first place.

Then, once upon a time one could easily switch Xamarin channels, but not anymore.

Bottom line, am I correct assuming that .NET Standard isn't an option (unless one wants a debugging-less experience) for a long while?
Comment 5 Miha Markic 2017-05-05 08:48:18 UTC
OK, luckily there is a simple workaround. Just change Debugging Information from "portable" to "full" under Project/Properties/Build/Advanced... 

But probably that's not the best solution when you don't have sources and you have only portable debug info?
Comment 6 dean.ellis 2017-05-05 08:52:40 UTC
The current stable mono debugger cannot load the debug symbols from portable pub files. The Alpha channel mono debugger can, so portable pdb on Alpha will work with debugging :). The PDBReader is used to convert old style pdb over to the mono mdb format. In the alpha we don't need to do that for portable pdb only standard pdb.

.net standard should be working in Alpha without any issues (afaik).
Comment 7 Miha Markic 2017-05-05 08:58:02 UTC
Thanks for explaining. Makes sense. Since it works with own source code anyway (set to Full) it isn't that important anymore.

But still, switching channels isn't easy anymore (since VS2017 that is).
Comment 8 dean.ellis 2017-05-05 09:13:31 UTC
I'll try and find out if we have an documentation on the process for switching in VS2017 and post links here.
Comment 9 dean.ellis 2017-05-05 11:54:23 UTC
The documentation we have is at [1]. You need to install the Preview VS 2017 side by side with the stable. 


[1] https://developer.xamarin.com/recipes/cross-platform/ide/change_updates_channel/#visualstudio2017