gpt4 book ai didi

c# - 无法加载文件或程序集 'Xceed.Wpf.Toolkit

转载 作者:可可西里 更新时间:2023-11-01 07:49:43 27 4
gpt4 key购买 nike

我正在为另一个应用程序 Autodesk Revit 开发一个插件,它是作为一个单独的 DLL 类库构建的。我正在尝试使用 Wpf Tool Kit Property grid在我的一个 WPF 窗口中。属性网格在 Visual Studio 中显示良好,智能感知也能正常工作。但是,当我尝试在加载加载项的情况下启动 Revit 时,出现以下异常。

System.Windows.Markup.XamlParseException occurred
HResult=-2146233087
Message=Could not load file or assembly 'Xceed.Wpf.Toolkit, PublicKeyToken=3e4669d2f30244f4' or one of its dependencies. The system cannot find the file specified.
Source=PresentationFramework
LineNumber=133
LinePosition=27
StackTrace:
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
InnerException: System.IO.FileNotFoundException
HResult=-2147024894
Message=Could not load file or assembly 'Xceed.Wpf.Toolkit, PublicKeyToken=3e4669d2f30244f4' or one of its dependencies. The system cannot find the file specified.
Source=mscorlib
FileName=Xceed.Wpf.Toolkit, PublicKeyToken=3e4669d2f30244f4
FusionLog==== Pre-bind state information ===
LOG: User = GLOBAL\eric.anastas
LOG: DisplayName = Xceed.Wpf.Toolkit, PublicKeyToken=3e4669d2f30244f4
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Xceed.Wpf.Toolkit, PublicKeyToken=3e4669d2f30244f4 | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Program Files/Autodesk/Revit 2014/
LOG: Initial PrivatePath = NULL
Calling assembly : PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files\Autodesk\Revit 2014\Revit.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit 2014/Xceed.Wpf.Toolkit.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit 2014/Xceed.Wpf.Toolkit/Xceed.Wpf.Toolkit.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit 2014/SDA/bin/Xceed.Wpf.Toolkit.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit 2014/SDA/bin/Xceed.Wpf.Toolkit/Xceed.Wpf.Toolkit.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit 2014/Xceed.Wpf.Toolkit.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit 2014/Xceed.Wpf.Toolkit/Xceed.Wpf.Toolkit.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit 2014/SDA/bin/Xceed.Wpf.Toolkit.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit 2014/SDA/bin/Xceed.Wpf.Toolkit/Xceed.Wpf.Toolkit.EXE.

StackTrace:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
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.ResolveBamlType(BamlType bamlType, Int16 typeId)
at System.Windows.Baml2006.Baml2006SchemaContext.GetXamlType(Int16 typeId)
at System.Windows.Baml2006.Baml2006Reader.Process_ElementStart()
at System.Windows.Baml2006.Baml2006Reader.Process_OneBamlRecord()
at System.Windows.Baml2006.Baml2006Reader.Process_BamlRecords()
at System.Windows.Baml2006.Baml2006Reader.Read()
at System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
InnerException:

通常,当我想从 Revit 插件引用第 3 方程序集时,我只需确保将第 3 方 DLL 复制到与我的插件 DLL 相同的位置。我检查了一下,Xceed.Wpf.Toolkit.dll 被复制到包含我的插件 DLL 的目录。

我从错误中的日志消息中注意到它正在 Revit 程序目录中查找 DLL。将 Xceed.Wpf.Toolkit.dll 复制到此目录后,我不再收到错误。

但是,我有现有的插件部署工具,这些工具依赖于插件文件位于它们自己的隔离文件夹中。

那么,有没有人知道如何让插件找到 WPF 工具包库?

最佳答案

因此,从 2014 年开始,我找到了一个新的更好的解决方案来解决我的这个问题。

今天我遇到了同样的问题,即从程序集中加载 WPF 控件会抛出 XamlParseException,只是这次是我创建的 WPF 控件库程序集。

我尝试将 DLL 移动到与 EXE 相同的文件夹中,并且像以前一样解决了问题。

经过一番搜索,我在 telerik.com 论坛上发现了这个问题: http://www.telerik.com/forums/xamlparseexception-could-not-load-file-or-assembly

事实证明,如果您只是通过添加 x:Name 属性为控件命名,这将在代码隐藏中添加对控件的引用,并且出于某种原因解决了问题加载程序集。

  <!--This causes a XamlParseException -->
<mylib:MyCustomControl />

<!-- This works -->
<mylib:MyCustomControl x:Name="foobar"/>

关于c# - 无法加载文件或程序集 'Xceed.Wpf.Toolkit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22108712/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com