471,355 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How to overcome from the error : "Object does not match target typ

hi,

Im running this code
public Boolean IsLayoutOpen(String strLayoutName)
{
Layout Layout_Obj = null;
try
{
Layouts layouts = instrumentation.Layouts; //This call is
through COM object
Layout_Obj = layouts.Item(strLayoutName);

layouts = null;
}
}

This code i am running in a thread but while calling the
instrumnetation.Layouts (it is From COM object) it gives me exception "Object
does not match target type."

Can someone tell me why this error is coming & what is the solution to
resolve this problem.
Jul 4 '08 #1
4 2259
Swappy wrote:
hi,

Im running this code
No, you are not running that code. It won't even compile, as you don't
set any return value in the method.

It might not be possible to say what's wrong with the code that you are
running, as you are some other code that you are not running.
public Boolean IsLayoutOpen(String strLayoutName)
{
Layout Layout_Obj = null;
try
{
Layouts layouts = instrumentation.Layouts; //This call is
through COM object
Layout_Obj = layouts.Item(strLayoutName);

layouts = null;
}
}

This code i am running in a thread but while calling the
instrumnetation.Layouts (it is From COM object) it gives me exception "Object
does not match target type."

Can someone tell me why this error is coming & what is the solution to
resolve this problem.
What more information does the exception contain? For example, what is
the type of the exception? That would help to determine if the exception
occurs in the COM method or in the code that is calling the COM method.

How is the method declared in the COM code?

--
Göran Andersson
_____
http://www.guffa.com
Jul 4 '08 #2


"Göran Andersson" wrote:
Swappy wrote:
hi,

Im running this code

No, you are not running that code. It won't even compile, as you don't
set any return value in the method.

It might not be possible to say what's wrong with the code that you are
running, as you are some other code that you are not running.
public Boolean IsLayoutOpen(String strLayoutName)
{
Layout Layout_Obj = null;
try
{
Layouts layouts = instrumentation.Layouts; //This call is
through COM object
Layout_Obj = layouts.Item(strLayoutName);

layouts = null;
}
}

This code i am running in a thread but while calling the
instrumnetation.Layouts (it is From COM object) it gives me exception "Object
does not match target type."

Can someone tell me why this error is coming & what is the solution to
resolve this problem.

What more information does the exception contain? For example, what is
the type of the exception? That would help to determine if the exception
occurs in the COM method or in the code that is calling the COM method.

How is the method declared in the COM code?

--
Göran Andersson
_____
http://www.guffa.com
Hi ,
That exception contain the following information :
Source : "mscorlib"
Data : System.CollectionaryInternal
HelpLink : null
InnerException : null
StackTrace : at System.RuntimeType.InvokeDispMethod(String name,........)
TargetSite : System.ObjectInvokeDispMethod(System.string,
System.Reflection.BindingFlags,........)
Jul 4 '08 #3
Swappy wrote:
>
"Göran Andersson" wrote:
>Swappy wrote:
>>hi,

Im running this code
No, you are not running that code. It won't even compile, as you don't
set any return value in the method.

It might not be possible to say what's wrong with the code that you are
running, as you are some other code that you are not running.
>>public Boolean IsLayoutOpen(String strLayoutName)
{
Layout Layout_Obj = null;
try
{
Layouts layouts = instrumentation.Layouts; //This call is
through COM object
Layout_Obj = layouts.Item(strLayoutName);

layouts = null;
}
}

This code i am running in a thread but while calling the
instrumnetation.Layouts (it is From COM object) it gives me exception "Object
does not match target type."

Can someone tell me why this error is coming & what is the solution to
resolve this problem.
What more information does the exception contain? For example, what is
the type of the exception? That would help to determine if the exception
occurs in the COM method or in the code that is calling the COM method.

How is the method declared in the COM code?

--
Göran Andersson
_____
http://www.guffa.com

Hi ,
That exception contain the following information :
Source : "mscorlib"
Data : System.CollectionaryInternal
HelpLink : null
InnerException : null
StackTrace : at System.RuntimeType.InvokeDispMethod(String name,........)
TargetSite : System.ObjectInvokeDispMethod(System.string,
System.Reflection.BindingFlags,........)
It looks like the COM method is declared as returning a Layouts object
(as the code compiles), but it's actually returning something different.

--
Göran Andersson
_____
http://www.guffa.com
Jul 4 '08 #4


"Göran Andersson" wrote:
Swappy wrote:

"Göran Andersson" wrote:
Swappy wrote:
hi,

Im running this code
No, you are not running that code. It won't even compile, as you don't
set any return value in the method.

It might not be possible to say what's wrong with the code that you are
running, as you are some other code that you are not running.

public Boolean IsLayoutOpen(String strLayoutName)
{
Layout Layout_Obj = null;
try
{
Layouts layouts = instrumentation.Layouts; //This call is
through COM object
Layout_Obj = layouts.Item(strLayoutName);

layouts = null;
}
}

This code i am running in a thread but while calling the
instrumnetation.Layouts (it is From COM object) it gives me exception "Object
does not match target type."

Can someone tell me why this error is coming & what is the solution to
resolve this problem.
What more information does the exception contain? For example, what is
the type of the exception? That would help to determine if the exception
occurs in the COM method or in the code that is calling the COM method.

How is the method declared in the COM code?

--
Göran Andersson
_____
http://www.guffa.com
Hi ,
That exception contain the following information :
Source : "mscorlib"
Data : System.CollectionaryInternal
HelpLink : null
InnerException : null
StackTrace : at System.RuntimeType.InvokeDispMethod(String name,........)
TargetSite : System.ObjectInvokeDispMethod(System.string,
System.Reflection.BindingFlags,........)

It looks like the COM method is declared as returning a Layouts object
(as the code compiles), but it's actually returning something different.

--
Göran Andersson
_____
http://www.guffa.com

Ya, i think this method is returning something different but why this is
happening?
Is this because of this method i m calling inside the thread?

The same code when i run without the thread then it runs properly & returns
the Layouts.

If this is because of thread then how can i overcome this problem. Please
suggest me any solution.
Jul 7 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Phil | last post: by
2 posts views Thread by =?Utf-8?B?U3dhcHB5?= | 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.