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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:54:15+00:00 2026-06-10T20:54:15+00:00

I just started working with C++ yesterday and I’m stuck on what I suspect

  • 0

I just started working with C++ yesterday and I’m stuck on what I suspect is a trivial problem. The main DLL class is generating error C2653: ‘Marshal’: is not a class or namespace name.

I’m pretty sure I’ve copied the syntax almost verbatim from the MSDN page on using this class. Here is the code:

// VideoInfoAssembly.cpp
// compile with: /clr

using namespace std;
using namespace System;
using namespace System::Runtime::InteropServices;

#include "stdafx.h"
#include "VideoInfoAssembly.h"

#pragma managed

namespace VideoInfoAssembly
{
    short VideoInfo::GetWidth(System::String^ managedString)
    {
        // Marshal the managed string to unmanaged memory. 
        char* stringPointer = (char*) Marshal::StringToHGlobalAnsi(managedString).ToPointer();

        // Always free the unmanaged string.
        Marshal::FreeHGlobal(IntPtr(stringPointer));

        return 9001;
    }
}

At a high level, I have a C# app that needs to read the video properties of video files and the Microsoft Media Foundation requires C++. I’ve successfully built the DLL and had it return over 9000 as a test. Now, I’m trying to pass a managed string to the DLL (which will be video file name); however, I’ve been struggling for over an hour to get the Marshal class to function. As stated earlier, I’ve been using the MSDN page without success. What am I missing?

  • 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-10T20:54:17+00:00Added an answer on June 10, 2026 at 8:54 pm

    This is a problem induced by pre-compiled headers. The compiler will skip everything until it finds the #include for the precompiled header file. The mistake you made is not putting #include "stdafx.h" at the top of the file. So fix it like this:

    #include "stdafx.h"             // Has to be first
    #include "VideoInfoAssembly.h"
    
    using namespace std;
    using namespace System;
    using namespace System::Runtime::InteropServices;
    
    // etc..
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started working using Google Maps API yesterday, and trying to set up
I just started using virtualenv, and it was working normally until yesterday. Now, and
Just started working with .NET and MVC(1). I'm having a problem wherein in my
I just started playing about with emacs yesterday for a project I'm working on.
Just started working with android and ran into a small problem. I am have
I just started working with powershell to automate a process, and now I'm stuck
I just started working with Javascript and I ran into an error with Visual
I have just started working in SSRS and I got a very strange problem
Just started working with Mercurial a few days ago and there's something I don't
Just started working through the Ruby chapter in Mr. Tate's Seven Language in Seven

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.