Skip to content

Exception Thrown on Blazor WASM #43

@LuvForAirplanes

Description

@LuvForAirplanes

I am trying to use this package on my Blazor WASM (client-side) project. The goal is to reflect my database service set out to the client so service methods can be called without calling web APIs.

I'm running into this exception:

blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Cannot emit a CustomAttribute with argument of type System.RuntimeType.
System.ArgumentException: Cannot emit a CustomAttribute with argument of type System.RuntimeType.
   at System.Reflection.Emit.CustomAttributeBuilder.Initialize(ConstructorInfo con, Object[] constructorArgs, PropertyInfo[] namedProperties, Object[] propertyValues, FieldInfo[] namedFields, Object[] fieldValues)
   at System.Reflection.Emit.CustomAttributeBuilder..ctor(ConstructorInfo con, Object[] constructorArgs)
   at ImpromptuInterface.Build.BuildProxy.BuildTypeHelper(ModuleBuilder builder, Type contextType, Type[] interfaces)
   at ImpromptuInterface.Build.BuildProxy.BuildType(Type contextType, Type mainInterface, Type[] otherInterfaces)
   at ImpromptuInterface.Impromptu.DynamicActLike(Object originalDynamic, Type[] otherInterfaces)
   at ImpromptuInterface.ActLikeCaster.TryConvert(ConvertBinder binder, Object& result)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[Object,IMyInterface](CallSite site, Object arg0)
   at WasmReload.Client.Services.DIService.ResolveCustomersService() in C:\Users\Micah\source\repos\WasmReload\WasmReload\Client\Services\DIService.cs:line 67
   at WasmReload.Client.Pages.Index.OnAfterRender(Boolean firstRender) in c:\Users\Micah\source\repos\WasmReload\WasmReload\Client\Pages\Index.razor:line 17
   at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleAfterRender.OnAfterRenderAsync()
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.NotifyRenderCompletedAsync()

And here is my code: (from the front page of the repo)

   //Dynamic Expando object
    dynamic expando = new ExpandoObject();
    expando.Prop1 ="Test";
    expando.Prop2 = 42L;
    expando.Prop3 = Guid.NewGuid();
    expando.Meth1 = Return<bool>.Arguments<int>(it => it > 5);
    IMyInterface myInterface = Impromptu.ActLike(expando);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions