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 7848219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:07:29+00:00 2026-06-02T18:07:29+00:00

I would like to accomplish a simple task: I want to produce a C++/CLI

  • 0

I would like to accomplish a simple task:
I want to produce a C++/CLI lib that calls some .NET routines, and exposes 1 static method that I can call from purely native C++ app. I want to statically link to that lib from my native app. The signature of the method that the native C++ app would call should be

void (unsigned char* data, int length, _TCHAR* args[])

I am pretty new to C++/CLI and C++ in general. So, can you please help me and answer these questions:

  1. For my tiny C++/CLI project, I assume the type needs to be class library with lib as output, targeting vc9 runtime (so that I can be sure it is available on end users PCs). Am I correct in this assumption?

  2. Can you provide an example of the outline of the method with that signature I will need to write in my C++/CLI project. In particular how should I do conversion to CLR types properly (i.e. byte[], int32, and string)? And how do I decorate that method with something like “extern “C” __declspec(dllexport)” to make this method callable from my native C++ app?

  3. How would I separate the code between cpp and h files in C++/CLI properly?

  4. Finally how would I actually call it from my native app once I add lib reference?

Thank you.

  • 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-02T18:07:30+00:00Added an answer on June 2, 2026 at 6:07 pm
    1. Class library: correct, but you’ll also need to change your project’s configuration type from Dynamic Library to Static Library. I’m not sure what you mean by ‘targeting vc9 runtime’ – you need to target the same runtime as the native code that will be using your static library.

    2. Since this is a static library, no __declspec(dllexport) is needed. If you want to know how to do conversion to .NET types, you’ll need to post what your code is actually doing. In general, you’ll want Marshal::Copy to copy a C-array into a .NET array, and marshal_as<> to copy C-strings into .NET strings, but there’s still the question as to whether that data is intended to be mutable and needs to be marshaled back to native types before returning…

    3. The exact same as in C++ – declaration in a header, definition in a source file.

    4. The exact same as any other function – #include the header containing the declaration and call the function.

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

Sidebar

Related Questions

What i would like to accomplish is that a partiel view contains a form.
I need something real simple, that for some reason I am unable to accomplish
What I would like is be able to generate a simple report that is
I would like to accomplish two things during my build process: Run unit tests
What I would like to accomplish from my Android application is an ability to
Would like to make anapplication in Java that will not automatically parse parameters used
This seems like it would be pretty common task, but I'm not having any
I am new to jQuery and I would like to know how to accomplish
Greetings, I want to write a script that handles simple http requests from Google
I'm new to Silverlight and I wanted to accomplish a relatively simple task:    Create

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.