CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.86k stars 1.37k forks source link

Can't load Microsoft.Toolkit.Uwp.Notifications in preview 2 (FileNotFoundException) #3446

Open mtissington opened 4 years ago

mtissington commented 4 years ago

Have been running preview-1 without any issues, upgraded to preview-2 and now when I build a release version and ship we get the following exception.

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Toolkit.Uwp.Notifications, Version=7.0.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2' or one of its dependencies. The system cannot find the file specified.File name: 'Microsoft.Toolkit.Uwp.Notifications, Version=7.0.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2' at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType) at System.Reflection.RuntimeMethodInfo.get_ReturnType() at Microsoft.CSharp.RuntimeBinder.RuntimeBinderExtensions.IsEquivalentTo(MemberInfo mi1, MemberInfo mi2) at Microsoft.CSharp.RuntimeBinder.SymbolTable.FindMatchingMethod(MemberInfo method, AggregateSymbol callingAggregate) at Microsoft.CSharp.RuntimeBinder.SymbolTable.AddMethodToSymbolTable(MemberInfo member, AggregateSymbol callingAggregate, MethodKindEnum kind) at Microsoft.CSharp.RuntimeBinder.SymbolTable.AddNamesInInheritanceHierarchy(String name, BindingFlags flags, List1 inheritance) at Microsoft.CSharp.RuntimeBinder.SymbolTable.PopulateSymbolTableWithName(String name, IEnumerable1 typeArguments, Type callingType) at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.PopulateSymbolTableWithPayloadInformation(DynamicMetaObjectBinder payload, Type callingType, ArgumentObject[] arguments) at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.BindCore(DynamicMetaObjectBinder payload, IEnumerable1 parameters, DynamicMetaObject[] args, DynamicMetaObject& deferredBinding) at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.Bind(DynamicMetaObjectBinder payload, IEnumerable1 parameters, DynamicMetaObject[] args, DynamicMetaObject& deferredBinding) at Microsoft.CSharp.RuntimeBinder.BinderHelper.Bind(DynamicMetaObjectBinder action, RuntimeBinder binder, IEnumerable1 args, IEnumerable1 arginfos, DynamicMetaObject onBindingError) at Microsoft.CSharp.RuntimeBinder.CSharpInvokeMemberBinder.FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion) at System.Dynamic.DynamicMetaObject.BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) at System.Dynamic.InvokeMemberBinder.Bind(DynamicMetaObject target, DynamicMetaObject[] args) at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection1 parameters, LabelTarget returnLabel) at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite1 site, Object[] args)

ghost commented 4 years ago

Hello mtissington, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

mtissington commented 4 years ago

This might be related to #3099

Kyaa-dost commented 4 years ago

@mtissington What's the App min and Target Version are you using?

mtissington commented 4 years ago
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
duzhenyi commented 4 years ago

你好,请问.NET Core3.1支持吗?怎么最新版本没有WebViewCompatible这个对象了

michael-hawker commented 4 years ago

@duzhenyi see info about WebView here. Everything has moved to WebView2 which you can find out about here.

@mtissington is this a C# or C++ project, can you provide a bit more details on your configuration?

The PR you mentioned would have occurred with 6.1.0, so if that's working for you it may be something different like the PR we did #3423 here for 6.1.1. Can you try either of those two versions and let us know if they both work or not?

@azchohfi did we pull the 6.1.1 fix from @andrewleader into the main branch?

mtissington commented 4 years ago

It as c# project - and I include the config file contents.

7.0.0-preview2 causes the provided exception, if we revert to 7.0.0-preview1 everything works correctly.

`<?xml version="1.0" encoding="utf-8"?>

`

azchohfi commented 4 years ago

@michael-hawker yes. The PR was merged on master, and cherry-picked to a branch of rel/6.1.0, just for 6.1.1.

michael-hawker commented 3 years ago

@mtissington have you validated the latest v7.0.0-preview5 are these issues resolved?

FYI @andrewleader

mtissington commented 3 years ago

Initial testing shows v7.0.0-preview5 is still broken ... still testing to see if I can provide any more information.

mtissington commented 3 years ago

I get the same error as originally reported (see below for the exception). Interestingly on the development machine (with VS installed) I don't get the error. Only on a clean machine. Is there any way to know what components the clean machine might be missing?

`System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Toolkit.Uwp.Notifications, Version=7.0.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2' or one of its dependencies. The system cannot find the file specified.

File name: 'Microsoft.Toolkit.Uwp.Notifications, Version=7.0.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2'

at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)

at System.Reflection.RuntimeMethodInfo.get_ReturnType()

at Microsoft.CSharp.RuntimeBinder.RuntimeBinderExtensions.IsEquivalentTo(MemberInfo mi1, MemberInfo mi2)

at Microsoft.CSharp.RuntimeBinder.SymbolTable.FindMatchingMethod(MemberInfo method, AggregateSymbol callingAggregate)

at Microsoft.CSharp.RuntimeBinder.SymbolTable.AddMethodToSymbolTable(MemberInfo member, AggregateSymbol callingAggregate, MethodKindEnum kind)

at Microsoft.CSharp.RuntimeBinder.SymbolTable.AddNamesInInheritanceHierarchy(String name, BindingFlags flags, List`1 inheritance)

