在为Outlook 2010构建插件时,FindRibbons任务意外失败

我们正在使用VS2013,.NET4,Microsoft Async和BCL Portability(来自Nuget)构建Outlook 2010插件,并遇到类似于此问题的构建错误,不幸的是这个论坛讨论这些资源(或其他互联网)都没有帮助解决我们的问题。

构建错误和Fusion日志位于底部。 我的第一个问题:

如何解决此FindRibbons构建任务? 从VS目标文件中完全删除它可以完成构建,但代价是没有function区控件。

我们的第二个症状是Fusion日志的Attempting download部分。 DLL在我们的项目bin\Debug目录下构建,因此其他目录搜索是奇数。 这提出了我的第二个问题:

我们忽略的Fusion日志中是否有症状?

最后一个症状来自详细的构建日志,我们在其中看到mscorlib,System.Core和其他几个库之间的冲突。 这些依赖项通过Bcl等进入,4.0.0.0与2.0.5.0冲突似乎可以防止构建或生成FileNotFoundException。 我们使用绑定重定向等尝试了许多补救措施,但无法使其工作。 最后一个问题:

此版本的解决方案或故障排除提示构建冲突?

提前谢谢了。 对不起,长度。

正如承诺的构建失败:

 Error 1 The "FindRibbons" task failed unexpectedly. System.IO.FileNotFoundException: Could not load file or assembly 'myDocketOutlookAddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'myDocketOutlookAddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' Server stack trace: 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.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.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at System.UnitySerializationHolder.GetRealObject(StreamingContext context) at System.Runtime.Serialization.ObjectManager.ResolveObjectReference(ObjectHolder holder) at System.Runtime.Serialization.ObjectManager.DoFixups() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream stm) at System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage.FixupForNewAppDomain() at System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(IMessage reqMsg) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.Build.Framework.ITask.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Running under executable C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe --- A detailed error log follows. === Pre-bind state information === LOG: DisplayName = myDocketOutlookAddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null (Fully-specified) LOG: Appbase = file:///C:/Program Files (x86)/MSBuild/12.0/bin/ LOG: DEVPATH = C:\ProgramData\Red Gate\.NET Reflector\DevPath LOG: Initial PrivatePath = NULL Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\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 (x86)/MSBuild/12.0/bin/myDocketOutlookAddIn.DLL. LOG: Attempting download of new URL file:///C:/Program Files (x86)/MSBuild/12.0/bin/myDocketOutlookAddIn/myDocketOutlookAddIn.DLL. LOG: Attempting download of new URL file:///C:/Program Files (x86)/MSBuild/12.0/bin/myDocketOutlookAddIn.EXE. LOG: Attempting download of new URL file:///C:/Program Files (x86)/MSBuild/12.0/bin/myDocketOutlookAddIn/myDocketOutlookAddIn.EXE. 

和构建版本冲突摘录:

 There was a conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes". (TaskId:7) "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" was not. (TaskId:7) References which depend on "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll]. (TaskId:7) C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll (TaskId:7) Project file item includes which caused reference "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll". (TaskId:7) System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL (TaskId:7) Microsoft.Office.Tools.Common.v4.0.Utilities, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL (TaskId:7) ... References which depend on "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" []. (TaskId:7) c:\code\Projects\myDocketForOutlook\packages\Microsoft.Bcl.1.1.9\lib\net40\System.IO.dll (TaskId:7) Project file item includes which caused reference "c:\code\Projects\myDocketForOutlook\packages\Microsoft.Bcl.1.1.9\lib\net40\System.IO.dll". (TaskId:7) System.IO (TaskId:7) c:\code\Projects\myDocketForOutlook\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Threading.Tasks.dll (TaskId:7) Project file item includes which caused reference "c:\code\Projects\myDocketForOutlook\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Threading.Tasks.dll". (TaskId:7) Microsoft.Threading.Tasks (TaskId:7) This pattern then repeats for System.Core, System, and System.Net 

您需要从AssemblyInfo.cs文件的末尾删除SecurityTransparent属性。

将Visual Studio 2010 VSTO项目升级到Visual Studio 2013时遇到了同样的问题。我解决问题的方法是两个方面的组合:

首先,我从AssemblyInfo.vb中删除了对程序集属性SecurityTransparent的引用

  

其次,我在Microsoft.Office.Tools.Common.v4.0.Utilities参考上设置了Copy Local = true。

我能够通过在.csproj中添加显式汇编版本引用来修复此错误。 有关详细信息,请参阅https://stackoverflow.com/a/29095545/4679952 。