Linking eVC4.0 in DOT NET

  • Thread starter Shrikant Chikhalkar
  • Start date
S

Shrikant Chikhalkar

Hi all!

Please help me.

If I create a simple Managed C++ DLL and use this dll in VB >NET CF it
works fine.
But if I make managed code as a wrapper to the unmanaged code it fails.

So I was tring to make Managed Code as a wrapper to unmanaged code (in eVC
4.0). and using Managed DLL in vb .NET .
It links with out any error.
But as soon as it encounter eVC call it through exception as
System.TypeLoadException.

So my problem is "How do I link static eVC 4.0 (.LIB) to VC .NET managed
DLL. So that using same DLL I can create VB .NET CF application"

Can any body help me out?. I will be helpfull for me.


Regards,
Shrikant Chikhalkar

I am giving code that I am using
code inside eVC 4.0
/**********************************************/
/**********************************************/
#include <malloc.h>
#include <string.h>

class myMath
{
private:
int i;
int j;
public:
myMath()
{
}
~myMath()
{
}
int Add();
};
/**********************************************/
/**********************************************/

code inside VC.NET

/**********************************************/
/**********************************************/
#pragma once

#pragma unmanaged

#include "../../mathLib/test.h"

#pragma managed

//using namespace System;

namespace DLL

{

public __gc class Class1

{

public:

Class1()

{

}

~Class1()

{

}

void Add(int i,int j)

{

myMath myPtr;

int ret = myPtr.Add();

}

};

}

/**********************************************/
/**********************************************/


code inside VB .NET For smart devices
/************************************************/
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Try

Dim myDLL As New DLL.Class1

myDLL.test(10, 10)

Catch ex As Exception

MsgBox(ex.ToString(), MsgBoxStyle.YesNo)

End Try

End Sub

/***********************************************/
 
D

Daniel Moth

Managed C++ is not supported on CE. Anything you got working was in an
unsupported scenario... Use VB or C# for NETCF and you can pinvoke to eVC
dlls.

Cheers
Daniel
 
C

Chris Tacke, eMVP

THere are a few things to note:

1. Managed C++ is not supported.
2. Unamanged C++ must be written with eVC - Studio doesn't support it
3. The only way to consume unmanaged code from managed is with P/Invoke

This means that native LIBs are not consumable. To use them you'll have to
make a native DLL that you P/Invoke.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate
 
G

Ginny Caughey [MVP]

Shrikant,

It is possible to create a managed C++ DLL that can be used with managed
apps on the Compact Framework, but it is not supported. What that means is
that if you get it working, fine, but probably nobody will help you with
that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top