473,324 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Managed Extensions - error C2440

I am encountering a problem with a Visual C++ >NET Class Library using
Managed Extensions. The code is simplied below to show the problem

=================Class1.h======================

namespace Namespace1
{
public __gc class Class1
{
private:
static IMediaControl __nogc *m_pMC;
public:
Class1(void);
~Class1(void);
};
}

=================Class1.cpp======================

#include "StdAfx.h"
#include <dshow.h>
#include "Class1.h"

using namespace System;
namespace Namespace1
{
Class1::Class1(void)
{
HRESULT hr;
// ...
hr = m_pGraphBuilder->QueryInterface(IID_IMediaControl, (void
**)&m_pMC);
// ...
}
// other classes
}

==================================================

This code generates the following compile error

error C2440: 'type cast' : cannot convert from 'ICaptureGraphBuilder2
*__gc * ' to 'void ** '
Cannot convert a managed type to an unmanaged type

This error goes away when the following work-around is made to Class1:

Class1::Class1(void)
{
HRESULT hr;
// ...
IMediaControl __nogc *pMC; //Workaround for possible Visual Studio
bug
hr = m_pGraphBuilder->QueryInterface(IID_IMediaControl, (void
**)&pMC);
if (FAILED(hr))
m_pMC = pMC;
// ...
}

==================================================

Is this a Microsoft Visual Studio .NEt bug?
Nov 17 '05 #1
0 1043

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Lars Grøtteland | last post by:
Hello! Could anyone help me please. I tried the following - I created an application in .NET 2003. The project is a MFC Application a CDialog. I ran the application fine. I changed the...
0
by: BobTheHacker | last post by:
I am a little lost which is not out of place for me. Anyway here is the story. I wrote a C# class library (managed code) and have a VC++ project that is not managed and am having a few issues. ...
6
by: Tim | last post by:
I'm trying to co-erce a __gc array of Byte to a __nogc pointer to char to pass to a native function call in a bit of managed c++ code like this: Byte field __gc = dynamic_cast<Byte...
12
by: GRoll35 | last post by:
I get 4 of those errors. in the same spot. I'll show my parent class, child class, and my driver. All that is suppose to happen is the user enters data and it uses parent/child class to display...
3
by: Andreas | last post by:
Hi! I'm currently developing a DLL that makes use of C++ and .net (mixed) using Visual Studio 2003. Now, as I wanted to move to the new Visual Studio 2005, I converted this project into the...
7
by: harishashim | last post by:
I am wrapping a digital camera API using Managed C++ VS .NET 2003). I have this function that called as bellow in the API sample. err = PR_RC_StartViewFinder( m_hCamera, //line 1...
4
by: Andy | last post by:
Hi all, sorry for the cross group spam but my question does really fall into both groups. Here's my issue. I have a Visual C++, CLR Class Library with a public class and a public method in a...
2
by: kelvin.koogan | last post by:
Our company has a mix of users with VS2003 & VS2005. I'm am having difficulty working out how components written with these 2 tools can be written together. I want to be able to a) incorporate a...
3
by: David K in San Jose | last post by:
I'm using managed (CLR) C++ in VS2005 to create a Windows app that contains a form named "MyForm". In the code for that form I'm trying to invoke some static functions by using an array of function...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.