11

In my WPF application, I get the following exception on startup:

A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

Additional information: Could not load file or assembly 
'PresentationUI.Aero2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 
or one of its dependencies. 

EDIT: Using fusion log, I get a little more valuable info than the call stack:

LOG: DisplayName = PresentationUI.Aero2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///[...]/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = EngideskLauncher.vshost.exe
Calling assembly : PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: [...]\bin\Debug\EngideskLauncher.vshost.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: PresentationUI.Aero2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///[...]/bin/Debug/PresentationUI.Aero2.DLL.
LOG: Attempting download of new URL file:///file:///[...]/bin/Debug/PresentationUI.Aero2/PresentationUI.Aero2.DLL.
LOG: Attempting download of new URL file:///file:///[...]/bin/Debug/PresentationUI.Aero2.EXE.
LOG: Attempting download of new URL file:///file:///[...]/bin/Debug/PresentationUI.Aero2/PresentationUI.Aero2.EXE.
LOG: All probing URLs attempted and failed.

What I find strange, is that the calling assembly is PresentationFramework, which is a .NET framework assembly, obviously. A .NET Framework assembly wouldn't call an assembly which is not a .NET framework assembly. Anyway, I can't find a PresentationUI.Aero2.DLL anywhere and not even Google seems to know anything about it??

Any ideas?

Additional information:

  • .NET Framework 4.0
  • Windows 8.1
Marc
  • 12,706
  • 7
  • 61
  • 97
  • Enable fusion log or use ProcMon to find out what file it is trying to load. See [How to debug “Could not load file or assembly” runtime errors?](http://stackoverflow.com/questions/4602912/how-to-debug-could-not-load-file-or-assembly-runtime-errors). – CodeCaster Nov 04 '14 at 11:18
  • Hi CodeCaster, thanks for the hint. I would be glad, if you could give me short feedback to the output. Do you have any ideas? – Marc Nov 04 '14 at 11:40
  • Hi Hans, the folder you mention contains `PresentationFramework.Aero2.DLL` but not `PresentationUI.Aero2.DLL`. What do you mean with "how you got 4.0 on that machine is entirely unguessable"? I cant remember using any sort of sledge hammer ;) Thank you for your help! – Marc Nov 04 '14 at 12:34
  • My WPF project (.NET 4.0, Win8.1) is throwing exactly the same exception for any view containing a FlowDocument, but _only_ when I run with the debugger in Visual Studio. If I launch the executable from the `bin` folder, no exception. A separate project I created as a standalone works when run as a standalone project in its own solution, but fails if I add it to my existing solution, so I suspect there's something wrong with my solution. – pmcoltrane Nov 25 '14 at 15:18
  • Hi pmcoltrane, in my case the bug disappeared by itself and I could not tell, what I changed. I worked in the project which threw the exception and rebuilt it. No idea... That's what you call a Heisen-Bug, I guess. If find out anything, I would be glad if you let me know! – Marc Nov 26 '14 at 08:04
  • 1
    This answer fixed my similar problem: http://stackoverflow.com/questions/17335712/why-cant-windows-7-load-the-assembly-presentationframework-aero2 – sergeantKK Dec 16 '14 at 11:18
  • You're probably using a FlowDocument or a FlowDocumentScrollViewer or something. – Kirill Osenkov May 28 '16 at 22:49

2 Answers2

18

If you're interested, this is a (benign) bug in WPF. The exception is first-chance and can be ignored.

WPF forgot to add Aero2.NormalColor.xaml to PresentationUI.dll. If you inspect PresentationUI.dll with your favorite reflector/decompiler, you'll find all sorts of themes, such as Aero.NormalColor.baml, etc. but no Aero2.NormalColor.xaml. This causes WPF to try and see if an external assembly exists:

This tries to load Aero2.NormalColor.baml from PresentationUI.dll and returns null: http://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/SystemResources.cs,773

This then goes to try an external assembly: http://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/SystemResources.cs,554

And this throws the actual exception: http://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/SystemResources.cs,706

This exception is commonly observed when using a FlowDocument or a FlowDocumentScrollViewer.

Kirill Osenkov
  • 8,786
  • 2
  • 33
  • 37
2

I was getting the same error and finally realized that it was simply stopping in the IDE because I had first chance exceptions turned on, the exception doesn't actually matter and you can ignore or continue past it.

BrandonAGr
  • 5,827
  • 5
  • 47
  • 72
  • So, this doesn't answer the question as to why the exception is being thrown. Do you have any idea why it is being thrown if we can just ignore it? – Zack Jan 04 '16 at 17:27