at Microsoft.CSharp.RuntimeBinder.SymbolTable.PopulateSymbolTableWithName(String name, IEnumerable`1 typeArguments, Type callingType)

at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.PopulateSymbolTableWithPayloadInformation(DynamicMetaObjectBinder payload, Type callingType, ArgumentObject[] arguments)

at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.BindCore(DynamicMetaObjectBinder payload, IEnumerable`1 parameters, DynamicMetaObject[] args, DynamicMetaObject& deferredBinding)

at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.Bind(DynamicMetaObjectBinder payload, IEnumerable`1 parameters, DynamicMetaObject[] args, DynamicMetaObject& deferredBinding)

at Microsoft.CSharp.RuntimeBinder.BinderHelper.Bind(DynamicMetaObjectBinder action, RuntimeBinder binder, IEnumerable1 args, IEnumerable1 arginfos, DynamicMetaObject onBindingError)

at Microsoft.CSharp.RuntimeBinder.CSharpInvokeMemberBinder.FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)

at System.Dynamic.DynamicMetaObject.BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)

at System.Dynamic.InvokeMemberBinder.Bind(DynamicMetaObject target, DynamicMetaObject[] args)

at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection`1 parameters, LabelTarget returnLabel)

at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, Object[] args)

at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid4[T0,T1,T2,T3](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)

at ActiveWords.Tasks.TaskManager.<>c__DisplayClass39_0.b__0()

