XXX cannot override XXX because they differ in return type

A

Alex

Hello everyone,

I'm currently in the process of converting a huge project from VS2003 to
VS2008. I'm having a very specific problem to which I cannot find a
solution.

Take a quick look at the following code:

(assembly name is ClassLibrary1)
Public Class Class1
Public Overridable Sub Init(ByVal kernel As MSComCtl2.MonthView)
End Sub
Public Overridable Function GetKernel() As MSComCtl2.MonthView
Return Nothing
End Function
End Class

(assembly name is ClassLibrary2)
Public Class Class2
Inherits ClassLibrary1.Class1
Public Overrides Sub Init(ByVal kernel As MSComCtl2.MonthView)
End Sub
Public Overrides Function GetKernel() As MSComCtl2.MonthView
Return Nothing
End Function
End Class

I'm using MSComCtl2.MonthView as an example. In the actual software, this is
a plain vanilla C/C++ COM object that is part of the project. Apparently,
this happens with any COM object.

The particularity of the problem is that both of these classes are in
different assemblies. If I try to do it within the same assembly, I get no
problem. As separate assemblies, I'm being told the Init sub isn't matching
a function of the base and that the return types on GetKernel are different.
Obviously, they aren't but VB apparently thinks they are.

I could prolly just change the name for Object and avoid these annoying
errors, but I'd like to understand what changed from VS2003 to VS2008 that
made this code go from working to not working.

Thanks for your help,

Alex.
 
B

Bill McCarthy

When you referenced the com object, a interop assembly would have been
generated for you. What you probably need to do is place that in a common
location so as both projects reference the same interop assembly.
 
A

Alex

How would I do that exactly?

I mean, when I add the COM object I don't get to choose where he saves or
loads the interop assembly from so how can I make both project use the same
assembly? Can I like choose to reference the interop assembly instead of the
real COM object? Not too sure how all of this works...

Alex.
 
B

Bill McCarthy

Hi Alex,

When you add a reference to the COM library the interop assembly is
generated for you. Look in your project references and you'll see it's
location. Copy that assembly into your other project and add a reference to
it instead of letting the IDE add the COM reference.
 

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