473,608 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Object type cannot be converted to target type.

I am trying to call a delegate on my parent from a child thread, this is my
code, however i'm getting an exception "Object type cannot be converted to
target type." which I can't understand. The prototype for my delegate is:

public delegate void ExceptionDelega te( object[] o ); // called from all
child threads

This is the offending code. Can anyone shed any light please?

if( myParent.Invoke Required )
{
myParent.Invoke ( myParent.Messag eOnException, new object[] {
e.Message } );
}
else
{
myParent.Messag eOnException( new object[] { e.Message } );
}
Nov 16 '05 #1
2 5324
The second argument of Invoke excepts an array of objects you want to
pass as arguments to the delegate. Your delegate expects 1 argument,
which is of the type object[]. Your code should therefore look
something like the following:

myParent.Invoke ( myParent.Messag eOnException, new object[] { new
object[] {
e.Message } } );

----
- Wilco Bauwer
Blog & Custom Controls @ http://wilcoding.xs4all.nl

Nov 16 '05 #2
Thanks very much
"Wilco Bauwer" <wi****@gmail.c om> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
The second argument of Invoke excepts an array of objects you want to
pass as arguments to the delegate. Your delegate expects 1 argument,
which is of the type object[]. Your code should therefore look
something like the following:

myParent.Invoke ( myParent.Messag eOnException, new object[] { new
object[] {
e.Message } } );

----
- Wilco Bauwer
Blog & Custom Controls @ http://wilcoding.xs4all.nl

Nov 16 '05 #3

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

Similar topics

16
25403
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have the properties: mode1, mode2, and mode3. This seems simple but I can't quite figure it out... Any ideas anyone?
3
1525
by: Michael Stahl | last post by:
What I want to do: I want to have a class which is reading an .ini file and manipulate the application with the data from the ini file. What I have now: An ini file: Text=Hallo Dock=none
0
1561
by: Dica | last post by:
i'm getting an error when trying set my dataAdapter's selectCommand. the sqlStatement is a storedProc which takes parameters, so it's constructed as: sqlSelectCommand1.CommandText = ""; sqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure; sqlSelectCommand1.Connection = sqlConnection1; sqlSelectCommand1.Parameters.Add(new
4
4171
by: Barry | last post by:
object type cannot be converted to target type - i am getting this error message occuring numerous times in my task list, my project compiles and runs ok but it is a nuisance, I think Ihva eheard of this before but I cannot remember the solution, anybody got any help?
3
3123
by: news.microsoft.com | last post by:
I got this error "Object type cannot be converted to target type" in my VB Winforms application. When I click on it, it goes no where, how do I troubleshoot this? Thank you.
5
2135
by: Martin Robins | last post by:
I know that this has been asked before; and not only that, I know that it has been answered (successfully) as I myself have previously resolved the problem (with help) - however, I cannot for the life of me remember what the solution was. I am trying to send an email from an ASP.net application. If I send the email with the MailMessage.BodyFormat = MailFormat.Text then it sends fine; if I set MailMessage.BodyFormat = MailFormat.Html then I...
16
2887
by: anonymous.user0 | last post by:
The way I understand it, if I have an object Listener that has registered as a listener for some event Event that's produced by an object Emitter, as long as Emitter is still allocated Listener will stay alive. Is this correct? If this is correct, I've got a problem. Let's say I've got an object Customer that has an PurchaseList (Collection) of Purchase objects. Now, these Purchase objects were pulled from a datasource Datasource. The...
2
1856
by: Dabbler | last post by:
I'm getting the following error when I try and insert a row using FormView, ObjectDataSource and stored procedure. The form has 40+ columns on it and I'm not sure how to diagnose where the problem is, the data object class, the business class etc? Object of type 'System.Int32' cannot be converted to type 'System.String'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack...
0
1275
by: Pablo.Mazaeda | last post by:
Hello, I am getting the following error when opening a form with customs controls objects in Visual Studio 2005 environment. I assume it is a version problem or something. Any solution? Object of type 'AMOSReplicationClient.InstStatus' cannot be converted to type 'AMOSReplicationClient.InstStatus'.
0
8063
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8002
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8496
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8475
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8338
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6816
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5475
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1329
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.