简体   繁体   中英

Visual Studio 2010 project to Visual Studio 2012

My friend just sent me a VS2010 project with 2 solutions in it: one with one CPP file and the other solution with a C# WPF project (one XAML and one CS). Everything is working fine on his computer with VS2010. When he builds and executes the project, the main XAML window shows up as supposed.

When I try to do the same with VS2012 on my computer, I have no problem building the project. However, when I run it, nothing happens. I added some breakpoints into the C# code and I realized that the code runs, but the window never shows up. So, as soon as the code has been executed, the app just quits instead of waiting for user input within the XAML interface.

I never faced up this problem before, usually going from VS2010 to VS2012 works pretty well. And here again, everything seems to work... except for the XAML window now showing when running the project, which is quite annoying.

Has anyone any idea of what's going on there? I am probably missing something really fundmental here, but I don't see any setting in the solution's or project's properties that could actually help me to ensure the XAML window runs when I start the project.

One thing to note is that the 4.5 compiler has changed the semantics of lambdas in foreach loops, so your application may have tripped over this. See here: https://connect.microsoft.com/VisualStudio/feedback/details/732657/c-5-compiler-doesnt-respect-the-semantics-of-the-foreach-range-variable-when-langversion-5

basically if you had something like this:

List<Action<int>> actions = new List<Action<int>>();
foreach (var x in new[] { 10, 20, 30 })
{
   actions.Add(() => Console.WriteLine("x = {0}", x);
}

actions.ForEach(a => a());

would give a different result depending on whether it was compiled with 4.0 or 4.5. We kinda tripped over this because our build machine was still 4.0 and we upgraded our development machines to VS 2012.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM