简体   繁体   English

修复.NET应用程序中的并行错误

[英]Fix a side-by-side error in .NET application

I am porting a C# program from Visual Studio 2010 to Visual Studio 2013. Both are Express versions of the IDE. 我正在将C#程序从Visual Studio 2010移植到Visual Studio2013。两者都是IDE的Express版本。 In the 2013 build I encounter a side-by-side failure. 在2013年的版本中,我遇到了并行失败。

The application has failed to start because its side-by-side configuration is incorrect.

The sxstrace.exe tool does not provide any information that I was able to interpret usefully. sxstrace.exe工具没有提供我能够有用解释的任何信息。 Here is the human readable output from the tool. 这是该工具的可读输出。

Begin Activation Context Generation. 开始激活上下文生成。

Input Parameter: 输入参数:

Flags = 0 标志= 0

ProcessorArchitecture = AMD64 ProcessorArchitecture = AMD64

CultureFallBacks = en-GB;en;en-US CultureFallBacks = zh-CN; en; zh-CN

ManifestPath = C:\\Users\\Brian\\Documents\\Visual Studio 2013\\Projects\\WebInterface1\\WebInterface1\\bin\\Debug\\WebInterface1.exe ManifestPath = C:\\ Users \\ Brian \\ Documents \\ Visual Studio 2013 \\ Projects \\ WebInterface1 \\ WebInterface1 \\ bin \\ Debug \\ WebInterface1.exe

AssemblyDirectory = C:\\Users\\Brian\\Documents\\Visual Studio 2013\\Projects\\WebInterface1\\WebInterface1\\bin\\Debug\\ AssemblyDirectory = C:\\ Users \\ Brian \\ Documents \\ Visual Studio 2013 \\ Projects \\ WebInterface1 \\ WebInterface1 \\ bin \\ Debug \\

Application Config File = C:\\Users\\Brian\\Documents\\Visual Studio 2013\\Projects\\WebInterface1\\WebInterface1\\bin\\Debug\\WebInterface1.exe.Config 应用程序配置文件= C:\\ Users \\ Brian \\ Documents \\ Visual Studio 2013 \\ Projects \\ WebInterface1 \\ WebInterface1 \\ bin \\ Debug \\ WebInterface1.exe.Config


INFO: Parsing Application Config File C:\\Users\\Brian\\Documents\\Visual Studio 2013\\Projects\\WebInterface1\\WebInterface1\\bin\\Debug\\WebInterface1.exe.Config. 信息:解析应用程序配置文件C:\\ Users \\ Brian \\ Documents \\ Visual Studio 2013 \\ Projects \\ WebInterface1 \\ WebInterface1 \\ bin \\ Debug \\ WebInterface1.exe.Config。

ERROR: Activation Context generation failed. 错误:激活上下文生成失败。

End Activation Context Generation. 结束激活上下文生成。

With little information to go on, I suspected the problem may be Interop related so I proceeded with a few experiments, none of which resolved the problem. 由于缺乏足够的信息,我怀疑问题可能与Interop有关,因此我进行了一些实验,但都没有一个解决问题。

