473,543 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 MDirectShowHand ler.
This currently wraps only the constructor and destructor calls (see
code below) in the unmanaged class DirectShowHandl er. When I try to
build this, the .obj files are created but the linker throws errors:

error LNK2020: unresolved token (06000001)
ManagedDirectSh owHandler.MDire ctShowHandler:: .ctor
error LNK2020: unresolved token (06000002)
ManagedDirectSh owHandler.MDire ctShowHandler:: Finalize
error LNK2020: unresolved token (06000002) delete
fatal error LNK1120: 3 unresolved externals

Here are the 4 files:

ManagedDirectSh owHandler.h:
---------------------------
#pragma once
#include "DirectShowHand ler.h"
#pragma managed
#using <mscorlib.dll >
using namespace System;

namespace ManagedDirectSh owHandler
{
public __gc class MDirectShowHand ler
{
public:
MDirectShowHand ler();
~MDirectShowHan dler();
private:
DirectShowHandl er __nogc* m_pDirectShowHa ndler;
};
}

ManagedDirectSh owHandler.cpp:
-----------------------------
#pragma once
#include "stdafx.h"

#include "ManagedDirectS howHandler.h"

public __gc class MDirectShowHand ler
{
public:
MDirectShowHand ler::MDirectSho wHandler()
{
m_pDirectShowHa ndler = new DirectShowHandl er();
}

MDirectShowHand ler::~MDirectSh owHandler()
{
m_pDirectShowHa ndler->~DirectShowHan dler();
}
private:
DirectShowHandl er __nogc* m_pDirectShowHa ndler;
};

DirectShowHandl er.h:
--------------------
#pragma once
#pragma unmanaged

class DirectShowHandl er
{
public:
DirectShowHandl er(void);
~DirectShowHand ler(void);
};

DirectShowHandl er.cpp:
----------------------
#include "StdAfx.h"
#include ".\directshowha ndler.h"
#include <iostream>
#using <mscorlib.dll >
using namespace std;

// Constructor for DirectShowHandl er (this class is unmanaged)
DirectShowHandl er::DirectShowH andler(void)
{
cout << "DirectShowHand ler created" << endl;
}

DirectShowHandl er::~DirectShow Handler(void)
{
cout << "DirectShowHand ler 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 2912

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

Similar topics

2
7562
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 DLL C++ (unmanaged) project. I found the decorated names of the symbols I wanted to export and created a .def file, so that it generated an import...
1
9090
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, Configuration: Debug Win32 ------ Compiling... Stdafx.cpp
4
11331
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 LNK2020: unresolved token (0A000007) memset LINK : error LNK2020: unresolved token (0A000008) free LINK : error LNK2020: unresolved token (0A00000A)...
0
1367
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 it's ugly and sure things shouldn't be like that. I'd like to know if that's a conceptual mistake by me, a compiler error, both, or none of them! ;-)...
1
533
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 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...
1
3701
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) class library and type in the following code below: #include <map> #include<string>
3
1864
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 errors: LINK : error LNK2020: unresolved token (0A00001A) _CxxThrowException LINK : error LNK2020: unresolved token (0A00001C) exception.__ctor...
3
6132
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 : unmanaged (or regular classes) and managed (__gc classes). I already know how to use "__declspec(dllexport)" to export and "__declspec(dllimport)" to...
3
2299
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 can use the interface as preferred. How do you expose a static event through an interface? In the example below as coded, in a VB app I can...
0
7402
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7733
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7344
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7684
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5264
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4890
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3391
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
963
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
633
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.