You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am following the example to use a RequestMessage:
// Request the value from another module
User user = WeakReferenceMessenger.Default.Send<LoggedInUserRequestMessage>();
But am getting Compiler Error CS0266 which says there is no implicit conversion from RequestMessage to IMyInterface but an explicit conversion exists, am I missing a cast.
public class MyInterfaceRequestMessage : RequestMessage<IMyInterface>
{
}
IMyInterface myInterface = WeakReferenceMessenger.Default.Send<MyInterfaceRequestMessage>();
So I tried adding an explicit cast: IMyInterface myInterface = (IMyInterface)WeakReferenceMessenger.Default.Send<MyInterfaceRequestMessage>();
But then at runtime I get an exception: System.InvalidCastException: 'Unable to cast object of type 'MyInterfaceRequestMessage' to type 'IMyInterface'.'
This is in Visual Studio 2022 (v17.1.0)
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
ID: c7dcc853-0669-abff-dfd4-2f3f846550e6
Version Independent ID: dda76eac-fef5-01f4-6ddc-e5265c8e9d17
I am following the example to use a RequestMessage:
But am getting Compiler Error CS0266 which says there is no implicit conversion from RequestMessage to IMyInterface but an explicit conversion exists, am I missing a cast.
So I tried adding an explicit cast:
IMyInterface myInterface = (IMyInterface)WeakReferenceMessenger.Default.Send<MyInterfaceRequestMessage>();
But then at runtime I get an exception:
System.InvalidCastException: 'Unable to cast object of type 'MyInterfaceRequestMessage' to type 'IMyInterface'.'
This is in Visual Studio 2022 (v17.1.0)
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: