FileNotFoundException in XAML designer (Visual Studio 2012/2013)

Jan 14, 2014 at 3:14 PM
When adding an OxyPlot component to a WPF form, I'm observing a System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version= [...] in the XAML designer. I've confirmed this issues exists on my system in both Visual Studio 2012 and Visual Studio 2013, using projects configured for both .NET 4.0 and .NET 4.5.

Here is my implementation of OxyPlot in XAML:

<oxy:Plot x:Name="Plot"></oxy:Plot>

I've seen other posts reporting similar issues with OxyPlot, with the common recommendation being to repair Visual Studio. Unfortunately, repairing Visual Studio or the .NET Framework has not resolved the issue for me.

Interesting (although perhaps not indicative of a problem): I'm observing details in the stack trace that indicate a file system structure that does not exist on my system: at OxyPlot.Wpf.Plot.UpdateModel(Boolean updateData) in c:\TeamCity\buildAgent\work\f48330714bade418\Source\OxyPlot.Wpf\Plot.cs:line 1362. Perhaps this might be related?

The OxyPlot component does work properly at runtime, as shown with this example:

Here's the full exception from the XAML designer:
Could not load file or assembly 'System.Core, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified.
   at OxyPlot.PlotModel.Update(Boolean updateData)
   at OxyPlot.Wpf.Plot.UpdateModel(Boolean updateData) in c:\TeamCity\buildAgent\work\f48330714bade418\Source\OxyPlot.Wpf\Plot.cs:line 1362
   at OxyPlot.Wpf.Plot.UpdateModelAndVisuals(Boolean updateData) in c:\TeamCity\buildAgent\work\f48330714bade418\Source\OxyPlot.Wpf\Plot.cs:line 1375
   at OxyPlot.Wpf.Plot.ArrangeOverride(Size arrangeBounds) in c:\TeamCity\buildAgent\work\f48330714bade418\Source\OxyPlot.Wpf\Plot.cs:line 671
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.UIElement.UpdateLayout()
   at System.Windows.Interop.HwndSource.SetLayoutSize()
   at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
   at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
   at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteUIElement.<>c__DisplayClass10.<Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteUIElement.CreateContent>b__f()
   at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.<>c__DisplayClass2a`1.<MarshalIn>b__29()
   at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.Call.InvokeWorker()
   at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.Call.Invoke(Boolean waitingInExternalCall)
   at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.InvokeCall(Call call)
   at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.ProcessQueue(CallQueue queue)
   at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.ProcessInboundAsyncQueue(Int32 identity)
   at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.ProcessMessage(Int32 msg, IntPtr wParam, IntPtr lParam, Boolean elevatedQuery, Boolean& handled)
   at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.OnWindowMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at Microsoft.Expression.DesignHost.Isolation.Remoting.MessageOnlyHwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at Microsoft.Expression.DesignHost.Isolation.DesignerProcess.RunApplication()
   at Microsoft.Expression.DesignHost.Isolation.DesignerProcess.<>c__DisplayClass2.<Main>b__0()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
Thanks for any help, and please let me know if I can provide additional information.
Jan 14, 2014 at 3:26 PM
I should add that I'm using OxyPlot.Wpf from NuGet, version 2014.1.1.1.
Jan 14, 2014 at 4:47 PM
Edited Jan 14, 2014 at 4:51 PM
After much trial-and-error, I found one procedure that does not crash the XAML designer, although it doesn't give me much insight into a true solution.

Prerequisite: In my project, I'm observing a System.IO.FileNotFoundException as stated earlier.
  1. Remove all OxyPlot references from the project
  2. Add only the OxyPlot.Wpf reference to the project by referencing the compiled DLL
  3. Download the OxyPlot source code, then in the existing solution, add and "Existing Project" oxyplot/Source/OxyPlot/OxyPlot.csproj
  4. In the project with the FileNotFound exception, add a new reference, and select SolutionProjects, then select the OxyPlot project from the list.
The System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version= [...] error is no longer displayed.

Obviously this isn't an ideal solution as it requires a reference to the OxyPlot source code to be included with my solution. However, I'm hoping this may be meaningful to others when considering this issue.
Jan 14, 2014 at 7:01 PM
The OxyPlot core is currently a portable class library compiled with TargetFrameworkProfile=Profile136 (which also targets Xamarin.Android and Xamarin.iOS).
I can reproduce the XAML designer error in VS 2012 Upgrade 4, but not in VS 2013. Could it be that Profile136 is not properly supported in the VS 2012 designer?
Jan 17, 2014 at 5:57 PM
I am also encountering a similar issue. I've just installed VS2013 Ultimate and upgraded all projects to this with .NET 4.5.1 runtime specified. When I create a simple standalone project things work fine, but when interacting with my existing projects I get the errors.

I've tried both adding this into an existing project, and as a separate project in my solution. In both cases I get the error raised at the XAML line: <oxy:Plot Model="{Binding ViewModel.MainPlotModel}"/>.

My VS info is:
Microsoft Visual Studio Ultimate 2013
Version 12.0.21005.1 REL
Microsoft .NET Framework
Version 4.5.50938
Installed Version: Ultimate

Here are the exception details:
System.Windows.Markup.XamlParseException occurred
  Message=Could not load file or assembly 'OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0' or one of its dependencies. The system cannot find the file specified.
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at MemoryPlotControl.MemoryPlotView.InitializeComponent() in s:\SWDEV\Timelines\Timelines_v3.0_Fourier_sandbox\Source\MemoryPlotControl\MemoryPlotView.xaml:line 1
       at MemoryPlotControl.MemoryPlotView..ctor(TopViewModel topVM) in s:\SWDEV\Timelines\Timelines_v3.0_Fourier_sandbox\Source\MemoryPlotControl\MemoryPlotView.xaml.cs:line 28
  InnerException: System.IO.FileNotFoundException
       Message=Could not load file or assembly 'OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0' or one of its dependencies. The system cannot find the file specified.
       FileName=OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0
       FusionLog==== Pre-bind state information ===
LOG: DisplayName = OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0 | 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 for more information and common solutions to this issue.
LOG: Appbase = file:///S:/SWDEV/Timelines/Timelines_v3.0_Fourier_sandbox/Source/TimeLinesShell/bin/x86/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : PresentationFramework, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
Jan 17, 2014 at 6:16 PM
I tried this approach but it did not work for me. Must be since my error is not quite the same as yours.
  • VS2013
  • directly referenced the nuget OxyPlot.Wpf 2014.1.1.1
  • added the Source/OxyPlot/OxyPlot.csproj
Jan 27, 2014 at 6:37 PM
If you build the OxyPlot core yourself, I think you should also build the OxyPlot.Wpf assembly.
Can you reproduce the error in any of the included examples?
Mar 3, 2014 at 9:21 AM

I have exactly the same problem with VS2012 Update 4 (Win 8.1 64Bit French). Problem in designer, but you can compile and runs your app.
Same error FileNotFoundException: Could not load file or assembly 'System.Core, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. Le fichier spécifié est introuvable. (-> This specified file can not be found)

StackTrace (seems to be a bit different at the end)
at OxyPlot.PlotModel.Update(Boolean updateData)
at OxyPlot.Wpf.Plot.UpdateModel(Boolean updateData)
at OxyPlot.Wpf.Plot.InvalidatePlot(Boolean updateData)
at OxyPlot.Wpf.Plot.PlotLoaded(Object sender, RoutedEventArgs e)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
at MS.Internal.LoadedOrUnloadedOperation.DoWork()
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

InnerException: none
Mar 3, 2014 at 9:44 AM
Thanks for the report, does anyone know why this is happening? I thought the PCL issue was solved in the VS update.

In VS 2013 Update 1 there are no errors in the WPF designer view.

Also see a similar thread:
(search for "Visual Studio", "designer", "pcl" in the discussions and issues)
Mar 3, 2014 at 10:37 AM
The solution provided by evan_w, on 14th feb. is working on my machine too.
Mar 3, 2014 at 11:59 AM
VS 2012 Update 4 is crap, the bug was reintroduced.
Stay with Update 3 or use VS2013.
Mar 5, 2014 at 1:05 PM
I can confirm that for VS2013 installing Silverlight SDK fixed the issue (as VadimCh kindly pointed out here: ).
I had VS2013 update 1, but that was not enough.
Apr 1, 2014 at 5:19 PM
Problem solved by installing Silverlight 5 SDK. Thanks!
Apr 15, 2014 at 4:36 PM
Having the same problems in VS 2012 Update 4 and using Oxyplot.Wpf.dll (not Silverlight!). Installing the Silverlight 5 SDK also fixed things for me.
Aug 26, 2014 at 9:44 PM
Edited Aug 26, 2014 at 9:44 PM
I had same problem...

It can be solved adding the OxyPlot and OxyPlot.Wpf references to all my projects in the same solution.
Jan 26, 2015 at 3:10 PM
Installing Silverlight 5 SDK worked for me too! Love you guys- been having the same issue with Catel!