Does the new UnsafeAccessor not work with protected visibility? #108950
Unanswered
ScarletKuro
asked this question in
Q&A
Replies: 1 comment 4 replies
-
Can you share a complete version of your code (and also which .NET version you are using)? I've tried running this sample and it works as expected (both on .NET 8 and .NET 9): using System.Runtime.CompilerServices;
using Microsoft.AspNetCore.Components;
var c = new MyComponent();
var ex = new Exception("Test");
await DispatchExceptionAsync(c, ex);
[UnsafeAccessor(UnsafeAccessorKind.Method, Name = "DispatchExceptionAsync")]
static extern Task DispatchExceptionAsync(ComponentBase component, Exception exception);
class MyComponent : ComponentBase
{
} Version of |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I wanted to access the following method from the
ComponentBase
class:I initially used the following
UnsafeAccessor
:However, I encountered an exception saying that the method
DispatchExceptionAsync
could not be found. As a workaround, I had to access the private_renderHandle
directly:I did not find any limitations mentioned in:
I expected it to work with any visibility, as long as the signature is defined correctly.
Beta Was this translation helpful? Give feedback.
All reactions