473,396 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Virtual Override of "Mixed" method in another assembly.

I have the following situation:

Assembly #1:

class NativeSearchCriteria // NOTE: a native class
{
};

public ref class TheBaseClass
{
public:
virtual void Get_Search_Criteria( NativeSearchCriteria& _Criteria );
};

Assembly #2:

#using <assembly1.dll>

public ref class MyRestriction : TheBaseClass
{
public:
virtual void Get_Search_Criteria( NativeSearchCriteria& _Criteria )
override;
};

Upon compilation of the source-file containing the MyRestriction class, I
get the following error:

warning C4490: 'override' : incorrect use of override specifier;
'Get_Search_Criteria' does not match a base ref class method
'new' or 'override' are only allowed when a matching base method
from a ref class exists

I know for a fact that this is quite doable when there are only managed
types involved, so I think the problem here is related to the presence of a
native type.

Can anyone explain what the problem is, and a solution?

Thanks

Kevin
Mar 1 '07 #1
4 2334

Okay, after a little investigation:

It would appear that, from looking at the assembly with Reflector, all
native types are compiled as internal.

Hence there would appear to be an explicit firewalling between using the
same native type across an assembly boundary, on account of the native type
being internal to the assembly.

The practical effect is that class A in assembly 1 is considered distinct
from class A in
assembly 2, even though logically they are the same definition.

Fortunately I only have exactly one case where I am passing a native type
across assembly boundaries, and I intend to solve it by wrapping the native
type.

Nonetheless I'd still be interested if others have found alternative
solutions.

Mar 1 '07 #2

"Kevin Frey" <ke**********@hotmail.coma écrit dans le message de news:
eF**************@TK2MSFTNGP05.phx.gbl...
>
Okay, after a little investigation:

It would appear that, from looking at the assembly with Reflector, all
native types are compiled as internal.

Hence there would appear to be an explicit firewalling between using the
same native type across an assembly boundary, on account of the native
type being internal to the assembly.

The practical effect is that class A in assembly 1 is considered distinct
from class A in
assembly 2, even though logically they are the same definition.

Fortunately I only have exactly one case where I am passing a native type
across assembly boundaries, and I intend to solve it by wrapping the
native type.

Nonetheless I'd still be interested if others have found alternative
solutions.
Mark the native type as public (see
http://msdn2.microsoft.com/en-us/lib...bw(VS.80).aspx) or use
#pragma make_public (see
http://msdn2.microsoft.com/en-us/lib...07(VS.80).aspx)

However, you should be aware that using a native parameter for a public
function is a very bad idea if you want your assembly to be compatible with
other .NET languages.

Arnaud
MVP - VC
Mar 1 '07 #3
Thanks for the reply Arnaud.

You're right. I didn't actually think about the "re-use" aspects of exposing
a public native class. The types of methods I'm referring to would be
categorized as "internal to assembly group" if there were in fact such a way
to express that concept in .NET. In other words, they are a base-class
assembly package that is not necessarily for general consumption by
end-users, but will have multiple "higher-level" assemblies depending on
it. They used to be part of one assembly, and I'm now breaking this assembly
in two, so some methods have had to become public rather than internal as a
result.

For the moment, however, I've just put a wrapper around the object in
question which solves the problem.

Thanks for the pragma option - I'll keep it in mind.

Kevin

"Arnaud Debaene" <ad******@club-internet.frwrote in message
news:O5**************@TK2MSFTNGP05.phx.gbl...
>
"Kevin Frey" <ke**********@hotmail.coma écrit dans le message de news:
eF**************@TK2MSFTNGP05.phx.gbl...
>>
Okay, after a little investigation:

It would appear that, from looking at the assembly with Reflector, all
native types are compiled as internal.

Hence there would appear to be an explicit firewalling between using the
same native type across an assembly boundary, on account of the native
type being internal to the assembly.

The practical effect is that class A in assembly 1 is considered distinct
from class A in
assembly 2, even though logically they are the same definition.

Fortunately I only have exactly one case where I am passing a native type
across assembly boundaries, and I intend to solve it by wrapping the
native type.

Nonetheless I'd still be interested if others have found alternative
solutions.

Mark the native type as public (see
http://msdn2.microsoft.com/en-us/lib...bw(VS.80).aspx) or use
#pragma make_public (see
http://msdn2.microsoft.com/en-us/lib...07(VS.80).aspx)

However, you should be aware that using a native parameter for a public
function is a very bad idea if you want your assembly to be compatible
with other .NET languages.

Arnaud
MVP - VC


Mar 4 '07 #4

"Arnaud Debaene" <ad******@club-internet.frwrote in message
news:O5**************@TK2MSFTNGP05.phx.gbl...
>
"Kevin Frey" <ke**********@hotmail.coma écrit dans le message de news:
eF**************@TK2MSFTNGP05.phx.gbl...
>>
Okay, after a little investigation:

It would appear that, from looking at the assembly with Reflector, all
native types are compiled as internal.

Hence there would appear to be an explicit firewalling between using the
same native type across an assembly boundary, on account of the native
type being internal to the assembly.

The practical effect is that class A in assembly 1 is considered distinct
from class A in
assembly 2, even though logically they are the same definition.

Fortunately I only have exactly one case where I am passing a native type
across assembly boundaries, and I intend to solve it by wrapping the
native type.

Nonetheless I'd still be interested if others have found alternative
solutions.

Mark the native type as public (see
http://msdn2.microsoft.com/en-us/lib...bw(VS.80).aspx) or use
#pragma make_public (see
http://msdn2.microsoft.com/en-us/lib...07(VS.80).aspx)

However, you should be aware that using a native parameter for a public
function is a very bad idea if you want your assembly to be compatible
with other .NET languages.
The assembly will stay compatible, just that class, or possibly only that
method, will only be useable from C++/CLI. Or not? At least the
CLSCompliantAttribute can be specified per-method.
>
Arnaud
MVP - VC


Mar 9 '07 #5

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

Similar topics

20
by: Raymond Lewallen | last post by:
I read this on this website page http://www.vbip.com/books/1861004915/chapter_4915_06.asp: Unlike many object-oriented languages, all methods in VB.NET are virtual. Now in BOL, Under...
0
by: chaitan | last post by:
Hi, I have a search engine site written in Perl. How could I display a temporarily page while the system retrieving data, then a page refresh, display the search result in a new page? I try to do...
3
by: Stephen Gennard | last post by:
Hello, I having a problem dynamically invoking a static method that takes a reference to a SByte*. If I do it directly it works just fine. Anyone any ideas why? I have include a example...
3
by: Nadav | last post by:
Hi, I am writing a mixed mode application, I have a mixed mode Assembly manipulating a managed byte array, to access this array in unmanaged code I '__pin' the array, As I understand, pining an...
5
by: ron jacobs | last post by:
I have just implemented a "mixed mode" dll in VC++. I have implemented this dll in accordence with several articles found on the MSDN website including KB 814472. The crux of the problem is that...
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
8
by: Nadav | last post by:
Hi, I am writing a performence critical application, this require me to stick to unmanaged C++ as performance is much better using unmanaged C++ ( about 33% better ), Still, I am trying to avoid...
9
by: Andrew Robinson | last post by:
I have class A which inherits from class B. B contains the following virtual method: public virtual List<TSelect() { return new List<T>(); } Is there any way to make private or otherwise...
1
by: =?Utf-8?B?SmltIFdhbHNo?= | last post by:
I have an VC++ MFC Win32 application that isn't working correctly when I build it with VS2005. The problem seems to be in some ADO ActiveX controls that came with VS6 and are now out of support....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.