473,508 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with COM - System.InvalidCastException

Hi.

I've been searching all over the internet, and I didn't find solution of my
problem :( I hope someone can help me here...

The problem is:

Im writing a library in C# (COM Library). This library will be used by an
application, which is wrote in VB6. I will call it "MainApp".

In my library I'm reading property from object which is shared from MainApp.

My class looks like:

[Guid("6FA89BBA-A87F-4e0a-8A0D-9B2FA0C7BD53"),
ClassInterface(ClassInterfaceType.None)]

public class MainClass : MainApp.ExternalClass
{
void InitClass(MainApp.Interface myIntrf)
{
MainApp.SomeObj s = myIntrf.MyProperty;
}
}

MainApp.ExternalClass - abstract class (I'm implementing its methods).

When I'm buliding the project, VS says:
"Property, indexer, or event 'MyProperty' is not supported by the language;
try directly calling accessor methods 'MainApp.get_MyProperty()' or
'MainApp.set_MyProperty(ref MainApp.SomeObj)''".

So i changed my code and I'm invoking get_MyPropert() method. Buuuut, when I
want to access some fields in MainApp.SomeObj an exception is thrown:
"System.InvalidCastException: QueryInterface for interface
'MainApp._SomeObj' failed."

What should I do, so my returing (from accessor method) object
('MainApp._SomeObj') is valid ??

I'll be appreciative for any advise...

Michal


Nov 16 '05 #1
0 1086

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

Similar topics

1
3669
by: bob scola | last post by:
I have a csharp, VS 2003 solution for a winform application The application uses an object called a "matter" and the class is defined in matter.cs. I can load matter objects into a combobox ...
0
2478
by: umhlali | last post by:
I get the following exception when my VB.NET app calls a Java web service that returns an array of objects. The same call works for a single object though. So looks like there is no problem...
3
2167
by: VB Programmer | last post by:
I am setting up forms authentication. In my code I keep getting this error. Any ideas? Error.... Server Error in '/LandOLots' Application....
0
623
by: QA | last post by:
I am using a Business Scorecard Accelarator in a Sharepoint Portal 2003 using SQL Server 2005 I am getting the following error: Error,5/7/2005 10:50:14 AM,580,AUE1\Administrator,"Specified cast is...
0
1108
by: Stefan Christmann | last post by:
I am validating XML-Documents with XML-schema-files and the C#-standard-functions. I have one XSD-document which is syntactically 100% correct after W3C-standard, but the schema compiler dies with...
0
1967
by: kcm | last post by:
Hello all, Not sure if this is the right place to post this. I ran up the samples for adventureworks for MSSQL2005. I setup the shop front. The web site is up. But when I try to register a new...
8
4247
by: Gamma | last post by:
I'm trying to inherit subclass from System.Diagnostics.Process, but whenever I cast a "Process" object to it's subclass, I encounter an exception "System.InvalidCastException" ("Specified cast is...
4
1833
by: rsdev | last post by:
Hi, I have an InvalidCastException which is completely puzzling me. I have checked all the members in the stored procedure against my data provider and seems to be ok. Also in the stack trace it...
1
2365
by: =?Utf-8?B?QkpT?= | last post by:
I have written a Generic method that takes an object, a type, T, and returns a System.Nullable (Of T) depending on whether or not the object IsDBNull. It was working fine until I tried to pass a...
2
5958
by: John Heitmuller. | last post by:
Hi, I have a VB.Net application that I have recently upgraded from Visual Studio 2003 to Visual Studio 2005. The VB.Net app accesses Word and Excel. When I run the newly compiled VB.Net app on...
0
7231
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
7132
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
7336
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
7401
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...
0
5640
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,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4720
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...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
432
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...

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.