ElinamLLC/SharpVectors

Could not load file or assembly 'SharpVectors.Converters.Wpf, Culture=neutral, PublicKeyToken=b532964b8548be77'

Closed this issue · 2 comments

Application: Client.exe
CoreCLR Version: 5.0.1722.21314
.NET Version: 5.0.17
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Windows.Markup.XamlParseException: 设置属性“System.Windows.ResourceDictionary.DeferrableContent”时引发了异常。
---> System.IO.FileNotFoundException: Could not load file or assembly 'SharpVectors.Converters.Wpf, Culture=neutral, PublicKeyToken=b532964b8548be77'. 系统找不到指定的文件。
File name: 'SharpVectors.Converters.Wpf, Culture=neutral, PublicKeyToken=b532964b8548be77'
at System.Reflection.RuntimeAssembly.InternalLoad(ObjectHandleOnStack assemblyName, ObjectHandleOnStack requestingAssembly, StackCrawlMarkHandle stackMark, Boolean throwOnFileNotFound, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack retAssembly)
at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, RuntimeAssembly requestingAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at System.Windows.Baml2006.Baml2006SchemaContext.ResolveAssembly(BamlAssembly bamlAssembly)
at System.Windows.Baml2006.Baml2006SchemaContext.ResolveBamlTypeToType(BamlType bamlType)
at System.Windows.Baml2006.Baml2006SchemaContext.GetClrType(Int16 typeId)
at System.Windows.Baml2006.Baml2006Reader.Process_DefAttributeKeyType()
at System.Windows.Baml2006.Baml2006Reader.ReadKeys()
at System.Windows.ResourceDictionary.SetDeferrableContent(DeferrableContent deferrableContent)
at System.Windows.Baml2006.WpfSharedBamlSchemaContext.<>c.<Create_BamlProperty_ResourceDictionary_DeferrableContent>b__297_0(Object target, Object value)
at System.Windows.Baml2006.WpfKnownMemberInvoker.SetValue(Object instance, Object value)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(XamlMember member, Object obj, Object value)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
--- End of inner exception stack trace ---
at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at Client.App.InitializeComponent()
at Client.App.Main()

@houbincarson Please provide more information of what you did or how to reproduce the issue.

Just tested the Nuget package for .NET 5 on my system and it works without any problem. Here is my test project configuration

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="SharpVectors.Wpf" Version="1.8.1" />
  </ItemGroup>

</Project>

I experienced the same error.
This problem can occur when your main application does not contain a reference to this assembly.

I had a project that was using this nuget package, but my main application did not reference this nuget package.

Solution: Also reference the nuget package in your main application (where the executable is created)