当我们使用构建配置时,为什么 Expression Blend 4 的设计器不工作? [英] Why isn't Expression Blend 4's designer working whenever we use build configurations?

查看:11
本文介绍了当我们使用构建配置时,为什么 Expression Blend 4 的设计器不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Expression Blend 4 时遇到了一个奇怪的问题.我将 Blend 4 与 Visual Studio 2010 结合使用已经有一段时间了,没有发生任何事故(除了非常频繁的崩溃).现在我们的图形设计师想要开始使用 Blend 做一些修饰工作.

I'm having an odd issue with Expression Blend 4. I've been using Blend 4 in conjunction with Visual Studio 2010 for quite a while without incident (beyond the ultra-frequent crashes). Now our graphics designer wants to start using Blend to do some touch-up work.

我们能够让 Blend 在他的计算机上编译解决方案.不幸的是,当我们尝试打开任何 XAML 文件时,我们会收到来自设计器的错误,其中包含通过合并资源字典和附加属性的资源无法识别.基本上,即使 Blend 正在编译没有错误的解决方案,也好像没有看到构建工件.

We were able to get Blend to compile the solution on his computer. Unfortunately, when we try to open any XAML file, we get errors from the designer where resources included through the merged resource dictionary and attached properties are not recognized. Basically, it's as though the build artifacts aren't seen even though Blend is compiling the solution with no errors.

我们设置中唯一奇怪的是我们的解决方案包含多个构建配置,并且您无法在 Blend 中更改构建配置.

The only oddity in our setup is that our solution contains multiple build configurations, and you cannot change your build configuration in Blend.

您认为 Blend 的设计器为什么无法加载它构建的文件?

Why do you suppose Blend's designer is failing to load the files that it built?

推荐答案

在弄清楚 Blend 4 如何构建 Visual Studio 项目/解决方案时,我发现了为什么我们的图形设计师的 Blend 副本无法正常工作并解决了问题.我们设置的多个构建配置是罪魁祸首.以下是我发现的细节以及对使用多个构建配置、Blend 4 和 Visual Studio 2010 的其他人的警告列表.

In figuring out how Blend 4 builds Visual Studio projects/solutions, I found out why our graphics designer's copy of Blend was not working properly and fixed the problem. The multiple build configurations that we had set up were to blame. Here's the specifics of what I found out and a list of warnings to anyone else using multiple build configurations, Blend 4, and Visual Studio 2010.

警告 1:Blend 不允许您选择构建配置.

在 Visual Studio 中,当您构建时,您始终使用特定的构建配置进行构建.可以更改此设置.Blend 似乎无法在其 UI 的任何位置更改构建配置设置.相反,它使用自己的启发式方法来选择要使用的构建配置.

In Visual Studio, when you build, you are always building with a specific build configuration. This setting can be changed. Blend doesn't appear to have the ability to change the build configuration setting anywhere in its UI. Instead, it uses its own heuristics for selecting which build configuration to use.

警告 2:Blend 在构建和设计时使用不同的逻辑来选择构建配置.

这就是给我们带来问题的原因.Blend 似乎有两种不同的方式来选择构建配置.编译时,它使用 .csproj 文件中的逻辑来选择默认构建配置(请参阅警告 3).但是,设计器会查看解决方案文件,它应该使用哪个构建配置的输出目录来解析程序集引用(请参阅警告 4).因此,尽管 Blend 编译正常,但设计者并未查看已编译的文件,而是查看它创建的空 bin 目录.

This is what was causing issues for us. It seems that Blend has two different ways to choose a build configuration. When you compile, it uses the logic in the .csproj files for selecting a default build configuration (see warning 3). The designer, however, looks to the solution file for which build configuration's output directory it should use to resolve assembly references (see warning 4). So although Blend was compiling alright, the designer was not looking at the compiled files but at an empty bin directory it created.

警告 3:Blend 和 Visual Studio 处理默认构建配置的方式不同.

在 .csproj 文件的顶部,有一个属性组,用于指定在运行 csc.exe 时未指定要使用的构建配置.Visual Studio 似乎没有修改这些数据,可能是因为它不需要它,因为它总是使用定义的构建配置.我们已经删除了默认的 Debug 和 Release 配置,并制作了我们自己的 DebugWindows、ReleaseWindows、DebugMac 和 ReleaseMac 配置,但是当没有指定配置时,项目文件仍然说使用调试".Blend 4 在没有构建配置的情况下运行 csc.exe,因此使用默认逻辑.因此,我不得不手动修复 .csproj 文件.

At the top of .csproj files, there's a property group that specifies which build configuration to use when one is not specified when running csc.exe. Visual Studio does not seem to modify this data, probably because it doesn't need it given that it always uses a defined build configuration. We had removed the default Debug and Release configurations and made our own DebugWindows, ReleaseWindows, DebugMac, and ReleaseMac configurations, but the project files still said to use "Debug" when no configuration is specified. Blend 4 runs csc.exe with no build configuration, so the defaulting logic is used. Therefore, I had to manually fix up the .csproj files.

警告 4:Visual Studio 不允许您对解决方案的构建配置进行排序,并且该排序与 Blend 相关.

与 Blend 在编译时选择构建配置的方式相反,Blend 的设计者似乎使用解决方案文件中的第一个解决方案配置来将项目与构建配置相关联.然后,设计器在输出目录中查找 其程序集的配置.换句话说,如果 .csproj 构建配置默认值和 first-solution-configuration 的设置不匹配,即使您构建了项目,设计器也不会看到您的类、合并的资源字典等.

Contrary to how Blend selects build configurations when compiling, Blend's designer seems to use the first solution configuration in a solution file to associate projects with a build configuration. The designer then looks to the output directory for that configuration for its assemblies. In other words, if there's a mismatch between the .csproj build configuration defaults and the first-solution-configuration's settings, the designer will not see your classes, merged resource dictionaries, etc, even if you built the project.

首先无法通过 Visual Studio 更改哪个解决方案配置.为了修复设计人员查找构建工件的位置,我们必须在 .sln 文件中手动重新排序解决方案配置.

Whichever solution configuration is first cannot be changed through Visual Studio. For us to fix where the designer looked for build artifacts, we had to reorder the solution configurations manually in the .sln file.

这篇关于当我们使用构建配置时,为什么 Expression Blend 4 的设计器不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