Hi, have a "System.Reflection.TargetInvocationException Message=Exception has been thrown by the target of an invocation.

Kevin A 121 Reputation points
2021-01-18T18:45:07.353+00:00

Hi, this exception is being thrown on code that earlier worked fine. It is a message posting call only, sending a phrase to a message 57811-sys-reflection-02.png57821-sys-reflection-01.png57831-sys-reflection-03.png57812-sys-reflection-04.png57841-sys-reflection-05.png57813-sys-reflection-06.png57851-sys-reflection-07.png

Developer technologies | .NET | Xamarin
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,756 Reputation points
    2021-01-19T01:59:36.937+00:00

    Hello,

    Welcome to Microsoft Q&A!

    The Send method should specify a generic argument that represents the sender and data type.

    Modify your code as below

       MessagingCenter.Send<object,string>(this, MessageNames.ToastMessageService, msg);  
    

    Refer to https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/messaging-center#publish-a-message .

    Thank you.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.