Domanda

I am porting a C# program from Visual Studio 2010 to Visual Studio 2013. Both are Express versions of the IDE. In the 2013 build I encounter a side-by-side failure.

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. Here is the human readable output from the tool.

Begin Activation Context Generation.

Input Parameter:

Flags = 0

ProcessorArchitecture = AMD64

CultureFallBacks = en-GB;en;en-US

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\

Application Config File = 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.

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.

The application interoperates with Excel, originally, Excel 2003 from Office 2003 Professional. 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. 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. Under the Add Reference > Assemblies > Framework, there is no reference that appears to be Excel Interop-related. Likewise there is none under 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.

Under Add Reference > COM, there is a reference called 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.

What else should I try to resolve the side-by-side failure?

Update I removed all VS Redistributables that support C++. As already mentioned, I am using C#. I removed and re-installed VS 2013. I removed Office 2003. The side-by-side configuration is incorrect failure persists.

È stato utile?

Soluzione 2

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).

For the Application's .EXE, create a Visual Studio App.config and include within it the following element.

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

Do the same for every .DLL dependency in your solution. 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.

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.

When it is true the following quote applies.

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. 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. 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.

When it is false, the following quote applies.

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. 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. 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. The example values of v4.0 and the sku value might need to be adjusted for the particular circumstances.

Links:

The MSDN description of the startup element

The MSDN description of the side-by-side-for-COM-Interop-technology that is being disabled in this solution

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top