`

andrewleader commented 3 years ago

Hey @mtissington, do you have a repro project you can share or instructions to reproduce this? Cause I'm not able to. Thanks!

mtissington commented 3 years ago

Hey @andrewleader I don't have a repro project - however another piece of the puzzle .. we have a couple of test machines - all running Windows 10 with the latest updates and the same version of .NET. One causes the error the other works fine.

michael-hawker commented 3 years ago

@andrewleader does the Notifications try and look for any file resources anywhere? I really with these exceptions would at least put the name of the file being looked for in their error message, eh?

We'd have to fix this this week, so unless we can figure out what's going on, we'll have to ship 7.0. If we find something later or see it effects others, than we can always ship a hotfix.

andrewleader commented 3 years ago

Nah it doesn't use file resources... I'm clueless here and agreed about just shipping 7.0 and if we figure out what's going on ship a fix later. I'll do another look through preview1 vs preview2 and see if I can think of anything else that could be causing this

andrewleader commented 3 years ago

@mtissington did you ever try version 6.1.1?

Is your project referencing Microsoft.Windows.SDK.Contracts independently of the Notifications package? Could you share all your NuGet references from your csproj?

mtissington commented 3 years ago

Did not try 6.1.1 however I tried removing any nuget reference to Microsoft.Toolkit.Uwp.Notifications and noticed Microsoft.Windows.SDK.Contracts was still listed. I've now removed any independent reference to Microsoft.Windows.SDK.Contracts and testing - will notify tomorrow with any update.

Here are the NuGet references

<ItemGroup>
<PackageReference Include="CsvHelper">
  <Version>25.0.0</Version>
</PackageReference>
<PackageReference Include="HtmlAgilityPack">
  <Version>1.11.30</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.Platforms">
  <Version>6.0.0-preview.1.21102.12</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
  <Version>7.0.0-preview5</Version>
</PackageReference>
<PackageReference Include="Microsoft.Win32.Primitives">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.Contracts">
  <Version>10.0.19041.1</Version>
</PackageReference>
<PackageReference Include="Nager.PublicSuffix">
  <Version>2.2.2</Version>
</PackageReference>
<PackageReference Include="NETStandard.Library">
  <Version>2.0.3</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
  <Version>13.0.1-beta1</Version>
</PackageReference>
<PackageReference Include="Nito.AsyncEx">
  <Version>5.1.0</Version>
</PackageReference>
<PackageReference Include="QueryString.NET">
  <Version>1.0.0</Version>
</PackageReference>
<PackageReference Include="System.AppContext">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Collections">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Collections.Concurrent">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Console">
  <Version>4.3.1</Version>
</PackageReference>
<PackageReference Include="System.Diagnostics.Debug">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Diagnostics.Tools">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Diagnostics.Tracing">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Globalization">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Globalization.Calendars">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.IO.Compression">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.IO.Compression.ZipFile">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.IO.FileSystem">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Linq">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Linq.Expressions">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Net.Http">
  <Version>4.3.4</Version>
</PackageReference>
<PackageReference Include="System.Net.Primitives">
  <Version>4.3.1</Version>
</PackageReference>
<PackageReference Include="System.Net.Sockets">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.ObjectModel">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Reflection">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Reflection.Extensions">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Reflection.Primitives">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Resources.ResourceManager">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime">
  <Version>4.3.1</Version>
</PackageReference>
<PackageReference Include="System.Runtime.Extensions">
  <Version>4.3.1</Version>
</PackageReference>
<PackageReference Include="System.Runtime.Handles">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.InteropServices">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.Numerics">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.WindowsRuntime">
  <Version>5.0.0-preview.5.20278.1</Version>
</PackageReference>
<PackageReference Include="System.Runtime.WindowsRuntime.UI.Xaml">
  <Version>5.0.0-preview.5.20278.1</Version>
</PackageReference>
<PackageReference Include="System.Security.Cryptography.Algorithms">
  <Version>4.3.1</Version>
</PackageReference>
<PackageReference Include="System.Security.Cryptography.X509Certificates">
  <Version>4.3.2</Version>
</PackageReference>
<PackageReference Include="System.Text.Encoding">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Text.Encoding.Extensions">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Text.RegularExpressions">
  <Version>4.3.1</Version>
</PackageReference>
<PackageReference Include="System.Threading">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Threading.Tasks">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Threading.Tasks.Extensions">
  <Version>4.5.4</Version>
</PackageReference>
<PackageReference Include="System.Threading.Timer">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.ValueTuple">
  <Version>4.5.0</Version>
</PackageReference>
<PackageReference Include="System.Xml.ReaderWriter">
  <Version>4.3.1</Version>
</PackageReference>
<PackageReference Include="System.Xml.XDocument">
  <Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="WpfScreenHelper">
  <Version>1.0.0</Version>
</PackageReference>

andrewleader commented 3 years ago

I'm thinking it's the explicit reference to the Windows SDK Contracts...

<PackageReference Include="Microsoft.Windows.SDK.Contracts">
  <Version>10.0.19041.1</Version>
</PackageReference>

Our package includes a dependency on that NuGet package but we target 17763 and request that you have >=17763.

I'm thinking the Windows SDK Contracts package possibly doesn't deal well with code being built against 17763 and then the parent app using 19041...

The 7.0.0-preview1 release mistakenly forgot the dependency on the Windows SDK Contracts NuGet package, so that could explain why you weren't seeing the issue...

Lemme experiment around some more.

@mtissington can you share a code snippet of what you're calling from the Notifications library so I can make sure I'm calling the same APIs as you?

andrewleader commented 3 years ago

Hmm, still unable to repro, do I don't think it's a problem with the SDK Contracts package being explicitly referenced as a newer version...

One thing I noticed in your packaged reference that seems odd to me is the .NET Core Platforms 6.0 package...

<PackageReference Include="Microsoft.NETCore.Platforms">
  <Version>6.0.0-preview.1.21102.12</Version>
</PackageReference>

I thought this was a .NET Framework 4.7.2 app as mentioned earlier? Should it be using a .NET Core 6.0 reference? What specifically is this app and type of app? And as previously mentioned the code you're calling from the Notifications library would be helpful if you can share that at all! Thanks!

mtissington commented 3 years ago

This is the class we use for notifications ... DesktopNotificationManager.txt

Yes it is a .NET Framework 4.7.2 but we make a couple of calls into .NET Core. The app is https://activewords.com - the UI is written in C# - nothing special.

mtissington commented 3 years ago

Interesting when we remove the required nuget Microsoft.NETCore.Platforms and our code which requires this then the issue does not occur.

andrewleader commented 3 years ago

Ah interesting... do you know if using .NET Core 6 alongside .NET Framework is an officially supported scenario?

michael-hawker commented 3 years ago

I think it's only supposed to work the other way around for .NET Core loading .NET Framework assemblies but only running .NET Standard APIs to help with the transition process: https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-2-0#support-for-net-framework-libraries?

Nice blog on the subject here too: https://www.ben-morris.com/sharing-libraries-between-net-core-and-net-framework-applications/

michael-hawker commented 3 years ago

@andrewleader what did you want to do with this one? I've moved to our next milestone for now.

andrewleader commented 3 years ago

I don't have the bandwidth to further investigate (we never really figured out the root issue), and it unfortunately doesn't sound like this is impacting many people (so far only this one report, so low pri), so I currently don't have any plans to address this bug. Moving to the next milestone sounds good with me.

Nirmal4G commented 2 years ago

@mtissington Can you check if you can reproduce this with PR #4234 packages?

mtissington commented 2 years ago

@Nirmal4G Because of the issue we needed to remove our dependency on this.