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

  • SEARCH
  • Home
  • 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 8389763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:48:39+00:00 2026-06-09T18:48:39+00:00

I need a C# interface to call some native C++ code via the CLI

  • 0

I need a C# interface to call some native C++ code via the CLI dialect. The C# interface uses the out attribute specifier in front of the required parameters. That translates to a % tracking reference in C++/CLI.

The method I has the following signature and body (it is calling another native method to do the job):

virtual void __clrcall GetMetrics(unsigned int %width, unsigned int %height, unsigned int %colourDepth, int %left, int %top) sealed
{
    mRenderWindow->getMetrics(width, height, colourDepth, left, top);
}

Now the code won’t compile because of a few compile time errors (all being related to not being able to convert parameter 1 from 'unsigned int' to 'unsigned int &').

As a modest C++ programmer, to me CLI is looking like Dutch to a German speaker. What can be done to make this wrapper work properly in CLI?

  • 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-09T18:48:40+00:00Added an answer on June 9, 2026 at 6:48 pm

    Like it was also suggested in a deleted answer, I did the obvious and used local variables to pass the relevant values around:

     virtual void __clrcall GetMetrics(unsigned int %width, unsigned int %height, unsigned int %colourDepth, int %left, int %top) sealed
            {
                unsigned int w = width, h = height, c = colourDepth;
                int l = left, t = top;
                mRenderWindow->getMetrics(w, h, c, l, t);
                width = w; height = h; colourDepth = c; left = l; top = t;
            }
    

    It was a bit obvious since the rather intuitive mechanism of tracked references: they’re affected by the garbage collector’s work and are not really that static/constant as normal &references when they’re prone to be put somewhere else in memory. Thus this is the only way reliable enough to overcome the issue. Thanks to the initial answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used SWIG for generating some native JNI function interface for Irrlicht C/C++ 3D
I have some high-performance C++ that I need to interface with Objective-C, is there
I am writing a native COM/Ole/ActiveX wrapper for a scripting language. I need some
I have a web user control which call some methods of an interface. Four
I'm working on a flex application and I need to call some data with
I'm developing a Python/ObjC application and I need to call some methods in my
I need some help - I am trying to use a custom validation attribute
I have some code similar to the following: public interface IMyClass { MyEnum Value
In a delphi program (running as a service) i need to call some webservices.
I wrote some wcf interface ( REST ) that need to be called from

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.