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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:38:55+00:00 2026-05-26T12:38:55+00:00

First off, I’ll admit I’m cargo-culting this a little bit — my nice clean

  • 0

First off, I’ll admit I’m cargo-culting this a little bit — my nice clean sample code doesn’t work when I’m wedging it into the real world. That being said…

I have a DLL called CPierce.CSharpCall.dll that has something like the following C# in it:

namespace CPierce.CSharpBridge
{
    [System.Runtime.InteropServices.Guid("3D08DF02-EFBA-4A65-AD84-B08ADEADBEEF")]
    public interface ICSide
    {
        // interface definition omitted...
    }
    [System.Runtime.InteropServices.Guid("CBC04D81-398B-4B03-A3D1-C6D5DEADBEEF")]
    public partial class CSide : ICSide
    {
        // class definition omitted...
    }
}

This is registered with regasm /tlb, etc.. Then, my C++ code looks something like this:

#import "CPierce.CSharpCall.tlb" named_guids

    // Contains syntax errors!
int myfunc()
{
    HRESULT hRes = S_OK;
    CoInitialize(NULL);
    CPierce.CSharpBridge::ICSide *pManagedInterface = NULL;

    hRes = CoCreateInstance(
            CPierce.CSharpBridge::CLSID_Class1, 
            NULL, CLSCTX_INPROC_SERVER, 
            CPierce.CSharpBridge::ICSide, 
            reinterpret_cast<void**> (&pManagedInterface));

    // Calls to the interface omitted....

    CoUninitialize();
    return 0;
}

The problem is, of course, the syntactically wrong bit about CPierce.CSharpBridge. I know in C++ if I want to have a similar namespace to the C# code I could say:

namespace CPierce
{
    namespace CSharpBridge
    {
        // definitions go here
    }
}

But I don’t think that’s what I’m looking for here, since I just need to refer to two constants that are in another namespace without putting the entire method in that namespace.

What is the C++ syntax I need to complete this call to CoCreateInstance?


Update: On deeper (much deeper) inspection, I’m finding that my .tlb file created by regasm is nearly empty. When I catenated all of my source into a single .cs file and compile with:

csc /debug /t:library BigFile.cs 
regasm BigFile.dll /tlb:BigFile.tlb

I get a hefty (and useful) tlb file.

When I compile the whole project from Visual Studio, I’m getting a .DLL all right, but regasm doesn’t do anything with it but produce a minimal .tlb file. (ildasm shows almost no differences between the two DLL’s)

If I compile BigFile.cs in Visual Studio, I get a DLL that’s also useless.

I’m stumped.

  • 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-26T12:38:56+00:00Added an answer on May 26, 2026 at 12:38 pm

    This appears to be a problem on the C#/Visual Studio side. I’ll abandon this question and open an appropriate one. Thank you for your help in narrowing it down.

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

Sidebar

Related Questions

First off I use this code to make the navigation bar always stay fixed;
First off, the little voice inside my head is screaming that this is a
First off, there's a bit of background to this issue available on my blog:
First off, my code: @interface Block : NSObject { NSData *data; NSInteger slice_count; }
First off tags wont work. I say this because i create 4 buttons all
First off this is for homework or... project. I'm having trouble understanding the idea
First off, my problem is quite similar to this one . I would like
First off, I'm using Access 2000 and DAO. I have code that executes a
First off, I am cross-posting this from Server Fault because I did not receive
First off: Everything works , but I would like to fine tune this a

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.