我正在为应用程序编写加载程序。 外接程序是一个DLL,它位于特定文件夹%APPDATA & /应用/加载项/ MyAddIn加载程序集的问题
所以,我有几个项目的解决方案和MyAddInFolder包含下列文件:
IVC.Common.dll
IVC.MaterialCatalogEditorAddIn.dll
IVC.MaterialCatalogEditor.dll
的位于所述IVC.MaterialCatalogEditorAddIn.dll和IVC.MaterialCatalogEditorAddIn.dll应用程序调用方法参照的IVC.MaterialCatalogEditor.dll和IVC.MaterialCatalogEdit or.dll引用到IVC.Common.dll
有一个WPF在IVC.MaterialCatalogEditor.dll 320交织。而就在XAML文件中被引用到IVC.Common.dll
当我尝试从应用程序我得到一个异常执行外接程序指令“无法加载组件IVC.Common.dll”
我用FusionLogViewer和我得到了以下信息记录
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Program Files\Autodesk\Revit Structure 2012\Program\Revit.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = SK\ChekalinVV
LOG: DisplayName = IVC.MaterialCatalogEditor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Program Files/Autodesk/Revit Structure 2012/Program/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = Revit.exe
Calling assembly : IVC.MaterialCatalogEditorAddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Program Files\Autodesk\Revit Structure 2012\Program\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 Structure 2012/Program/IVC.MaterialCatalogEditor.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit Structure 2012/Program/IVC.MaterialCatalogEditor/IVC.MaterialCatalogEditor.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit Structure 2012/Program/IVC.MaterialCatalogEditor.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit Structure 2012/Program/IVC.MaterialCatalogEditor/IVC.MaterialCatalogEditor.EXE.
LOG: Attempting download of new URL file:///C:/Users/ChekalinVV/AppData/Roaming/Autodesk/Revit/Addins/2012/IVC/FamilyManager/IVC.MaterialCatalogEditor.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Users\ChekalinVV\AppData\Roaming\Autodesk\Revit\Addins\2012\IVC\FamilyManager\IVC.MaterialCatalogEditor.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: IVC.MaterialCatalogEditor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
LOG: Where-ref bind Codebase does not match what is found in default context. Keep the result in LoadFrom context.
LOG: Binding succeeds. Returns assembly from C:\Users\ChekalinVV\AppData\Roaming\Autodesk\Revit\Addins\2012\IVC\FamilyManager\IVC.MaterialCatalogEditor.dll.
LOG: Assembly is loaded in LoadFrom load context.
这里一切就OK了。该IVC.MaterialCatalogEditorAddIn.dll电话* IVC.MaterialCatalogEditor.dll *在外接程序文件夹
但接下来的日志:
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Program Files\Autodesk\Revit Structure 2012\Program\Revit.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = SK\ChekalinVV
LOG: DisplayName = IVC.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Program Files/Autodesk/Revit Structure 2012/Program/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = Revit.exe
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 Structure 2012\Program\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 Structure 2012/Program/IVC.Common.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit Structure 2012/Program/IVC.Common/IVC.Common.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit Structure 2012/Program/IVC.Common.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Revit Structure 2012/Program/IVC.Common/IVC.Common.EXE.
LOG: All probing URLs attempted and failed.
的PresebtationFramework组装尝试叫IVC.Common.dll并尝试仅从应用程序文件夹加载。
为什么一个DLL试图从AddIn文件夹加载,但另一个DLL试图只从应用程序文件夹加载?以及如何解决我的问题。
所有项目都有任何CPU平台目标。该应用程序是x64。
当我加载IVC.MaterialCatalogEditor.dll从测试可执行应用程序的一切工作正常。
EDITED 某些代码:
的主要代码在IVC.MaterialCatalogEditorAddIn.dll
[Transaction(TransactionMode.ReadOnly)]
public class Command : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
MaterialsWindow materialsWindow =
new MaterialsWindow();
materialsWindow.DataContext =
new MaterialsViewModel();
materialsWindow.ShowDialog();
return Result.Succeeded;
}
}
的MaterialsWindow类和MaterialsViewModel类位于IVC.MaterialCatalogEditor。 dll
debbuger显示错误o n在IVC.MaterialCatalogEditor中的这部分xaml。DLL:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ViewModel="clr-namespace:IVC.MaterialCatalogEditor.ViewModel"
xmlns:Common="clr-namespace:IVC.Common;assembly=IVC.Common">
<DataTemplate
DataType="{x:Type Common:ResourceWithCharge}">
<!-- Some data template -->
</DataTemplate>
</ResourceDictionary>
组织编写 我已经写了具有相同结构的测试解决方案作为我工作的解决方案。 从测试应用程序启动它时,它没有任何错误。但是,如果我从外接程序执行它,它失败,“无法加载组件Common.dll”
你能显示任何相关的代码吗?你所提供的全部是应用程序特定的日志。 – 2012-07-19 04:25:18
增加了一些代码 – 2012-07-19 04:44:50
欢迎使用程序集加载地狱。安装到GAC可能是唯一的解决方案。对于所有工作来说,第二个“日志”仍然应该处于“加载”的上下文中。您可以尝试预加载您的相关程序集,但不知道这是否可行。我看到了与VS插件相同的问题。 – leppie 2012-07-19 05:28:02