Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / December 2004

Tip: Looking for answers? Try searching our database.

.override directive missing in manual COM interop...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nathan Baulch - 18 Nov 2004 13:03 GMT
I am so close to getting my manual COM interop classes to load correctly!
I have very slowly tracked down the problem to missing .override directives
on the classes in the IL generated from my assembly compared to that of
TlbImp.

I don't really understand why the directives exist in the first place
actually. TlbImp seems to be marking the extern methods as overriding
methods from an interface. This doesn't make much sense to me. If I try to
replicate it in my C# source by adding the "override" modifier, I get a very
predictable "There is no suitable method for override" error.

If I dump my DLL to IL, manually add in the .override directives, everything
works.
Please tell me there is a way to do this in C# and that I don't have to make
IL changes every time I need to build my assembly!

Nathan
Jeremy Chapman - 23 Nov 2004 19:27 GMT
I don't think COM supports overriding.

> I am so close to getting my manual COM interop classes to load correctly!
> I have very slowly tracked down the problem to missing .override directives
[quoted text clipped - 13 lines]
>
> Nathan
"Adam Nathan" - 07 Dec 2004 18:59 GMT
Defining classes exactly how TlbImp does can be tricky (and sometimes
impossible without using IL Assembler), but fortunately it's not really
required.  The simple way to define such a class in C# is to make it empty,
implement no interfaces, but mark it with ComImportAttribute and
GuidAttribute.  The attributes make the CLR perform the appropriate
CoCreateInstance when you instantiate the class, and casts to interfaces
will perform the appropriate QueryInterface calls.  If you mark your
"default interface" with the CoClassAttribute, you can make the experience
even more seemless to clients of your class.

Hope that helps,
Adam

--------------------
>From: "Jeremy Chapman" <NoSpam@Please.com>
>References: <OrN3e6WzEHA.3708@TK2MSFTNGP14.phx.gbl>
[quoted text clipped - 9 lines]
>NNTP-Posting-Host: mail.interiorhealth.ca 204.239.148.2
>Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09
phx.gbl
>Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.clr:12331
>X-Tomcat-NG: microsoft.public.dotnet.framework.clr
[quoted text clipped - 22 lines]
>>
>> Nathan
Nathan Baulch - 16 Dec 2004 05:41 GMT
Thanks so much for the info, everything seems to be working now.
I always wondered what the CoClassAttribute was and why TlbImp wrapped
classes could be referenced in two ways (TheObject or TheObjectClass)
interchangeably.
Never again will my CoClasses explicitly implement my COM interfaces!

Nathan

> Defining classes exactly how TlbImp does can be tricky (and sometimes
> impossible without using IL Assembler), but fortunately it's not
[quoted text clipped - 9 lines]
> Hope that helps,
> Adam
Ravichandran J.V. - 17 Dec 2004 09:17 GMT
As long it works you should be happy!:)

Override works only in inheritance. All you are doing is adding a
reference to a dll. Anyway, are the COM methods virtual or pure virtual
by any chance ?

with regards,

J.V.Ravichandran
Signature

- http://www.geocities.com/
 jvravichandran
- http://www.411asp.net/func/search?
 qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com 
- http://www.MSDNAA.Net 
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
 display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
 at http://www.Google.com


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.