Visual Studio 2010项目到Visual Studio 2012

时间:2023-01-17 11:04:59

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.

我的朋友刚给我发了一个VS2010项目,里面有两个解决方案:一个有一个CPP文件,另一个有一个C#WPF项目(一个XAML和一个CS)。 VS2010在他的电脑上运行正常。当他构建并执行项目时,主XAML窗口显示为所谓的。

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.

当我尝试在我的计算机上使用VS2012时,我没有问题构建项目。但是,当我运行它时,没有任何反应。我在C#代码中添加了一些断点,我意识到代码运行,但窗口永远不会出现。因此,只要代码执行完毕,应用程序就会退出,而不是等待XAML界面中的用户输入。

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.

我之前从未遇到过这个问题,通常从VS2010到VS2012都运行得很好。在这里,一切似乎都有效......除了现在运行项目时显示的XAML窗口,这非常烦人。

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.

有谁知道那里发生了什么?我可能在这里遗漏了一些真正的基础,但我没有看到解决方案或项目属性中的任何设置实际上可以帮助我确保在启动项目时XAML窗口运行。

1 个解决方案

#1


0  

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

需要注意的一点是,4.5编译器已经改变了foreach循环中lambdas的语义,因此你的应用程序可能已经超过了它。请看这里: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.

会给出不同的结果,具体取决于它是用4.0还是4.5编译的。我们有点绊倒了,因为我们的构建机器仍然是4.0,我们将开发机器升级到VS 2012。

#1


0  

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

需要注意的一点是,4.5编译器已经改变了foreach循环中lambdas的语义,因此你的应用程序可能已经超过了它。请看这里: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.

会给出不同的结果,具体取决于它是用4.0还是4.5编译的。我们有点绊倒了,因为我们的构建机器仍然是4.0,我们将开发机器升级到VS 2012。