"Exception has been thrown by the target of an invocation."

G

Guest

Hi, I have a problem when loading one of my dll. I have a main class that
would load a winform in another dll using reflection. When I load it using
Assembly.CreateInstance(DLLName.DLLFormName), an exception is thrown with the
message: "Exception has been thrown by the target of an invocation."

?ex.Source
"mscorlib"

?ex.GetType.AssemblyQualifiedName
"System.Reflection.TargetInvocationException, mscorlib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"

?ex.StackTrace
" at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder
binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr,
Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes)
at System.Reflection.Assembly.CreateInstance(String typeName, Boolean
ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args,
CultureInfo culture, Object[] activationAttributes)
at System.Reflection.Assembly.CreateInstance(String typeName)
at ..."

?ex.GetBaseException
{System.ComponentModel.Win32Exception}
[System.ComponentModel.Win32Exception]:
{System.ComponentModel.Win32Exception}
HelpLink: Nothing
InnerException: Nothing
Message: "Not enough storage is available to process this command"
Source: "System.Drawing"
StackTrace: " at System.Drawing.Icon.Initialize(Int32 width, Int32
height)
at System.Drawing.Icon..ctor(SerializationInfo info, StreamingContext
context)"
TargetSite: {System.Reflection.RuntimeMethodInfo}

As from ex.GetBaseException, I found that it states there is no enough
storage. When I try to remove some code operation (that retrieve lots of
information, create classes, and display in a listview), I no longer have the
problem and the dll/form loads properly. So, is this really that it is a
memory problem and that memory is running low? How can I fix this if I must
have those removed code to run? How does .net actually allocates the memory?
Is it that the memory of the whole computer has been used up, or is that
there is a limited allocation for my program? Would by increasing the virtual
memory, or let it autogrow helps?

Thanks
Eugene
 
J

james.curran

My guess would be that at the times it blows-up, you are passing bad
values for the icon's height & width (ie, it thinks you want it to
create an massive icon).

When you moved things around, you stoped corrupting these values.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top