472,374 Members | 1,559 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 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 2737

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: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.