473,397 Members | 2,099 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,397 software developers and data experts.

Managed and unmanaged C++: error LNK2020: unresolved token

Hi,

ultimately I want to call some unmanaged C++ class that contains some
DirectShow code of mine from my C# classes, but for the time being I'd
be happy if I could get this to build! I have read the other topics on
the same problem here on the groups but haven't found the solution to
my problem yet.

I have written a managed C++ wrapper class called MDirectShowHandler.
This currently wraps only the constructor and destructor calls (see
code below) in the unmanaged class DirectShowHandler. When I try to
build this, the .obj files are created but the linker throws errors:

error LNK2020: unresolved token (06000001)
ManagedDirectShowHandler.MDirectShowHandler::.ctor
error LNK2020: unresolved token (06000002)
ManagedDirectShowHandler.MDirectShowHandler::Final ize
error LNK2020: unresolved token (06000002) delete
fatal error LNK1120: 3 unresolved externals

Here are the 4 files:

ManagedDirectShowHandler.h:
---------------------------
#pragma once
#include "DirectShowHandler.h"
#pragma managed
#using <mscorlib.dll>
using namespace System;

namespace ManagedDirectShowHandler
{
public __gc class MDirectShowHandler
{
public:
MDirectShowHandler();
~MDirectShowHandler();
private:
DirectShowHandler __nogc* m_pDirectShowHandler;
};
}

ManagedDirectShowHandler.cpp:
-----------------------------
#pragma once
#include "stdafx.h"

#include "ManagedDirectShowHandler.h"

public __gc class MDirectShowHandler
{
public:
MDirectShowHandler::MDirectShowHandler()
{
m_pDirectShowHandler = new DirectShowHandler();
}

MDirectShowHandler::~MDirectShowHandler()
{
m_pDirectShowHandler->~DirectShowHandler();
}
private:
DirectShowHandler __nogc* m_pDirectShowHandler;
};

DirectShowHandler.h:
--------------------
#pragma once
#pragma unmanaged

class DirectShowHandler
{
public:
DirectShowHandler(void);
~DirectShowHandler(void);
};

DirectShowHandler.cpp:
----------------------
#include "StdAfx.h"
#include ".\directshowhandler.h"
#include <iostream>
#using <mscorlib.dll>
using namespace std;

// Constructor for DirectShowHandler (this class is unmanaged)
DirectShowHandler::DirectShowHandler(void)
{
cout << "DirectShowHandler created" << endl;
}

DirectShowHandler::~DirectShowHandler(void)
{
cout << "DirectShowHandler destroyed" << endl;
}
The Visual Studio project is set to .NET Class Library, so that it
should create a DLL which I can then add to my C# project.

Any ideas why the errors mentioned above occur? This is quite
frustrating as there don't seem to be any good examples that take you
through it step by step.

Thanks,

Roland

Nov 17 '05 #1
0 2889

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

Similar topics

2
by: Jacob Cohen | last post by:
Under VC7.1, I am trying to wrap a native-C++ DLL that contains C++ objects in a Managed-C++ class library for use in a C# project. I created and compiled the native DLL under VC7.1 as a Win32...
1
by: Tony Baker | last post by:
Hi, If I 1) create a brand new Visual C++ Project -> Class Library (.Net) 2) in the stdafx.h file add #include <atlbase.h> I get the following errors: ------ Build started: Project: testATL,...
4
by: Aaron Queenan | last post by:
When I build a C++ library to .NET using the managed C++ compiler, I get the following error message: Linking... LINK : error LNK2020: unresolved token (0A000005) _CrtDbgReport LINK : error...
0
by: Gustavo L. Fabro | last post by:
Greetings! I found myself with a LNK2020 linking problem using VS.NET 2003 under a situation that I was able to replicate in a small project. I found one workaround for the problem too, but...
1
by: Roland | last post by:
Hi, ultimately I want to call some unmanaged C++ class that contains some DirectShow code of mine from my C# classes, but for the time being I'd be happy if I could get this to build! I have...
1
by: Maxwell | last post by:
Hello, I having having oodles of trouble using the std lib in my MC++ (VS.NET 2003) Class library. I figured out a simple sample to reproduce the errors I am having. Create a MC++ (VS.NET 2003)...
3
by: Ulrich Sprick | last post by:
Hi, I have to write a managed C++ wrapper around an existing, unmanaged C++ class. First tests suggested it should work, but after adding the complete unmanaged code, I get the following linker...
3
by: amirbehzadan | last post by:
Hello, I am writing some C++ classes and want to export them as .dll files so other users can import them and use the methods I have provided in those classes. I have two types of classes :...
3
by: =?Utf-8?B?TkVXMi5ORVQ=?= | last post by:
I have a static event declared in a C++ ref class, that can then be handled in a VB app. I'm trying to expose the static event through the interface that the C++ ref class implements so the VB app...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.