diff --git a/Blazor.sln b/Blazor.sln
index 3d112f5a81..92870f00f2 100644
--- a/Blazor.sln
+++ b/Blazor.sln
@@ -52,6 +52,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Blazor.Build", "s
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Blazor.Browser.JS", "src\Microsoft.Blazor.Browser.JS\Microsoft.Blazor.Browser.JS.csproj", "{8A19B1CE-9B62-4440-93B3-152DDBB39D0A}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Blazor.Browser", "src\Microsoft.Blazor.Browser\Microsoft.Blazor.Browser.csproj", "{4874AFF4-335D-4037-8858-BBBB987C124B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -126,6 +128,10 @@ Global
{8A19B1CE-9B62-4440-93B3-152DDBB39D0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A19B1CE-9B62-4440-93B3-152DDBB39D0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A19B1CE-9B62-4440-93B3-152DDBB39D0A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4874AFF4-335D-4037-8858-BBBB987C124B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4874AFF4-335D-4037-8858-BBBB987C124B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4874AFF4-335D-4037-8858-BBBB987C124B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4874AFF4-335D-4037-8858-BBBB987C124B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -151,6 +157,7 @@ Global
{709C7EBE-EB93-4F6D-9491-D714B0D2E898} = {ADA3AE29-F6DE-49F6-8C7C-B321508CAE8E}
{8B3D0F1C-0E38-4E6D-BFF1-C4FDA0CD9815} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
{8A19B1CE-9B62-4440-93B3-152DDBB39D0A} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
+ {4874AFF4-335D-4037-8858-BBBB987C124B} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {504DA352-6788-4DC0-8705-82167E72A4D3}
diff --git a/samples/HostedInAspNet.Client/HostedInAspNet.Client.csproj b/samples/HostedInAspNet.Client/HostedInAspNet.Client.csproj
index 256721762b..7def5ec093 100644
--- a/samples/HostedInAspNet.Client/HostedInAspNet.Client.csproj
+++ b/samples/HostedInAspNet.Client/HostedInAspNet.Client.csproj
@@ -4,11 +4,10 @@
netcoreapp2.0
-
-
-
-
+
+
+
diff --git a/samples/HostedInAspNet.Client/Program.cs b/samples/HostedInAspNet.Client/Program.cs
index 8055591e70..1e22fe34cf 100644
--- a/samples/HostedInAspNet.Client/Program.cs
+++ b/samples/HostedInAspNet.Client/Program.cs
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using System;
+using Microsoft.Blazor.Browser;
namespace HostedInAspNet.Client
{
@@ -9,7 +9,7 @@ namespace HostedInAspNet.Client
{
static void Main(string[] args)
{
- Console.WriteLine("Hello World!");
+ new Renderer();
}
}
}
diff --git a/src/Microsoft.Blazor.Browser/Interop/JavaScriptException.cs b/src/Microsoft.Blazor.Browser/Interop/JavaScriptException.cs
new file mode 100644
index 0000000000..d44be461e9
--- /dev/null
+++ b/src/Microsoft.Blazor.Browser/Interop/JavaScriptException.cs
@@ -0,0 +1,14 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+
+namespace Microsoft.Blazor.Browser.Interop
+{
+ public class JavaScriptException : Exception
+ {
+ internal JavaScriptException(string message) : base(message)
+ {
+ }
+ }
+}
diff --git a/src/Microsoft.Blazor.Browser/Interop/WebAssembly.Runtime.cs b/src/Microsoft.Blazor.Browser/Interop/WebAssembly.Runtime.cs
new file mode 100644
index 0000000000..21d8c937a6
--- /dev/null
+++ b/src/Microsoft.Blazor.Browser/Interop/WebAssembly.Runtime.cs
@@ -0,0 +1,28 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using Microsoft.Blazor.Browser.Interop;
+using System.Runtime.CompilerServices;
+
+namespace WebAssembly
+{
+ internal static class Runtime
+ {
+ public static string EvaluateJavaScript(string expression)
+ {
+ var result = InvokeJS(expression, out var resultIsException);
+
+ if (resultIsException != 0)
+ {
+ throw new JavaScriptException(result);
+ }
+
+ return result;
+ }
+
+ // The exact namespace, type, and method name must match the corresponding entry in
+ // driver.c in the Mono distribution
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ static extern string InvokeJS(string str, out int resultIsException);
+ }
+}
diff --git a/src/Microsoft.Blazor.Browser/Microsoft.Blazor.Browser.csproj b/src/Microsoft.Blazor.Browser/Microsoft.Blazor.Browser.csproj
new file mode 100644
index 0000000000..5766db614c
--- /dev/null
+++ b/src/Microsoft.Blazor.Browser/Microsoft.Blazor.Browser.csproj
@@ -0,0 +1,7 @@
+
+
+
+ netcoreapp2.0
+
+
+
diff --git a/src/Microsoft.Blazor.Browser/Renderer.cs b/src/Microsoft.Blazor.Browser/Renderer.cs
new file mode 100644
index 0000000000..237593eee4
--- /dev/null
+++ b/src/Microsoft.Blazor.Browser/Renderer.cs
@@ -0,0 +1,13 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+namespace Microsoft.Blazor.Browser
+{
+ public class Renderer
+ {
+ public Renderer()
+ {
+ WebAssembly.Runtime.EvaluateJavaScript("console.log('Renderer'), 'done'");
+ }
+ }
+}