Windowscommunitytoolkit: Microsoft.Toolkit.Uwp.Notifications causes System.MissingMethodException

Created on 8 Feb 2017  路  4Comments  路  Source: windows-toolkit/WindowsCommunityToolkit

It happens after I upgrade nuget package _Microsoft.Toolkit.Uwp.Notifications_ to version 1.3.0, The exception is caused during setting the Text property of AdaptiveText for toast notifications, which runs normally when using version 1.2.0.
The error info is:"Method not found: 'Void Microsoft.Toolkit.Uwp.Notifications.AdaptiveText.set_Text(System.String)'."

my codes:

        ToastContent toast = new ToastContent()
        {
            ActivationType = ToastActivationType.Foreground,
            Scenario = ToastScenario.Default,
            Audio = new ToastAudio()
            {
                Silent = true,
                Loop = false,
            },
            Visual = new ToastVisual
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    AppLogoOverride = new ToastGenericAppLogo()
                    {
                        HintCrop = ToastGenericAppLogoCrop.None,
                        Source = CurrentImageUri.AbsoluteUri,
                    },
                    HeroImage = new ToastGenericHeroImage()
                    {
                        Source = CurrentImageUri.AbsoluteUri,
                    },
                    Children =
                    {
                        new AdaptiveText()
                        {
                            HintWrap = false,
                            HintMaxLines = 1,
                            HintStyle = AdaptiveTextStyle.Title,
                            Text= song.Title
                        },
                        new AdaptiveText()
                        {
                            HintWrap = false,
                            HintMaxLines = 1,
                            HintStyle = AdaptiveTextStyle.Caption,
                            Text= song.Album
                        },
                        new AdaptiveText()
                        {
                            HintWrap = false,
                            HintMaxLines = 1,
                            HintStyle = AdaptiveTextStyle.Caption,
                            Text= song.Artist
                        },

                    },
                }
            },
            Actions = new ToastActionsCustom()
            {
                Buttons =
                {
                    new ToastButton("\u23EA","previous")
                    {
                        ActivationType= ToastActivationType.Foreground
                    },
                    new ToastButton("\u23F8","pause")
                    {
                        ActivationType= ToastActivationType.Foreground
                    },
                    new ToastButton("\u25B6","play")
                    {
                        ActivationType= ToastActivationType.Foreground
                    },
                    new ToastButton("\u23E9","next")
                    {
                        ActivationType= ToastActivationType.Foreground
                    }
                },
            }
        };

        var notification = new ToastNotification(toast.GetXml());
bug notifications

Most helpful comment

Ahh, do you have multiple projects in your solution, and only updated one of your projects to 1.3.0, and left the other one on 1.2.0?

Looks like you probably have a secondary project where this code is written (maybe a class library or WinRT component).... this secondary project is still referencing 1.2.0... but your main app is referencing 1.3.0.

That'll cause this exception. Make sure all nuget packages in your solution are 1.3.0 :)

All 4 comments

ping @anbare

Hey @SmartPolarBear, thanks for reporting this! I'm unable to repro this issue using your exact code (in both debug and .net native release mode).

Can you share some info about your project setup? Is this code inside the main UWP project? Or a WinRT component library? Or a portable class library?

Ahh, do you have multiple projects in your solution, and only updated one of your projects to 1.3.0, and left the other one on 1.2.0?

Looks like you probably have a secondary project where this code is written (maybe a class library or WinRT component).... this secondary project is still referencing 1.2.0... but your main app is referencing 1.3.0.

That'll cause this exception. Make sure all nuget packages in your solution are 1.3.0 :)

@anbare Thanks very much. With your advice, I solved the problem. The reason is I forget to update the library in one of my class libraries......

Was this page helpful?
0 / 5 - 0 ratings