logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: Invokemethod and static log4net
Date Mon, 20 Jun 2005 18:30:23 GMT

I have tried to reproduce your issue using a simple test app that loads
an assembly that uses log4net and uses InvokeMember to call a private
method. I have not seen any problems using this approach in my test.

Can you run your test under the VS debugger and see how far into the
private method the call gets before it blows the stack?

Nicko

> -----Original Message-----
> From: Julien Sobrier [mailto:julien@sobrier.net] 
> Sent: 17 June 2005 04:34
> To: log4net-user@logging.apache.org
> Subject: 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
> 
> 
> 

Mime
View raw message