|Summary:||Apps using Roslyn crash when trying to load Roslyn|
|Product:||[Desktop] Xamarin.Mac||Reporter:||Bojan Rajkovic [MSFT] <bojan.rajkovic>|
|Component:||Runtime||Assignee:||Ankit Jain <ankit.jain>|
|Severity:||major||CC:||abock, adrian.murphy, chris.hamons, gouri.kumari, kumpera, luis.aguilera, masafa, mono-bugs+monomac, v-alokul|
|Tags:||Is this bug a regression?:||Yes|
|Last known good build:||15.1|
Console and Mac projects
Trace from running Mac app w/ MONO_LOG_MASK=asm MONO_LOG_LEVEL=debug
Trace from running Console app w/ MONO_LOG_MASK=asm MONO_LOG_LEVEL=debug
Description Bojan Rajkovic [MSFT] 2017-05-04 17:44:32 UTC
Created attachment 21953 [details] Console and Mac projects Apps that use Roslyn crash when trying to actually load the Microsoft.CodeAnalysis.CSharp assembly. The reason appears to be that it wants to use System.ValueTuple, and loading *that* assembly is denied by the underlying Mono. Console apps on the same Mono do not exhibit this problem—the "bad" SVT DLL is attempted (from the NuGet), and then the Facade from the framework is loaded instead, and things work. Attached is a sample project and the output of `MONO_LOG_MASK=asm MONO_LOG_DLL=debug` runs of both the Mac app and the console app.
Comment 1 Bojan Rajkovic [MSFT] 2017-05-04 17:44:57 UTC
Created attachment 21954 [details] Trace from running Mac app w/ MONO_LOG_MASK=asm MONO_LOG_LEVEL=debug
Comment 2 Bojan Rajkovic [MSFT] 2017-05-04 17:45:12 UTC
Created attachment 21955 [details] Trace from running Console app w/ MONO_LOG_MASK=asm MONO_LOG_LEVEL=debug
Comment 3 Bojan Rajkovic [MSFT] 2017-05-04 17:57:05 UTC
Copying the correct facades in by hand from X.M fixes the issue: `cp /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/Facades/System.ValueTuple.dll ./TestRoslynApp/bin/Debug/Test\ Roslyn\ App.app/Contents/MonoBundle/` `cp /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/Facades/System.Text.Encoding.CodePages.dll ./TestRoslynApp/bin/Debug/Test\ Roslyn\ App.app/Contents/MonoBundle/` After that, the app runs fine.
Comment 4 Chris Hamons 2017-05-04 22:50:13 UTC
Here is an analysis of the issue -https://gist.github.com/chamons/3ad1634b2d453458c096382a77970f2b And here is a totally hack of a possible solution - https://gist.github.com/chamons/579b408517a4546a5b2c98790ec2777f @Marek is digging into the correction solution.
Comment 5 Chris Hamons 2017-05-04 22:51:40 UTC
This may not make 15.2, but it is blocking Workbooks from using 15.2.
Comment 6 Chris Hamons 2017-05-04 22:55:59 UTC
15.2 is too late. We'll backport it on 15.2 for workbooks if needed later.
Comment 7 Marek Safar 2017-05-05 12:10:49 UTC
I think we need some runtime support for this because linker or mkbundle could fell into same trap.
Comment 8 Rodrigo Kumpera 2017-05-05 18:01:58 UTC
What do we need to do?
Comment 10 Marek Safar 2017-05-11 17:32:40 UTC
We'll try to fix it at build level which seems to me is the most general solution. I asked Ankit to work/protype the approach where msbuild checks assemblies which are copied into output folder and if one of them is blacklisted then it needs to copy it at all. I think this should cover XM case too but if not we just add extra copy step. Ankit, we have a tool  to a build a list of these assemblies and we try to work with CoreFX folks to not expand it but what's there right now will stay there.  https://github.com/mono/mono/tree/master/tools/nuget-hash-extractor
Comment 14 Marek Safar 2017-05-13 08:27:48 UTC
I just realised for the System.ValueTuple.dll special case we can just disable the remapping in the runtime, if XM correctly uses reference assemblies we'll have to do it anyway as the Mono version of System.ValueTuple won't be available.
Comment 16 Luis Aguilera 2017-05-16 21:30:08 UTC
Comment 17 GouriKumari 2017-05-17 16:43:52 UTC
Verified with XM 22.214.171.124 and mono 126.96.36.199. Issue with System.Value.Tuple got resolved. But the test app is throwing an error that it can't load System.Text.Encoding.CodePages'. ## Logs: Build Log: https://gist.githubusercontent.com/GouriKumari/b570bef07f6b913c9ff10df13fc57d56/raw/9f8df4fb26cc8c3e30f3c5b6796a1632a3abb492/gistfile1.txt Error Log: https://gist.github.com/GouriKumari/5c0b3d89a23891fb03f9960bea8c3e96 ## Test Env: https://gist.github.com/24554801aee0b26a2270d250fd67afb7
Comment 18 GouriKumari 2017-05-17 18:05:22 UTC
Since, the initial issue mentioned in the bug is verified fixed, I am closing this bug. Filed a new one for the issue mentioned in comment#17 : https://bugzilla.xamarin.com/show_bug.cgi?id=56574
Comment 19 Alok Kulkarni 2017-05-19 13:15:42 UTC
I am trying to reproduce the original defect[ Issue with System.Value.Tuple ] on my side but, any quick help regarding steps will be beneficial.
Comment 20 GouriKumari 2017-05-22 20:55:55 UTC
Verified with XM 188.8.131.52.pkg and the issue is resolved. Rosyln app launches without any exception. ##Logs: Build Log: https://gist.githubusercontent.com/GouriKumari/d47d35a6832c5323ecc9ddd3db0b535d/raw/6f0b39b4d325173e26969ce52d9ccf751952022a/gistfile1.txt ## Test Env: https://gist.github.com/2bd8651e2285eb98b15761f46d90e6fe