473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

TargetInvocationException makes no sense

Hi, very puzzling...
I have one perfectly working solution, in which I use a a.dll which has a
class A. that class loads data from
the database and for each row deserialize the cell into class A1. works
great.
I made a new solution, I linked to the same a.dll, and In a new project in
this new solution I call the same function in a.dll that will load the
datatable and for each row deserialize the info into class A1.
however, this time in the line of code that calls the deserialize I get:
An unhandled exception of type
'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an
invocation.

I tried several thinks, first I checked I am using in both solution vs.NET
2003 and not 2002 in one of them by mistake, I tried copying the code that
does the deserialization into the new solution instead of linking to a.dll,
I also tried adding the a.dll project to the new solution (instead of just
adding a reference to the dll)... nothing works. I get that exception and I
can not make any sense of it!
the only intuition I have is that it might be because of security or name
space issues that deserialization is known to be sensitive to, but I can not
find any path to the light. any ideas?

some code follows:
Dim dt As DataTable = _dbmaster.getDataTable(_sqlSel)
Dim row As DataRow
Dim bf As New Runtime.Serialization.Formatters.Binary.BinaryForm atter
Dim topic As iProgramTopic.Topic
For Each row In dt.Rows
Dim byts As Byte() = CType(row("srlz"), Byte())
Dim ms As New IO.MemoryStream(byts)
topic = CType(bf.Deserialize(ms), iProgramTopic.Topic)
'------------EXCEPTION!!!!!---------
_ht.Add(topic.topicId.strKey, topic)
Next
regards.
Jul 21 '05 #1
4 37272
Hi,

This exception is usually thrown when a remoting call is made across
application domain boundaries. It is not that meaningless if you know where
to look for details. The key property is InnerException - you should examine
this one to obtain the real exception occured. Chances are this property
will contain another TargetInvocationException instance - so you should
continue digging into the InnerException chain until you've found something
meaningful.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"dudi" <Da*********@nowhere.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi, very puzzling...
I have one perfectly working solution, in which I use a a.dll which has a
class A. that class loads data from
the database and for each row deserialize the cell into class A1. works
great.
I made a new solution, I linked to the same a.dll, and In a new project in
this new solution I call the same function in a.dll that will load the
datatable and for each row deserialize the info into class A1.
however, this time in the line of code that calls the deserialize I get:
An unhandled exception of type
'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an
invocation.

I tried several thinks, first I checked I am using in both solution vs.NET
2003 and not 2002 in one of them by mistake, I tried copying the code that
does the deserialization into the new solution instead of linking to a.dll, I also tried adding the a.dll project to the new solution (instead of just
adding a reference to the dll)... nothing works. I get that exception and I can not make any sense of it!
the only intuition I have is that it might be because of security or name
space issues that deserialization is known to be sensitive to, but I can not find any path to the light. any ideas?

some code follows:
Dim dt As DataTable = _dbmaster.getDataTable(_sqlSel)
Dim row As DataRow
Dim bf As New Runtime.Serialization.Formatters.Binary.BinaryForm atter
Dim topic As iProgramTopic.Topic
For Each row In dt.Rows
Dim byts As Byte() = CType(row("srlz"), Byte())
Dim ms As New IO.MemoryStream(byts)
topic = CType(bf.Deserialize(ms), iProgramTopic.Topic)
'------------EXCEPTION!!!!!---------
_ht.Add(topic.topicId.strKey, topic)
Next
regards.


Jul 21 '05 #2
wouldn't it be nice if the debugger's exception message allowed my to
dig into that chain?

Dmitriy Lapshin [C# / .NET MVP] wrote:
Hi,

This exception is usually thrown when a remoting call is made across
application domain boundaries. It is not that meaningless if you know where
to look for details. The key property is InnerException - you should examine
this one to obtain the real exception occured. Chances are this property
will contain another TargetInvocationException instance - so you should
continue digging into the InnerException chain until you've found something
meaningful.

Jul 21 '05 #3
Yeah it would be a nice feature so you might wish to suggest it to the
Visual Studio team.
One can browse the chain by adding the exception variable to the Watch
window and expanding the InnerException nodes.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Uri Dor" <re***************@mivzak.com> wrote in message
news:eQ**************@TK2MSFTNGP12.phx.gbl...
wouldn't it be nice if the debugger's exception message allowed my to
dig into that chain?

Dmitriy Lapshin [C# / .NET MVP] wrote:
Hi,

This exception is usually thrown when a remoting call is made across
application domain boundaries. It is not that meaningless if you know where to look for details. The key property is InnerException - you should examine this one to obtain the real exception occured. Chances are this property
will contain another TargetInvocationException instance - so you should
continue digging into the InnerException chain until you've found something meaningful.


Jul 21 '05 #4
"Uri Dor" <re***************@mivzak.com> wrote in message
news:eQ**************@TK2MSFTNGP12.phx.gbl...
wouldn't it be nice if the debugger's exception message allowed my to
dig into that chain?


Try opening a watch window on the exception object's ToString method. That
should give you then entire stack trace, including that of inner exceptions.
It's not the most convenient format but the data is there.

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Greg Patrick | last post by:
My problem: I load an some assemblies (strong named) from a byte array using Assembly.Load(byte). They load fine. But one one of them is actually accessed, it's referenced assemblies can't be...
2
by: 2G | last post by:
Hi, I'm having some problems creating an instance of the dataset I compile in memory and I don't know why. I what to do this to Invoke WriteXmlSchema or GetSchemaSerializable so I could save...
0
by: Gemma M | last post by:
Hi, I have a C# program (code fragment below), which runs forever, processing incoming jobs. Part of this program launches a COM object. However, after a while I get : ...
0
by: chaf2701 | last post by:
Hi, I was in trouble with the System.Windows.Forms.ImageList control from VC.NET. I was doing the following : 1. New Project, C#, Windows Application 2. Add ImageList component imageList1 to...
7
by: dudi | last post by:
Hi, very puzzling... I have one perfectly working solution, in which I use a a.dll which has a class A. that class loads data from the database and for each row deserialize the cell into class A1....
1
by: JP | last post by:
Hi, I am facing a strange problem, please take a look at the code below: public SaveTree() { ........ ...... ......//some code Initranges()
0
by: Sutabi | last post by:
I'm trying to compile a "Release" build of a project, and in debug more it compiles and runs fine. In release mode it builds, but does not run and returns this exception. I have no idea what this...
3
by: Lambuz | last post by:
Hi all, when I use MethosInfo.Invoke method I obtain a TargetInvocationException where inner exception is +{"classBase.OpenConn cannot be invoked directly" } System.Exception. I'm using the...
2
by: Zytan | last post by:
I just got a TargetInvocationException from a WebBrowser control, after calling WebBrowser.Document.Write(text), which (internally) calls System.Windows.Forms.HtmlDocument.Write(String text),...
1
by: tcomer | last post by:
Hello, I'm receiving a "TargetInvocationException" on the follow line of code: datagridServers.Invoke(new UpdateDisplayCallback(this.UpdateServerDisplay), new object { server }); The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.