471,592 Members | 1,106 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,592 software developers and data experts.

Invokemethod and static variables

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
Nov 17 '05 #1
2 2132
julien <ju****@sobrier.net> wrote:

<snip>
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).


Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Jon Skeet [C# MVP] a écrit :
julien <ju****@sobrier.net> wrote:

<snip>
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).



Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.


Actually, even though commenting the line with the static variable made
the StackIverflow to dissapear, the problem was somewhere else!

Thank you
Julien
Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by James | last post: by
2 posts views Thread by katekukku | last post: by
9 posts views Thread by Bryan Parkoff | last post: by
8 posts views Thread by Simone Chiaretta | last post: by
16 posts views Thread by RB | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.