Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSharpScript cannot run in Android and iOS #24442

Open
jessejiang0214 opened this issue Jan 25, 2018 · 3 comments
Open

CSharpScript cannot run in Android and iOS #24442

jessejiang0214 opened this issue Jan 25, 2018 · 3 comments

Comments

@jessejiang0214
Copy link

Version Used:
Install from nuget 2.6.1 for CSharp.Scripting
Steps to Reproduce:

  1. Create Xamarin project
  2. Put these code in
            runBtn.Clicked += async (sender, e) => {
                using (var loader = new InteractiveAssemblyLoader())
                {
                    loader.RegisterDependency(typeof(object).Assembly);
                    loader.RegisterDependency(typeof(Enumerable).Assembly);
                    var script = CSharpScript.Create<int>("1 + 2", assemblyLoader: loader);

                    var result = await script.RunAsync();
                    outputLabel.Text = result.ToString(); 
                }


            };
  1. Run and crash both Android and iOS

Expected Behavior:
It should return 3 as a result
Actual Behavior:
In Android, it throws
System.IO.FileNotFoundException: Could not find file "/mscorlib.dll"
In iOS it throws

System.TypeInitializationException: The type initializer for 'AppContext' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: type
  at System.Reflection.IntrospectionExtensions.GetTypeInfo (System.Type type) [0x00009] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/reflection/introspectionextensions.cs:26
  at Microsoft.CodeAnalysis.CoreClrShim+AppContext..cctor () [0x0000f] in <7d37a385ddd24eeb96bd540d739cc157>:0
  --- End of inner exception stack trace ---
  at Microsoft.CodeAnalysis.Scripting.Hosting.RuntimeMetadataReferenceResolver.ResolveTrustedPlatformAssemblyCore (System.String name, Microsoft.CodeAnalysis.MetadataReferenceProperties properties) [0x00007] in <7d37a385ddd24eeb96bd540d739cc157>:0
  at Microsoft.CodeAnalysis.Scripting.Hosting.RuntimeMetadataReferenceResolver.ResolveReference (System.String reference, System.String baseFilePath, Microsoft.CodeAnalysis.MetadataReferenceProperties properties) [0x000d8] in <7d37a385ddd24eeb96bd540d739cc157>:0
  at Microsoft.CodeAnalysis.Scripting.Script.GetReferencesForCompilation (Microsoft.CodeAnalysis.CommonMessageProvider messageProvider, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, Microsoft.CodeAnalysis.MetadataReference languageRuntimeReferenceOpt) [0x000b5] in <7d37a385ddd24eeb96bd540d739cc157>:0
  at Microsoft.CodeAnalysis.CSharp.Scripting.CSharpScriptCompiler.CreateSubmission (Microsoft.CodeAnalysis.Scripting.Script script) [0x00021] in <c0e694fe65c94345b710ccb0d4c64a74>:0
  at Microsoft.CodeAnalysis.Scripting.Script.GetCompilation () [0x00008] in <7d37a385ddd24eeb96bd540d739cc157>:0
  at Microsoft.CodeAnalysis.Scripting.Script`1[T].GetExecutor (System.Threading.CancellationToken cancellationToken) [0x00008] in <7d37a385ddd24eeb96bd540d739cc157>:0
  at Microsoft.CodeAnalysis.Scripting.Script`1[T].RunAsync (System.Object globals, System.Func`2[T,TResult] catchException, System.Threading.CancellationToken cancellationToken) [0x0001b] in <7d37a385ddd24eeb96bd540d739cc157>:0
  at TestRoslyn.TestRoslynPage+<<-ctor>b__0_0>d.MoveNext () [0x00075] in /Users/jesse/Documents/Project/TestRoslyn/TestRoslynPage.xaml.cs:127
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018
  at UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/UIKit/UIKitSynchronizationContext.cs:24
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/Foundation/NSAction.cs:163
  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/UIKit/UIApplication.cs:79
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/UIKit/UIApplication.cs:63
  at TestRoslyn.iOS.Application.Main (System.String[] args) [0x00001] in /Users/jesse/Documents/Project/TestRoslyn/iOS/Main.cs:17

I haven't tested with iOS device, cause I know Mono has this issue mono/mono#6616, but Mono works on iOS simulator.

@jcouv
Copy link
Member

jcouv commented Jan 25, 2018

Tagging @tmat

@pacomaral
Copy link

Any news on this problem? I'm having the same problem and I haven't found any solution in the issues referenced below

@Clancey
Copy link

Clancey commented Jul 10, 2019

Duplicate issue: #23537

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants