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

S

Swappy

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.
 
G

Göran Andersson

Swappy said:
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?
 
S

Swappy

Göran Andersson said:
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.


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?

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,........)
 
G

Göran Andersson

Swappy said:
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.
 
S

Swappy

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


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.
 

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