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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:51:05+00:00 2026-05-24T08:51:05+00:00

I need to gain some run-time information about a C++ program, which is kinda

  • 0

I need to gain some run-time information about a C++ program, which is kinda difficult due to C++ not offering some sophisticated reflection mechanism. Now, my approach is to compile the C++ code using /clr and to reflect over the resulting assembly from C# (simply because I like that language more than C++).

While this is all turning out more or less fine, I’m now stuck at a point where I need to actually run the program by calling its main method. Which is kind of frustrating considering how far I got already…

This is the C++ program in question:

#include "systemc.h"
#include <iostream>
using namespace std;

// Hello_world is module name
SC_MODULE (HelloWorld) {
    SC_CTOR (HelloWorld) {
        // Nothing in constructor 
    }
    void HelloWorld::say_hello() {
        //Print "Hello World" to the console.
        cout << "Hello World.\n";
    }
};

//sc_main in top level function like in C++ main
int sc_main(int argc, char* argv[]) {
  HelloWorld hello("HELLO");
  hello.say_hello();
  string input = "";
  getline(cin, input);
  return(0);
}

Nothing fancy, really…

This is the C# method used to inspect the resulting assembly:

System.Reflection.Assembly ass = System.Reflection.Assembly.LoadFrom(filename);

System.Console.WriteLine(filename + " is an assembly and has been properly loaded.");

Type[] hello = ass.GetTypes().Where(type => type.Name.ToLower().Contains("hello")).ToArray();
Type[] main = ass.GetTypes().Where(type => type.Name.ToLower().Contains("main")).ToArray();

Now, while the hello Type-array contains the HelloWorld class (or at least I assume that it is that class), the main var contains three types, all of which deal with doMAINs (ie have nothing to do with the sc_main method I’m looking for). I assume that it has something to do with it not being public, but declaring it a static public member function of the HelloWorld class doesn’t work either since the function is expected to be a non-member function to be found. Or am I just overlooking something terribly stupid?

  • 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-05-24T08:51:05+00:00Added an answer on May 24, 2026 at 8:51 am

    No, it doesn’t. You need to learn how C++/CLI works- you can’t just recompile a C++ program with /CLR and be done with it. The sc_main method here is native, not managed, and you can’t reflect over it, and the same is true about the HelloWorld type, unless you redefined it to be a ref class, but I doubt you did because there you go in main instantiating it by value, which would only be legal if it was a native class.

    .NET and native code have very fundamentally different semantics and a magic compiler switch will not help you in this regard.

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

Sidebar

Related Questions

need ask you about some help. I have web app running in Net 2.0.
Need some help about with Memcache. I have created a class and want to
I'm using QT to implement some UI program. In this program I need a
I'm doing a translation of php script and want to gain some time by
I need to gain access to the list of most recently used programs and
Need to insert selected text on the page into textarea. There must be some
Need to call a filter function on some options based on a radio selected
The problem I have is that I need to do about 40+ conversions to
i've been working for some time with an opensource library ( fast artificial neural
I was working on a program,that I need to support new additions. Hmmm. Let

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.