Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8190737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:44:32+00:00 2026-06-07T03:44:32+00:00

The scenario I’m working with looks like this: public interface INativeWindow { … }

  • 0

The scenario I’m working with looks like this:

public interface INativeWindow { ... }

is a native window type of interface holding a few required, basic methods to implement in order to have a minimal window support (e.g. minimize, restore, etc.). This is a C# interface belonging to an interfaces project.

Now I want to implement it in a CLINativeWindow c++-cli class:

public ref class CLINativeWindow: public SWF::NativeWindow, INativeWindow
{ 
 ...
}

Lastly, I have another ref c++ cli class that has an internal member of the CLINativeWindow type and a wrapping property that returns an INativeWindow^ handle:

virtual property INativeWindow^ OwnNativeWindow
                {
                    INativeWindow^ __clrcall get() sealed { return NativeWindow;}
                    void __clrcall set(INativeWindow^ value) { NativeWindow = dynamic_cast<CLINativeWindow^>(value);}
                }

The issue here is that the dynamic_cast doesn’t work, nor does the implicit polymorphic downcast from the property’s getter method. If I’m not misinformed, I think I read in several places that in C++ with normal pointers, such a blunder really works. Now as an SWF::NativeWindow is the classic windows forms native window class (sorry about the unintended alliteration), it should have a virtual method, just as much as the interface does, so no problem for the dynamic cast operator since a polymorphic inheritance is involved. Am I wrong or is this just plain impossible in dotNet C++ CLI?

EDIT
additional code:

public ref class ExampleForSO
{
  CLINativeWindow^ NativeWindow;


 virtual property INativeWindow^ OwnNativeWindow
                    {
                        INativeWindow^ __clrcall get() sealed { return NativeWindow;}
                        void __clrcall set(INativeWindow^ value) { NativeWindow = dynamic_c

ast<CLINativeWindow^>(value);}
            }
}

The errors are from compile time and they state that the conversion/cast cannot be performed for both getter and setter (i.e. cannot convert from B^ to A^ and from B^ to A^)..
UPDATE
If the classes are in different files, implementing the property in a header won’t do. Implementing it in the separate .cpp source file does not cause a compile time error any more and works as desired.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:44:32+00:00Added an answer on June 7, 2026 at 3:44 am

    There is no multiple inheritance here. Your CLINativeWindow is inheriting from one class: SWF::NativeWindow, and it is also implementing INativeWindow interface.

    You did not provide enough information (what errors are you getting? sample code that can be pasted in VS to reproduce the problem?), but in general there is nothing wrong with the code that you posted.

    My guess is that your NativeWindow is declared as:

    CLINativeWindow NativeWindow;
    

    without the much needed ^. Try declaring it as:

    CLINativeWindow^ NativeWindow;
    

    EDIT

    The following compiles cleanly for me:

    public interface class INativeWindow
    {};
    
    public ref class SWFNativeWindow
    {};
    
    public ref class CLINativeWindow : SWFNativeWindow, INativeWindow
    {};
    
    public ref class NWHolder
    {
    public:
        virtual property INativeWindow^ OwnNativeWindow
        {
            INativeWindow^ __clrcall get() sealed { return nativeWindow_; }
            void __clrcall set(INativeWindow^ w) { nativeWindow_ = dynamic_cast<CLINativeWindow^>(w); }
        }
    
    private:
        CLINativeWindow^ nativeWindow_;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: I am working on a Android project where in one particular openGL page,
Scenario: At our company, we have enabled httpCompression for our website. This website (call
Scenario A SOAP web service provides an interface for retrieving documents and data. Security
Scenario: A simple html page exists with few buttons on Top (e.g. day, week)
Scenario 1 (That Works) This is a POC i created. I have a script
Scenario: I'm working on a solution that has many assemblies. The main assembly references
* Scenario i wish to make a jquery effect like the one found on
Scenario: I have a document I created using LaTeX (my resume in this case),
Scenario: I am trying to migrate a C++ application to WinRT/Metro Style. This application
Scenario I'm working with a Java model built from scratch in Eclipse. What's important

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.