开发者

Cannot find MS.Internal.Media namespace in assembly

I've been working on a WPF application. Since I design the UI in Expression Blend 4 and work on the code-behind part in Visual Studio 2010, I constantly switch from one tool to another.

I added some Image controls to an existing Grid and assigned some images to them. In Blend, I built the project and ran it. Worked just fine. When I switched to Visual Studio, I am getting this error:

Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'MS.Internal.Media' that is not included in the assembly. C:\Users\Dennis\Documents\Visual Studio 2010\Projects\solutionName\projectName\MainWindow.xaml

The designer cannot be loaded with this error pending. However, the project is working in Blend and I can see it just fine there.

The declarations are the following (in the Window):

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008开发者_运维百科" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:MS_Internal_Media="clr-namespace:MS.Internal.Media;assembly=PresentationCore" mc:Ignorable="d" x:Class="projectName.MainWindow"
        Height="272" Width="359" Loaded="Window_Loaded" WindowStyle="ThreeDBorderWindow" ResizeMode="NoResize" Icon="/projectName;component/Images/main.ico"
        Title="Sample Project">

What could be causing this error?


It seems that this is a known issue (perhaps bug is too strong a word, if it is a setting or something that I am missing too then happy to stand corrected on this one, anyway....) in Visual Studio - its still happening in VS2010 too.

If you remove the string "clr-namespace:" in the XAML, just leaving you with

xmlns:MS_Internal_Media="MS.Internal.Media;assembly=PresentationCore"

it will compile fine and you can reload the designer. If you then added the clr-namespace syntax in again it will build ok but the designer will still error. I believe this must be an issue in Visual Studio itself.

Hope this workaround at least helps you to load the designer and get the project built.

Having played around with this a little more I think the problem is probably the fact that that assembly has no public types. Looking at the assembly in .Net Reflector they are all internal classes. The same error that you are getting in VS is thrown for all assemblies where thare are no public types. I expect that Blends interface is either not checking for this or is handling it better.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