Bug 52623 - code compilation with Roslyn fails with code -2146232797
Summary: code compilation with Roslyn fails with code -2146232797
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2017-02-19 23:07 UTC by Eric Liu
Modified: 2017-10-21 00:48 UTC (History)
5 users (show)

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


Attachments
Solution (15.63 KB, application/x-zip-compressed)
2017-02-19 23:07 UTC, Eric Liu
Details


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 FIXED

Description Eric Liu 2017-02-19 23:07:28 UTC
Created attachment 19881 [details]
Solution

[Spec]
Windowns 10 Pro x64
Visual Studio 2017
Xamarin 4.3.0.664
Xamarin.Android 7.1.0.31 (c9880f9)

[Code to repro]
using Android.App;
using Android.OS;
using System.Threading.Tasks;

namespace App2
{
    [Activity(Label = "App2", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            
            var method = GetType().GetMethod(string.Empty);
            Task.Run(async () =>
            {
                dynamic task = method.Invoke(this, new object[] { 10 });
                dynamic result = await task; // with this line it fails
            });
        }
    }
}

[Excepted behaviour]
Compile successfully.

[Actual behaviour]
Compilation fails:
error MSB6006: "csc.exe" exited with code -2146232797.
Comment 1 Eric Liu 2017-02-19 23:16:11 UTC
+ And it's working if we cast it.
Task.Run(async () =>
{
   Task<int> task = (Task<int>)method.Invoke(this, new object[] { 10 });
   dynamic result = await task;
});

(+ the non-casted code is fine with other frameworks with Roslyn)
Comment 2 Jon Douglas [MSFT] 2017-09-08 19:41:01 UTC
I am seeing the following using 15.3.3:

Error	CS0656	Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'

On 15.4 builds, I'm seeing the same thing.

Given your version information, I feel it's safe to say you're on a very old build. Xamarin Android is currently on 7.4 on stable versions and 8.0 on preview versions.

The error seems to stem from your sample project not having a reference to "Microsoft.CSharp.dll". Including this allows the sample to build successfully. Setting this bug to NEEDINFO for the time being.
Comment 3 Eric Liu 2017-10-21 00:48:56 UTC
Yeah it was in 2017 February. Can be closed, pretty much resolved since then.