Click here to Skip to main content
15,894,343 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralQuick and easy question Pin
Adam Durity9-Jun-04 9:29
Adam Durity9-Jun-04 9:29 
GeneralRe: Quick and easy question Pin
palbano9-Jun-04 16:08
palbano9-Jun-04 16:08 
GeneralConversion of Unmanaged COM in VC++ to Managed VC++ or C# Pin
imran1899-Jun-04 2:55
imran1899-Jun-04 2:55 
GeneralRe: Conversion of Unmanaged COM in VC++ to Managed VC++ or C# Pin
palbano9-Jun-04 5:49
palbano9-Jun-04 5:49 
Generalimage in a window Pin
nyquisttt8-Jun-04 22:15
nyquisttt8-Jun-04 22:15 
GeneralRe: image in a window Pin
palbano9-Jun-04 5:41
palbano9-Jun-04 5:41 
Generalfiles in c++ Pin
reddys8-Jun-04 22:06
reddys8-Jun-04 22:06 
Generalproblems regarding embedded dlls... Pin
JRacle8-Jun-04 1:27
JRacle8-Jun-04 1:27 
Hi,

I have a problem regarding embedded dlls (managed and unmanaged).. Could you help me please ?

My problem is the following..
- my target is a Pocket PC
- I want to export an unmanaged dll that I've done using Embedded Visual C++ 4.0 and wrap it with a managed dll written in C++. My unmanaged class is :

header :
--------
#ifdef UNM

#define DLL_API __declspec(dllexport)

#else

#define DLL_API __declspec(dllimport)

#endif

class DLL_API DLLUnmanaged

{

public:


DLLUnmanaged();

DLLUnmanaged(const char * const);

~DLLUnmanaged();

const char * getstring() const {return str;}

char * suffix(int n);


private:

char * str;

unsigned short len;

};


cpp:
#include <windows.h>

#include "stdafx.h"

#pragma warning( disable : 4091 )

#include "UnmanagedDLL.h"

BOOL APIENTRY DllMain( HANDLE hModule,

DWORD ul_reason_for_call,

LPVOID lpReserved

)

{

return TRUE;

}

DLLUnmanaged::DLLUnmanaged()

{

str = (char *)LocalAlloc(0, sizeof(char));

str[0] = '\0';

len = 0;

}

DLLUnmanaged::DLLUnmanaged(const char * const str0)

{

len = (unsigned short)strlen(str0);

str = (char *) LocalAlloc(0, sizeof(char)*(len+1));

for(unsigned short i = 0; i < len; i++)

str[i] = str0[i];

str[i] = '\0';

}

char * DLLUnmanaged::suffix(int pos)

{

unsigned short suffix_length;

pos--;

if (pos < 0) pos = 0;

suffix_length = len - pos + 1;


if (suffix_length > 0)

{

char * suff = new char[suffix_length];

for(unsigned short i = pos; i < len+1; i++)

suff[i - pos] = str[i];

return suff;

} else

return 0;

}

DLLUnmanaged::~DLLUnmanaged()

{

LocalFree(str);

len = 0;

}

- I want to use the managed extensions of Visual Studio .Net like this :
#using <mscorlib.dll>

using namespace System;

#include <iostream>

using std::cout; using std::endl;

#include "path.../UnmanagedDLL.h"

public __gc class DLLManaged // to avoid using "DLLImport"s..

{

public:

String * find_suffix(String * s, int pos)

{

int length = s->Length;

char * in_string = new char[length+1];

for(unsigned short i = 0; i<length; i++)

{

in_string[i]="(char)s-">Chars[i];

}

in_string[length] = '\0';

DLLUnmanaged * s0 = new DLLUnmanaged(in_string);

delete [ ] in_string;

return s0->suffix(pos);

}


};

... so here is what I've done when doing it only with Visual Studio .Net. I've added to the solution (that has got the unmanaged (I took "DLL MFC") and managed (I took ".Net DLL") ) a C# windows application that simply references the managed dll. All that works fine..

but if I want to make a project like this (actually the unmanaged dll that I use is a bit more complicated that the one I gave you) for a Pocket PC I encounter a lot of problems (please don't blame me, I'm a beginner!)

I tried to do it this way. The thing is that I don't know how to make an EMBEDDED MANAGED C++ DLL...

if I do the unmanaged project with Embedded Visual C++ 4, and if I make a .Net DLL similar to the one I've given to you upper, I get errors like:

ManagedDLL error LNK2020: jeton non résolu (0A000009) _CxxThrowException
ManagedDLL error LNK2020: jeton non résolu (0A00000B) delete
ManagedDLL fatal error LNK1120: 2 externes non résolus
(sorry, I've the French version of VS .Net)

obviously the linkage goes wrong..

So..what is the thing I've to do ? could you help me please, since I'm trying to fix the problem for many days now!

thanks to pay attention to it, Smile | :)
Julien (IT student)
GeneralUsing SetupAPI for installing Ramdrive driver Pin
mtaghiloo7-Jun-04 23:57
mtaghiloo7-Jun-04 23:57 
GeneralCan't compile homework Pin
MisNemesis7-Jun-04 14:55
professionalMisNemesis7-Jun-04 14:55 
GeneralRe: Can't compile homework Pin
Ravi Bhavnani8-Jun-04 10:49
professionalRavi Bhavnani8-Jun-04 10:49 
Generalstring Pin
nyquisttt7-Jun-04 7:13
nyquisttt7-Jun-04 7:13 
GeneralRe: string Pin
Ravi Bhavnani7-Jun-04 7:32
professionalRavi Bhavnani7-Jun-04 7:32 
GeneralRe: string Pin
Ni@m8-Jun-04 10:44
Ni@m8-Jun-04 10:44 
GeneralUsing C++ DLL (from .NET) in C# Pin
choged7-Jun-04 3:19
choged7-Jun-04 3:19 
GeneralRe: Using C++ DLL (from .NET) in C# Pin
eldrago15-Jun-04 0:02
eldrago15-Jun-04 0:02 
Generalcompile error?????helpppp meeee Pin
nthevu6-Jun-04 19:06
professionalnthevu6-Jun-04 19:06 
GeneralRe: compile error?????helpppp meeee Pin
Ni@m8-Jun-04 10:45
Ni@m8-Jun-04 10:45 
GeneralComposite and Builder Dessign Patterns Pin
Arun AC6-Jun-04 7:27
Arun AC6-Jun-04 7:27 
General#include of windows headers Pin
Julien Delezenne5-Jun-04 12:20
Julien Delezenne5-Jun-04 12:20 
GeneralRe: #include of windows headers Pin
palbano5-Jun-04 16:59
palbano5-Jun-04 16:59 
Generallinking managed dll to standard c++ Pin
Emiliano3-Jun-04 23:54
Emiliano3-Jun-04 23:54 
GeneralRe: linking managed dll to standard c++ Pin
cppmanuf25-Jun-04 17:54
cppmanuf25-Jun-04 17:54 
GeneralRe: linking managed dll to standard c++ Pin
Emiliano28-Jun-04 23:59
Emiliano28-Jun-04 23:59 
QuestionProblem connecting to server -difference managed C++ and C#? Pin
EnkelIk2-Jun-04 21:46
EnkelIk2-Jun-04 21:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.