FileNotFoundException in XAML designer (Visual Studio 2012/2013)

Oystein Bjorke 10 aastat tagasi 0
This discussion was imported from CodePlex

evan_w wrote at 2014-01-14 16:14:

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=2.0.5.0 [...] 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.

Image

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:

Image

Here's the full exception from the XAML designer:
System.IO.FileNotFoundException
Could not load file or assembly 'System.Core, Version=2.0.5.0, 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.

evan_w wrote at 2014-01-14 16:26:

I should add that I'm using OxyPlot.Wpf from NuGet, version 2014.1.1.1.

evan_w wrote at 2014-01-14 17:47:

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=2.0.5.0 [...] 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.

objo wrote at 2014-01-14 20:01:

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?

Eduarte78 wrote at 2014-01-17 18:57:

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
  HResult=-2146233087
  Message=Could not load file or assembly 'OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0' or one of its dependencies. The system cannot find the file specified.
  Source=PresentationFramework
  LineNumber=11
  LinePosition=10
  StackTrace:
       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
       HResult=-2147024894
       Message=Could not load file or assembly 'OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0' or one of its dependencies. The system cannot find the file specified.
       Source=mscorlib
       FileName=OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0
       FusionLog==== Pre-bind state information ===
LOG: DisplayName = OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0
 (Partial)
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 http://go.microsoft.com/fwlink/?LinkId=109270 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=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

Eduarte78 wrote at 2014-01-17 19:16:

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

objo wrote at 2014-01-27 19:37:

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?

Loulou_75016 wrote at 2014-03-03 10:21:

HI,

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=2.0.5.0, 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

objo wrote at 2014-03-03 10:44:

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: https://oxyplot.codeplex.com/discussions/471989
(search for "Visual Studio", "designer", "pcl" in the discussions and issues)

Loulou_75016 wrote at 2014-03-03 11:37:

The solution provided by evan_w, on 14th feb. is working on my machine too.

tibel wrote at 2014-03-03 12:59:

VS 2012 Update 4 is crap, the bug was reintroduced.
Stay with Update 3 or use VS2013.

badbadboy wrote at 2014-03-05 14:05:

I can confirm that for VS2013 installing Silverlight SDK fixed the issue (as VadimCh kindly pointed out here: https://oxyplot.codeplex.com/discussions/471989 ).
I had VS2013 update 1, but that was not enough.

oloopy wrote at 2014-04-01 19:19:

Problem solved by installing Silverlight 5 SDK. Thanks!

gslysz wrote at 2014-04-15 18:36:

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.