By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,296 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,296 IT Pros & Developers. It's quick & easy.

Problem with COM - System.InvalidCastException

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.