The application interoperates with Excel, originally, Excel 2003 from Office 2003 Professional . 该应用程序可与Excel(最初是Office 2003 Professional Excel 2003互操作。 Since Office 2003 Professional is obsolete, I upgraded to Office 2013 Home and Student and converted the Excel file that my application needs to interoperate with. 由于Office 2003 Professional已过时,因此我升级到Office 2013 Home and Student并转换了应用程序需要与之互操作的Excel文件。 The upgrade did not make a noticeable difference when my application is run; 运行我的应用程序时,升级没有显着差异。 the side-by-side failure persists. 并排故障仍然存在。

The Interop DLL was Microsoft.Office.Interop.Excel.dll (carried over like "source code" from the VS 2010 project, and before that, a VS 2008 project, so I don't know about its pedigree) but in order to try any random thing to fix the side-by-side problem, I attempted to use a different reference to re-build. Interop DLL是Microsoft.Office.Interop.Excel.dll (类似于VS 2010项目中的“源代码”,在此之前是VS 2008项目,因此我不知道其谱系),但为了尝试使用任何随机方法来解决并行问题,我尝试使用其他引用来重新构建。 Under the Add Reference > Assemblies > Framework , there is no reference that appears to be Excel Interop-related. 在“ Add Reference > Assemblies > Framework ,没有似乎与Excel Interop相关的引用。 Likewise there is none under Add Reference > Assemblies > Extensions . 同样,“ Add Reference > Assemblies > Extensions下也没有任何内容。 I mention this because in this other Q and A (link) , you can see that in VS 2012 and VS 2010, it seems that it should be possible to resolve references by finding Microsoft.Office.Interop.Excel in the reference manager, but unfortunately, not in my installation of VS 2013. 我之所以这么说是因为在其他Q和A (链接)中 ,您可以看到在VS 2012和VS 2010中,似乎应该可以通过在引用管理器中找到Microsoft.Office.Interop.Excel来解析引用,但是不幸的是,不在我的VS 2013安装中。

Under Add Reference > COM , there is a reference called Microsoft Excel 15.0 Object Library (Version 1.8) . 在“ Add Reference > COM ,有一个称为Microsoft Excel 15.0 Object Library (Version 1.8)的引用。 This allows the project to build but the side-by-side failure persists. 这样可以构建项目,但并排故障仍然存在。 This MSDN page seems to indicate that this is the right way to resolve the reference when using VS 2013, so I don't have to worry about the pedigree of the DLL that has been carried over several years. 这个MSDN页面似乎表明这是使用VS 2013时解析引用的正确方法,因此我不必担心DLL的血统已经有几年了。

What else should I try to resolve the side-by-side failure? 我还应该尝试什么解决并排故障?

Update I removed all VS Redistributables that support C++. 更新我删除了所有支持C ++的VS Redistributable。 As already mentioned, I am using C#. 如前所述,我正在使用C#。 I removed and re-installed VS 2013. I removed Office 2003. The side-by-side configuration is incorrect failure persists. 我删除并重新安装了VS2013。删除了Office2003。 side-by-side configuration is incorrect故障仍然存在。

This answer eliminates the side-by-side error message at the time the application is activated but I do not know enough about the issue to be able to say if it is close to being a good answer. 这个答案消除了在激活应用程序时出现的并行错误消息,但是我对该问题的了解不足,无法说出它是否接近一个好的答案。

This answer assumes that Excel Interop is provided by Visual Studio 2013's Add Reference > COM , where there is a reference called Microsoft Excel 15.0 Object Library (Version 1.8) . 此答案假定Excel Interop由Visual Studio 2013的“ Add Reference > COM ,其中有一个称为Microsoft Excel 15.0 Object Library (Version 1.8)的引用。

For the Application's .EXE, create a Visual Studio App.config and include within it the following element. 对于应用程序的.EXE,创建一个Visual Studio App.config并在其中包含以下元素。

<startup useLegacyV2RuntimeActivationPolicy="true"> 
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>

Do the same for every .DLL dependency in your solution. 对解决方案中的每个.DLL依赖项都执行相同的操作。 If a library is being built, VS 2013 does not create the App.config by default, but it is easily generated by right clicking the project in the solution browser. 如果正在构建库,则VS 2013默认情况下不会创建App.config ,但是可以通过在解决方案浏览器中右键单击该项目来轻松生成它。

By setting the useLegacyV2RuntimeActivationPolicy attribute to true , the message side-by-side configuration is incorrect , and the dialog that bears it at the time of activation, ceases to appear. 通过将useLegacyV2RuntimeActivationPolicy属性设置为true ,消息side-by-side configuration is incorrect ,并且在激活时带有该消息的对话框将不再出现。

When it is true the following quote applies. 如果是true则以下引用适用。

Enable .NET Framework 2.0 runtime activation policy for the chosen runtime, which is to bind legacy runtime activation techniques (such as the CorBindToRuntimeEx function) to the runtime chosen from the configuration file instead of capping them at CLR version 2.0. 为选定的运行时启用.NET Framework 2.0运行时激活策略,该策略是将旧版运行时激活技术(例如CorBindToRuntimeEx函数)绑定到从配置文件中选择的运行时,而不是将它们限制在CLR版本2.0中。 Thus, if CLR version 4 or later is chosen from the configuration file, mixed-mode assemblies created with earlier versions of the .NET Framework are loaded with the chosen CLR version. 因此,如果从配置文件中选择了CLR版本4或更高版本,则使用所选的CLR版本加载使用.NET Framework早期版本创建的混合模式程序集。 Setting this value prevents CLR version 1.1 or CLR version 2.0 from loading into the same process, effectively disabling the in-process side-by-side feature. 设置此值可防止CLR 1.1版或CLR 2.0版加载到同一进程中,从而有效地禁用进程内并行功能。

When it is false , the following quote applies. 如果为false ,则使用以下引号。

Use the default activation policy for the .NET Framework 4 and later, which is to allow legacy runtime activation techniques to load CLR version 1.1 or 2.0 into the process. 对.NET Framework 4和更高版本使用默认的激活策略,该策略是允许旧版运行时激活技术将CLR 1.1或2.0版本加载到该过程中。 Setting this value prevents mixed-mode assemblies from loading into the .NET Framework 4 or later unless they were built with the .NET Framework 4 or later. 设置此值可防止将混合模式程序集加载到.NET Framework 4或更高版本中,除非它们是使用.NET Framework 4或更高版本构建的。 This value is the default. 此值为默认值。

The value of v4.0 and the sku value were simply the defaults by Visual Studio 2013 (on a system with .NET Framework 4.5.1 installed) when a WPF application was generated so the actual values might vary depending upon which version of the IDE you are using. v4.0的值和sku值只是生成WPF应用程序时Visual Studio 2013(在安装了.NET Framework 4.5.1的系统上)的默认值,因此实际值可能会随IDE的版本而有所不同您正在使用。 The example values of v4.0 and the sku value might need to be adjusted for the particular circumstances. v4.0的示例值和sku值可能需要针对特定​​情况进行调整。

Links: 链接:

The MSDN description of the startup element 启动元素的MSDN描述

The MSDN description of the side-by-side-for-COM-Interop-technology that is being disabled in this solution 在此解决方案中被禁用的COM-Interop-by-side-side-by-side-side

I had this same error, and it turned out I had an entry in my app config file that caused it: 我也遇到了同样的错误,结果是我的应用程序配置文件中有一个条目导致该错误:

<add key="EmailNotificationList" value="this&that@doamin.com;theotherthing@domain.com"/>

...which I had to change to: ...我必须更改为:

    <add key="EmailNotificationList" value="this&amp;that@doamin.com;theotherthing@domain.com"/>

Hope this helps someone. 希望这对某人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 应用程序无法启动,因为其并行配置不正确 - Application failed to start because its side-by-side configuration is incorrect 并排显示数据表列 C# 控制台应用程序 - Displaying DataTable Columns Side-By-Side C# Console Application .NET4:进程内并行执行说明 - .NET4: In-Process Side-by-Side Execution Explained COM互操作并排组件 - COM interop side-by-side assemblies 并排显示表单所有者表单 - Show Form side-by-side owner Form 免费注册COM互操作:由于并排配置不正确,因此应用程序无法启动 - Registration Free COM Interop: The application has failed to start because its side-by-side configuration is incorrect 应用程序无法启动,因为它的并行配置不正确 - The application has failed to start because its side-by-side configuration is incorrect 该应用程序无法启动,因为其并行配置不正确 - The application has failed to start because its side-by-side configuration is incorrect C#Dll导入失败:“应用程序无法启动,因为它的并行配置不正确” - C# Dll Import failure: “The application has failed to start because its side-by-side configuration is incorrect” 我可以并排部署两个ASP.NET(MVC和WebApi)应用程序吗? - Can I deploy two ASP.NET (MVC and WebApi) applications side-by-side?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM