This issue references issue #1499 in Blazor repo. After trying troubleshooting steps, I was told this would be the best place to post the issue.
Steps to Reproduce
Create Blazor App (standalone)
Reference class library
Visit Blazor page to make ML.NET Predictions
Current Behavior
There is an error output in the web console.
Expected Behavior
Expected behavior
Currently a class library is being referenced in the Blazor application which makes predictions using a pre-trained ML.NET Model. The model is hosted in Azure Storage. The expected behavior is for it to return a string representing the prediction. This solution works in a Console Application.
On which platforms did you notice this
[ ] macOS
[ ] Linux
[ X] Windows
Version Used:
Stacktrace
WASM: Initialized blazor.webassembly.js:1:31958
WASM: blazor.webassembly.js:1:32013
WASM: Unhandled Exception: blazor.webassembly.js:1:32013
WASM: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MemberAccessException: Cannot create an abstract class: System.Reflection.Emit.DynamicMethod blazor.webassembly.js:1:32013
WASM: at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&) blazor.webassembly.js:1:32013
WASM: at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x1a6e588 + 0x00096> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: --- End of inner exception stack trace --- blazor.webassembly.js:1:32013
WASM: at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x1a6e588 + 0x000ba> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) <0x1a6e258 + 0x00022> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.Runtime.Api.ApiUtils.GeneratePeek[TOwn,TRow] (Microsoft.ML.Runtime.Api.InternalSchemaDefinition+Column column) <0x21a0668 + 0x000f2> in <700e03bdc1224020a9c51406f31b73d4>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.Runtime.Api.DataViewConstructionUtils+DataViewBase`1[TRow]..ctor (Microsoft.ML.Runtime.IHostEnvironment env, System.String name, Microsoft.ML.Runtime.Api.InternalSchemaDefinition schemaDefn) <0x2198af0 + 0x000ec> in <700e03bdc1224020a9c51406f31b73d4>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.Runtime.Api.DataViewConstructionUtils+StreamingDataView`1[TRow]..ctor (Microsoft.ML.Runtime.IHostEnvironment env, System.Collections.Generic.IEnumerable`1[T] data, Microsoft.ML.Runtime.Api.InternalSchemaDefinition schemaDefn) <0x2198820 + 0x00020> in <700e03bdc1224020a9c51406f31b73d4>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.Runtime.Api.DataViewConstructionUtils.CreateFromEnumerable[TRow] (Microsoft.ML.Runtime.IHostEnvironment env, System.Collections.Generic.IEnumerable`1[T] data, Microsoft.ML.Runtime.Api.SchemaDefinition schemaDefinition) <0x215dd60 + 0x00058> in <700e03bdc1224020a9c51406f31b73d4>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.Runtime.Api.BatchPredictionEngine`2[TSrc,TDst]..ctor (Microsoft.ML.Runtime.IHostEnvironment env, System.IO.Stream modelStream, System.Boolean ignoreMissingColumns, Microsoft.ML.Runtime.Api.SchemaDefinition inputSchemaDefinition, Microsoft.ML.Runtime.Api.SchemaDefinition outputSchemaDefinition) <0x215d7f0 + 0x00036> in <700e03bdc1224020a9c51406f31b73d4>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.Runtime.Api.ComponentCreation.CreateBatchPredictionEngine[TSrc,TDst] (Microsoft.ML.Runtime.IHostEnvironment env, System.IO.Stream modelStream, System.Boolean ignoreMissingColumns, Microsoft.ML.Runtime.Api.SchemaDefinition inputSchemaDefinition, Microsoft.ML.Runtime.Api.SchemaDefinition outputSchemaDefinition) <0x215d130 + 0x00044> in <700e03bdc1224020a9c51406f31b73d4>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.PredictionModel.ReadAsync[TInput,TOutput] (System.IO.Stream stream) <0x1f91628 + 0x00056> in <de9eefdf9e51466c93acc3fbf86a9f7e>:0 blazor.webassembly.js:1:32013
WASM: at ModelLib.Model.LoadSerializeModel (System.IO.Stream serializedModel) <0x1f90f68 + 0x00026> in <4aa657c316ee4f4aa7fcb58dbfaae765>:0 blazor.webassembly.js:1:32013
WASM: at ModelLib.Model.MakeSerializedPrediction (System.Byte[] serialModel, ModelLib.IrisData input) <0x1f900c0 + 0x000d0> in <4aa657c316ee4f4aa7fcb58dbfaae765>:0 blazor.webassembly.js:1:32013
WASM: at MyBlazorApp.Pages.Prediction.predict () <0x1efc930 + 0x000d8> in <7889ac77b41345e69b6488605767213c>:0 blazor.webassembly.js:1:32013
WASM: at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_1 (System.Object state) <0x21d4080 + 0x00014> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at (wrapper delegate-invoke) <Module>.invoke_void_object(object) blazor.webassembly.js:1:32013
WASM: at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) <0x21d4028 + 0x00026> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at (wrapper delegate-invoke) <Module>.invoke_void_object(object) blazor.webassembly.js:1:32013
WASM: at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) <0x1e40218 + 0x000f8> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) <0x1e3ffb0 + 0x00020> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () <0x21d3fa8 + 0x0004a> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at System.Threading.ThreadPoolWorkQueue.Dispatch () <0x1e3b680 + 0x000ee> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0x1e3b270 + 0x00000> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: [ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MemberAccessException: Cannot create an abstract class: System.Reflection.Emit.DynamicMethod blazor.webassembly.js:1:32013
WASM: at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&) blazor.webassembly.js:1:32013
WASM: at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x1a6e588 + 0x00096> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: --- End of inner exception stack trace --- blazor.webassembly.js:1:32013
WASM: at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x1a6e588 + 0x000ba> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) <0x1a6e258 + 0x00022> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.Runtime.Api.ApiUtils.GeneratePeek[TOwn,TRow] (Microsoft.ML.Runtime.Api.InternalSchemaDefinition+Column column) <0x21a0668 + 0x000f2> in <700e03bdc1224020a9c51406f31b73d4>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.Runtime.Api.DataViewConstructionUtils+DataViewBase`1[TRow]..ctor (Microsoft.ML.Runtime.IHostEnvironment env, System.String name, Microsoft.ML.Runtime.Api.InternalSchemaDefinition schemaDefn) <0x2198af0 + 0x000ec> in <700e03bdc1224020a9c51406f31b73d4>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.Runtime.Api.DataViewConstructionUtils+StreamingDataView`1[TRow]..ctor (Microsoft.ML.Runtime.IHostEnvironment env, System.Collections.Generic.IEnumerable`1[T] data, Microsoft.ML.Runtime.Api.InternalSchemaDefinition schemaDefn) <0x2198820 + 0x00020> in <700e03bdc1224020a9c51406f31b73d4>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.Runtime.Api.DataViewConstructionUtils.CreateFromEnumerable[TRow] (Microsoft.ML.Runtime.IHostEnvironment env, System.Collections.Generic.IEnumerable`1[T] data, Microsoft.ML.Runtime.Api.SchemaDefinition schemaDefinition) <0x215dd60 + 0x00058> in <700e03bdc1224020a9c51406f31b73d4>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.Runtime.Api.BatchPredictionEngine`2[TSrc,TDst]..ctor (Microsoft.ML.Runtime.IHostEnvironment env, System.IO.Stream modelStream, System.Boolean ignoreMissingColumns, Microsoft.ML.Runtime.Api.SchemaDefinition inputSchemaDefinition, Microsoft.ML.Runtime.Api.SchemaDefinition outputSchemaDefinition) <0x215d7f0 + 0x00036> in <700e03bdc1224020a9c51406f31b73d4>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.Runtime.Api.ComponentCreation.CreateBatchPredictionEngine[TSrc,TDst] (Microsoft.ML.Runtime.IHostEnvironment env, System.IO.Stream modelStream, System.Boolean ignoreMissingColumns, Microsoft.ML.Runtime.Api.SchemaDefinition inputSchemaDefinition, Microsoft.ML.Runtime.Api.SchemaDefinition outputSchemaDefinition) <0x215d130 + 0x00044> in <700e03bdc1224020a9c51406f31b73d4>:0 blazor.webassembly.js:1:32013
WASM: at Microsoft.ML.PredictionModel.ReadAsync[TInput,TOutput] (System.IO.Stream stream) <0x1f91628 + 0x00056> in <de9eefdf9e51466c93acc3fbf86a9f7e>:0 blazor.webassembly.js:1:32013
WASM: at ModelLib.Model.LoadSerializeModel (System.IO.Stream serializedModel) <0x1f90f68 + 0x00026> in <4aa657c316ee4f4aa7fcb58dbfaae765>:0 blazor.webassembly.js:1:32013
WASM: at ModelLib.Model.MakeSerializedPrediction (System.Byte[] serialModel, ModelLib.IrisData input) <0x1f900c0 + 0x000d0> in <4aa657c316ee4f4aa7fcb58dbfaae765>:0 blazor.webassembly.js:1:32013
WASM: at MyBlazorApp.Pages.Prediction.predict () <0x1efc930 + 0x000d8> in <7889ac77b41345e69b6488605767213c>:0 blazor.webassembly.js:1:32013
WASM: at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_1 (System.Object state) <0x21d4080 + 0x00014> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at (wrapper delegate-invoke) <Module>.invoke_void_object(object) blazor.webassembly.js:1:32013
WASM: at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) <0x21d4028 + 0x00026> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at (wrapper delegate-invoke) <Module>.invoke_void_object(object) blazor.webassembly.js:1:32013
WASM: at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) <0x1e40218 + 0x000f8> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) <0x1e3ffb0 + 0x00020> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () <0x21d3fa8 + 0x0004a> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at System.Threading.ThreadPoolWorkQueue.Dispatch () <0x1e3b680 + 0x000ee> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
WASM: at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0x1e3b270 + 0x00000> in <4995adec482d4649a860872c8ccba266>:0 blazor.webassembly.js:1:32013
ExitStatus: Program terminated with exit(255) mono.js:1:177894
This issue references issue #1499 in Blazor repo. After trying troubleshooting steps, I was told this would be the best place to post the issue.
Steps to Reproduce
Current Behavior
There is an error output in the web console.
Expected Behavior
Expected behavior
Currently a class library is being referenced in the Blazor application which makes predictions using a pre-trained ML.NET Model. The model is hosted in Azure Storage. The expected behavior is for it to return a string representing the prediction. This solution works in a Console Application.
On which platforms did you notice this
[ ] macOS [ ] Linux [ X] Windows
Version Used:
Stacktrace
See file of stack trace: blazormlneterror.txt