Skip to content

Instantly share code, notes, and snippets.

View bgrainger's full-sized avatar

Bradley Grainger bgrainger

View GitHub Profile
@bgrainger
bgrainger / XamlParseException.txt
Created November 23, 2015 18:05
XamlParseException call stack
Message: XamlParseException: Document belongs to another FlowDocumentScrollViewer already. in System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter) ArgumentException: Document belongs to another FlowDocumentScrollViewer already. in System.Windows.Controls.FlowDocumentScrollViewer.DocumentChanged(FlowDocument oldDocument, FlowDocument newDocument)
System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter):540
System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlObjectWriter objectWriter):41
System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(DependencyObject container, IComponentConnector componentConnector, IStyleConnector styleConnector, List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField):271
System.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List`1 affectedChildren):42
System.Windows.StyleHelper.ApplyTemplateContent(UncommonField`1 da
FileNotFoundException: Retrieving the COM class factory for component with CLSID {56FDF344-FD6D-11D0-958A-006097C9A090} failed due to the following error: 8007007e The specified module could not be found. (Exception from HRESULT: 0x8007007E). in System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck):-1
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark):26
System.Activator.CreateInstance(Type type, Boolean nonPublic):54
System.Activator.CreateInstance(Type type):0
System.Windows.Window.ApplyTaskbarItemInfo():97
System.Windows.Window.WindowFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolea
@bgrainger
bgrainger / Benchmark.cs
Created July 22, 2014 20:43
WriteInt64 micro-benchmark
using System;
using System.Diagnostics;
namespace WriteInt64Test
{
class Program
{
static void Main()
{
byte[] buf = new byte[8];
@bgrainger
bgrainger / Squirrel.md
Last active December 27, 2015 07:19
What I had to do to get Squirrel working

Squirrel is the latest name for GitHub's "It's like ClickOnce but Works™" installer. I've been working on a Windows GUI for git blame, and setting up automatic updates with Squirrel seemed like a must-have feature before an initial public release.

However, I had a few problems when trying to add Squirrel to my project, so I thought I'd document what I had to do to get it actually working.

1. Read the Documentation

@bgrainger
bgrainger / MonadicTasks.cs
Last active December 15, 2015 15:09
Tasks as monads.
class Program
{
public static void Main()
{
string urls = @"http://www.google.com/
http://www.microsoft.com/
http://www.github.com/
http://news.ycombinator.com/
http://stackoverflow.com/
http://www.logos.com/";
internal static class NativeMethods
{
[DllImport("XpsPrint.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
public static extern int StartXpsPrintJob(string printerName, string jobName, string outputFileName, IntPtr progressEvent, SafeWaitHandle completionEvent,
[MarshalAs(UnmanagedType.LPArray)] byte[] printablePagesOn, int printablePagesOnCount, out IXpsPrintJob xpsPrintJob, out IXpsPrintJobStream documentStream, out IXpsPrintJobStream printTicketStream);
}
[ComImport, Guid("E974D26D-3D9B-4D47-88CC-3872F2DC3585"), ClassInterface(ClassInterfaceType.None)]
internal class XpsOMObjectFactory
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace DynamicDispatch
{
interface IAnimalVisitor