Skip to content

Logging Internal Classes

jpierson edited this page Jan 24, 2014 · 1 revision

Logging Internal Classes

So far, all of our examples have been with public classes and interfaces. You may want to keep your classes and interfaces internal like this:

abstract class CalculatorEventSource : EventSource
{
	public abstract void Clear();

	public static CalculatorEventSource Log = EventSourceImplementer.GetEventSourceAs<CalculatorEventSource>();
}

If you do this, you will get the following error:

Unhandled Exception: System.TypeLoadException: Type 'CalculatorEventSource_Implemented' from assembly 'EventSourceImplementation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is attempting to implement an inaccessible interface.

That's because ESP doesn't have access to your class. You can fix this with an assembly attribute. Add this to your AssemblyInfo.cs file:

[assembly: InternalsVisibleTo("EventSourceImplementation")]