-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Can't pass IJSObjectReference
in calls from JS to .NET
#26049
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
Comments
Event
object to IJSObjectReference
Event
object to C# as an IJSObjectReference
Event
object to C# as an IJSObjectReference
Event
object to C# as an IJSObjectReference
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Event
object to C# as an IJSObjectReference
IJSObjectReference
in calls from JS to .NET
Same issue here when trying to send objects from JS to .Net in a callback situation. I would like to receive the objects as IJSObjectReference on the .Net side and not have JSON attempt to serialize them. Is there an inverse to attachReviver so that I may influence the serialization process from JS to .Net? Is it attachDispatcher?? |
This my device I'm the owner here so whoever that user is please deny
access to my private repository list
jag
…On Tue, Sep 14, 2021, 1:24 PM user72356 ***@***.***> wrote:
Same issue here when trying to send objects from JS to .Net in a callback
situation. I would like to receive the objects as IJSObjectReference on the
.Net side and not have JSON attempt to serialize them. Is there an inverse
to attachReviver so that I may influence the serialization process from JS
to .Net? Is it attachDispatcher??
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#26049 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AU3JA5SS3BSJENWHV4W6DCTUB6HO7ANCNFSM4RRWPYNA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
You've been hacked! Evil laughter |
Yes, this was a typo and has been fixed for 6.0 |
The progress on solving this problem is also kept track of in issue #31151 |
Thanks for contacting us. We're moving this issue to the |
This is a bug in the application code. The JavaScript code should look like this: dotNetObj.invokeMethod(dotNetMethod, DotNet.createJSObjectReference(e)); That is, you must explicitly construct the JS object reference via @guardrex Do you know if this is covered in docs anywhere? I searched through https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/call-dotnet-from-javascript?view=aspnetcore-7.0 and the |
@TanayParikh Was it definitely fixed? I was still able to repro this message on 7.0: |
@SteveSandersonMS ... Correct ... not covered ... so I'll open an issue and hopefully reach it by the end of next week. I have about a week of .NET 7 wrap-up things to do first. |
That was in reference to a correction I'd made in one of my streaming/byte[] interop PRs. But just took another look and there are a lot of places we say |
@SteveSandersonMS @javiercn ... In @JinShil's example (in the context of creating a doc example to demonstrate this), why doesn't the event marshal back to .NET as a [JSInvokable]
public void OnClick(MouseEventArgs args)
{
Console.WriteLine($"Mouse coordinates: {args.ClientX}:{args.ClientY}");
} ... because I think that the
No 💥 ... but no values. If it turns out that it should marshal back as a [JSInvokable]
public void OnClick(IJSObjectReference objRef)
{
// ??????????
} |
Because it isn't one. It's a JavaScript |
I wouldn't have an example based on event handlers, because Blazor has a proper native way to deal with events, and it's not this. Instead I'd simply show an example of sending some arbitrary object from JS to .NET as an // Passes a reference to the non-serializable 'window' object to .NET code, which receives it as an IJSObjectReference
DotNet.invokeMethodAsync('MyApp', 'ReceiveWindowObject', DotNet.createJSObjectReference(window)); |
Very well ... one final question about an API remark for
export function createJSStreamReference(streamReference: ArrayBuffer | ArrayBufferView | Blob | any) I can't cross-link "ArrayBufferView" at MDN (or in the ECMAScript spec either). I see it described around the Net as a "superclass" for accessing the bytes of
No example on that one. I was just going to place it under the new content for Is an " Or ... should I just leave "ArrayBufferView" code-fenced without an MDN cross-link? |
I think
TBH the parameter name |
Ok, I'm good. I'll wrap this up now. If you want me to ping u on the PR, let me know, but I don't think it's necessary based on how closely the text will come off of your remarks (and the example). |
Thanks. Closing this issue now then. |
Trying to return a DOM Event object as an
IJSObjectReference
throws an exception:IJSObjectReference
to theJSInvokable
OnClick
function below.To Reproduce
Bug.csproj
Javascript to add to index.html
Index.razor
Further technical details
The text was updated successfully, but these errors were encountered: