473,856 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Virtual Override of "Mixed" method in another assembly.

I have the following situation:

Assembly #1:

class NativeSearchCri teria // NOTE: a native class
{
};

public ref class TheBaseClass
{
public:
virtual void Get_Search_Crit eria( NativeSearchCri teria& _Criteria );
};

Assembly #2:

#using <assembly1.dl l>

public ref class MyRestriction : TheBaseClass
{
public:
virtual void Get_Search_Crit eria( NativeSearchCri teria& _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_Cri teria' 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 2370

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**********@h otmail.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******@clu b-internet.frwrot e in message
news:O5******** ******@TK2MSFTN GP05.phx.gbl...
>
"Kevin Frey" <ke**********@h otmail.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******@clu b-internet.frwrot e in message
news:O5******** ******@TK2MSFTN GP05.phx.gbl...
>
"Kevin Frey" <ke**********@h otmail.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
CLSCompliantAtt ribute 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
1794
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 Perforamce Tips and Tricks in .NET Applications, A .Net Developer Platform White Paper, at the very bottom, it says: The JIT cannot inline virtual methods, so you lose a potential optimization if you get rid of non-virtual methods.
0
1433
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 it using "Content-Type: multipart/mixed;", it's working well in Netscape and firefox,but no luck in IE. Is there any standard way in doing that? Thanks a lot.
3
1312
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 below... --
3
1801
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 object guarantee that it will not be collected by the GC ( by increasing it's refcount or so ), Taking that in mind, looking at the code generated by the compiler I can't see anything taking care of the GC refcount... following is the pinned variable...
5
4844
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 when the dll is built with the \noentry linker option, I can not load the dll in a c# client. There is plenty of help available for loading this dll in a c++ client. Does anyone know how to load this dll in C# or VB?? Am I forced to use...
8
3526
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 cannot load/unload/reload extensions into my large and slow-to-load application during development without restarting the process then the disadvantages may outweigh the advantages. I've got a mixed-mode program in which I create a new AppDomain...
8
2004
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 the usage of old style COM, my alternative is to expose my unmanaged interface through the CLI, to achieve that I have created a mixed mode DLL in which my unmanaged class are defined. When referencing the DLL just described in another mixed mode EXE...
9
2730
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 hide this method within A so that classes instantiating A don't see it?
1
2702
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. So, I have decided to solve the problem by using a mixed assembly: Most of the program will be my MFC - based code (unmanaged), but I will implement one dialog box as managed code. In my original MFC app, this dialog box contains the problem ActiveX...
0
9904
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9758
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10692
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10378
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9527
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7086
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5754
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3195
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.