You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Julien Sobrier <ju...@sobrier.net> on 2005/06/17 05:34:04 UTC

Invokemethod and static log4net

Hello,
I have an assembly with a static variable:
private static readonly ILog log4net = LogManager.GetLogger(typeof(Core));

In one of the methods, I use this variable:
private void myMethod()
{
	...
	log4net.Debug("something to log");
	...
}


In one of my NUnit test, I create an instance for this assembly, and
call Mymethod:

Assembly asm = Assembly.LoadFrom("assembly.exe");
Type typeAssembly = asm.GetType("MyType");

object core = Activator.CreateInstance(typeAssembly, true);

			typeAssembly.InvokeMember("myMethod",BindingFlags.InvokeMethod |
BindingFlags.NonPublic | BindingFlags.Instance, null, core, null);

System.Reflection.TargetInvocationException : An exception was raised by
the target of a call
----> System.StackOverflowException : A System.StackOverflowException
exception was raised at
System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture, Boolean verifyAccess) at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, Binding
Flags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture) at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)

Exception not handled : StackOverflowException.

I don't have this error when I don't use the late binding, so log4net is
working (and I can actually the logs on the screen).


Thank you
Julien