2011-11-17 16 views
10

Mi proyecto WPF usa el perfil de cliente .NET 4. Cuando agregoAl usar PresentationFramework.Aero, ¿debo configurar "Copiar local" en verdadero (e incluirlo en mi proyecto de configuración)?

<ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml" /> 

a <Application.Resources> consigo esta excepción al iniciar el programa en modo de depuración (en modo de lanzamiento del programa se bloquea en silencio):

Una primera excepción del tipo ' System.Windows .Markup.XamlParseException' producido en PresentationFramework.dll

información adicional: 'Establecer la propiedad 'System.Windows.ResourceDictionary.Source' produjo una excepción'. Línea número '14' y posición de línea '14'.

Cuando establezco la propiedad "Copiar local" de PresentationFramework.Aero en verdadero, todo funciona y la excepción se ha ido.

"Copiar local" coloca una copia de PresentationFramework.Aero en mi directorio de salida y, por lo tanto, debo incluirlo en mi proyecto de instalación. ¿Por qué es eso necesario? Según MSDN PresentationFramework.aero se incluye en el perfil de cliente de .NET Framework 4.0 y, por lo tanto, en el GAC. No me siento cómodo al implementar un archivo de framework con mi aplicación.

uDate:

Como Hans Passant sugirió verifiqué que el directorio PresentationFramework.Aero existe en C:\windows\microsoft.net\assembly\gac_msil. Luego usé fuslogvw.exe para generar el siguiente registro, creado al iniciar mi aplicación "SetACL Studio.exe" sin PresentationFramework.Aero.dll presente en el directorio de la aplicación. Curiosamente, el cargador ni siquiera verifica el GAC. ¿Por qué?

*** Assembly Binder Log Entry (18.11.2011 @ 17:13:27) *** 

The operation failed. 
Bind result: hr = 0x80070002. The system cannot find the file specified. 

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll 
Running under executable D:\Daten\Helge\Programmierung\SetACL Studio\Source\Bin\Debug\SetACL Studio.exe 
--- A detailed error log follows. 

=== Pre-bind state information === 
LOG: User = HKT520\Helge 
LOG: DisplayName = PresentationFramework.Aero, Culture=neutral 
(Partial) 
WRN: Partial binding information was supplied for an assembly: 
WRN: Assembly Name: PresentationFramework.Aero, Culture=neutral | Domain ID: 1 
WRN: A partial bind occurs when only part of the assembly display name is provided. 
WRN: This might result in the binder loading an incorrect assembly. 
WRN: It is recommended to provide a fully specified textual identity for the assembly, 
WRN: that consists of the simple name, version, culture, and public key token. 
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. 
LOG: Appbase = file:///D:/Daten/Helge/Programmierung/SetACL Studio/Source/Bin/Debug/ 
LOG: Initial PrivatePath = NULL 
LOG: Dynamic Base = NULL 
LOG: Cache Base = NULL 
LOG: AppName = SetACL Studio.exe 
Calling assembly : PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35. 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: D:\Daten\Helge\Programmierung\SetACL Studio\Source\Bin\Debug\SetACL Studio.exe.Config 
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. 
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). 
LOG: Attempting download of new URL file:///D:/Daten/Helge/Programmierung/SetACL Studio/Source/Bin/Debug/PresentationFramework.Aero.DLL. 
LOG: Attempting download of new URL file:///D:/Daten/Helge/Programmierung/SetACL Studio/Source/Bin/Debug/PresentationFramework.Aero/PresentationFramework.Aero.DLL. 
LOG: Attempting download of new URL file:///D:/Daten/Helge/Programmierung/SetACL Studio/Source/Bin/Debug/PresentationFramework.Aero.EXE. 
LOG: Attempting download of new URL file:///D:/Daten/Helge/Programmierung/SetACL Studio/Source/Bin/Debug/PresentationFramework.Aero/PresentationFramework.Aero.EXE. 
LOG: All probing URLs attempted and failed. 

Actualización 2:

Ésta es la salida de gacutil:

C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin>gacutil.exe /l presentationframework.aero 
Microsoft (R) .NET Global Assembly Cache Utility. Version 3.5.30729.1 
Copyright (c) Microsoft Corporation. All rights reserved. 

The Global Assembly Cache contains the following assemblies: 
    presentationframework.aero, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL 

Number of items = 1 
+1

Compruebe el GAC. Navegue a c: \ windows \ microsoft.net \ assembly \ gac_msil y verifique que el directorio PresentationFramework.Aero esté allí. Fuslogvw.exe para obtener más ayuda para solucionar problemas. –

+0

@HansPassant: Gracias, verifiqué que el directorio existe, contiene y contiene la DLL. Agregué un registro fuslogvw a mi pregunta. –

+0

@HansPassant: Su comentario me llevó por el camino hacia la solución. ¡Gracias! –

Respuesta

31

simplemente he encontrado lo siguiente en MSDN:

También se puede hacer una dinámica referencia a un ensamblaje proporcionando la llamada m ethod con solo información parcial sobre el conjunto, como , que especifica solo el nombre del conjunto. En este caso, solo se busca el ensamblaje en el directorio de la aplicación y no se realiza ninguna otra comprobación .

Eso explica el comportamiento que estaba viendo y por qué el GAC no se buscó en PresentationFramework.aero.dll. Cambié la referencia dinámica a una referencia completa y eliminé "Copiar local" de PresentationFramework.aero. Ahora funciona sin necesidad de PresentationFramework.aero.dll en mi directorio de aplicaciones.

Para referencia, aquí es el código de diccionario de recursos de trabajo:

<ResourceDictionary Source="/PresentationFramework.Aero,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Aero.NormalColor.xaml" /> 

En resumen, eliminar la copia local de los temas (en caso de que haya añadido en su solución), agregar la referencia completa en la App archivo .xaml en Application.Resources (Resource Dictionary) y esto debería hacer.

+2

+1 Para vincular la documentación de MSDN y el código de recursos de trabajo. – aolszowka

Cuestiones relacionadas