Skip to content

Instantly share code, notes, and snippets.

@flq
Last active December 16, 2017 12:04
Show Gist options
  • Save flq/f982de834bc990b5b11b320f221b478e to your computer and use it in GitHub Desktop.
Save flq/f982de834bc990b5b11b320f221b478e to your computer and use it in GitHub Desktop.
Ye olde NRE from a ctor call
using System;
using System.Runtime.Remoting.Proxies;
internal class Program
{
private static void Main(string[] args)
{
var c = new CrazyObject();
Console.WriteLine(c.Hello());
Console.ReadLine();
}
}
[Silly]
public class CrazyObject : ContextBoundObject
{
public string Hello() => "Hello Back";
}
public class SillyAttribute : ProxyAttribute
{
public override MarshalByRefObject CreateInstance(Type serverType) => null;
}