2010-12-08 10 views
34

En VS 2010 se creó un nuevo proyecto WinForm. Se agregó un nuevo UserControl WPF.Error de VisualStudio?

2 errores en tiempo de compilación aparecieron:

Error 1 The type 'System.Windows.Markup.IQueryAmbient' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. D:\Projets\WindowsFormsApplication2\UserControl1.xaml.cs 20 26 WindowsFormsApplication2

Error 2 The type name 'IComponentConnector' could not be found in the namespace 'System.Windows.Markup'. This type has been forwarded to assembly 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Consider adding a reference to that assembly. D:\Projets\WindowsFormsApplication2\obj\x86\Debug\UserControl1.g.cs 41 100 WindowsFormsApplication2

NB.

referencias como PresenationCore.dll, PresenationFramework.dll, se añaden WindowsBase.dll automáticamente al añadir un nuevo WPF control de usuario al proyecto WinForm, ¿por qué no System.Xaml.dll también?

==============

Bug informó sobre Microsoft Connect.

+4

Bueno, como dice, considere agregar una referencia a System.Xaml. – mdm

+0

@mdm ¿Por qué no debería agregar entonces 'PresenationCore.dll',' PresenationFramework.dll', 'WindowsBase.dll' – serhio

Respuesta

54

Parece que sólo tiene una referencia a System.Xaml.dll


Re si esto es un error en VS; bueno, supongo que las plantillas podría añadir que la referencia - puedo reproducirlo, por lo que puede valer la pena logging on connect

+0

Sí, pero ¿por qué esas referencias no se agregan automáticamente con WPF Conrtol, como PresentationCore, por ej. – serhio

+0

@serhio - editaste la pregunta, creo; originalmente había algo notando el guid y preguntándose * cómo arreglarlo *. –

+0

@Marc Edité, pero nunca cambié el título. – serhio

11

Fue este proyecto emigraron de .NET 3.5 a 4.0 NET? Si es así, la interfaz ahora reside en System.Xaml y necesita referenciarla.

+0

has leído la pregunta? "acaba de crear" – serhio

+0

Lo extrañé .. :( –

0

En mi caso "System.Xaml" se añadió al proyecto de forma automática, pero dando el mismo tipo de error:

The type name 'IComponentConnector' could not be found in the namespace 'System.Windows.Markup'. This type has been forwarded to assembly 'System.Xaml, Version=4.0.0.0, Culture=neutral,.... .' Consider adding a reference to that assembly.

He resuelto el problema, simplemente borrando el "System.Xaml" de Referencias y agregando nuevamente desde Marco.

Cuestiones relacionadas