Hey Awais,
Thanks for your response. I installed the latest greatest and ran it under the evaluation license. I recompiled the entire solution (40+ projects) as .NET 4 and .NET 4.5 - both got the same error. The salient method is as follows:
protected void GenerateFixedDocumentFromFile(string tempXamlLocation)
{
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
using (FileStream inputStream = File.OpenRead(tempXamlLocation))
{
string absolutePath = Path.GetFullPath(tempXamlLocation);
string directoryPath = Path.GetDirectoryName(absolutePath);
var pc = new ParserContext
{
// It is critical to have the trailing backslash here
// will not work without it!
BaseUri = new Uri(directoryPath + Path.DirectorySeparatorChar)
};
var fixedDocument = (FixedDocument)XamlReader.Load(inputStream, pc);
var docReference = new DocumentReference();
docReference.SetDocument(fixedDocument);
var fixedDocuementSequence = new FixedDocumentSequence();
fixedDocuementSequence.References.Add(docReference);
Document = fixedDocuementSequence;
}
File.Delete(tempXamlLocation);
AltarixMessenger.Send(new object(), Notifications.UnblockUIAction);
AltarixMessenger.Send((PrintableViewModel)this, Notifications.DocumentXamlGenerationComplete);
}), DispatcherPriority.Send, null);
As you can see, we are generating a FixedDocument in Xaml utilizing the document builder. The resulting code gets saved to the file system and then loaded here for rendering. With version 11.8 of your libraries, compiling under .net 3.5 it works fine. When we moved to .net 4 and VS 2012 it started breaking right on the XamlReader.Load statement. Here is the stack trace:
System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=PresentationCore
StackTrace:
at MS.Internal.FontCache.FontFaceLayoutInfo.IntMap.TryGetValue(Int32 key, UInt16& value)
at System.Windows.Media.GlyphTypeface.Initialize(Uri typefaceSource, StyleSimulations styleSimulations)
at System.Windows.Documents.Glyphs.ParseGlyphRunProperties()
at System.Windows.Documents.Glyphs.ComputeMeasurementGlyphRunAndOrigin()
at System.Windows.Documents.Glyphs.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Canvas.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Canvas.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Canvas.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Canvas.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Documents.FixedPage.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Documents.FixedDocument.GetPage(Int32 pageNumber)
at System.Windows.Documents.FixedDocument.OnInitialized(Object sender, EventArgs e)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.InitializationGuard(XamlType xamlType, Object obj, Boolean begin)
at System.Xaml.XamlObjectWriter.Logic_EndInit(ObjectWriterContext ctx)
at System.Xaml.XamlObjectWriter.WriteEndObject()
at System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.XamlReader.Load(XamlReader xamlReader, ParserContext parserContext)
at System.Windows.Markup.XamlReader.Load(XmlReader reader, ParserContext parserContext, XamlParseMode parseMode)
at System.Windows.Markup.XamlReader.Load(Stream stream, ParserContext parserContext)
at Linx2.Client.ViewModel.ViewModels.ReportViewModels.GeneratedDocumentViewModelBase.<>c__DisplayClass2.b__1() in c:\Dev\Arcom\Altarix\trunk\src\Client\Linx2.Client.ViewModel\ViewModels\ReportViewModels\GeneratedDocumentViewModelBase.cs:line 62
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)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
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.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
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)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(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.Application.RunInternal(Window window)
at System.Windows.Application.Run()
at Linx2.Client.Gui.AltarixStartup.Main(String[] args) in c:\Dev\Arcom\Altarix\trunk\src\Client\Linx2.Client.Gui\AltarixStartup.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
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()
InnerException:
As you can see, ultimately it’s MS.Internal.FontCach.FontFaceLayoutInfo… which fails. Could there be something in the dottl files that Aspose creates that isn’t getting set?
Any help you can provide on this would be greatly appreciated. If we can’t fix this issue we either have to go back to 3.5 (which we would rather not do at this point) or use a different library to build the FixedDocument and render the reports. We’re already on a beta release to a limited audience and they all have the 3.5 version that works properly.
Let me know if there is anything else you need to know, and thank you again for your assistance.
Larry Whipple
Arcom