Linking eVC4.0 in DOT NET

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Shrikant Chikhalkar (shrikant_at_manchitra.com)
Date: 02/22/05


Date: Tue, 22 Feb 2005 19:40:35 +0530


Hi all!

Please help me.

If I created 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"

If any body help me out for same 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

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



Relevant Pages

  • Re: am having a problem with pinvoke and StringBuilder[ ]
    ... If you don't have the source of the DLL then you are in a world of pain, that means you wont be able to use the interop marshaler, you need to "custom" marshal. ... public static extern int EnumerateBoards(ref int numBoards, ... Since the String class is immutable, I have used StringBuilder in my code ...
    (microsoft.public.dotnet.framework.clr)
  • Problem in performance of calling a dialog in DLL(Windows programm
    ... I use VC++ 2008 and have two part in my project(First part: my dll project ... “Select Reader” and then select one of these substrings and send it to the ... int nPtr=0; ... static buff* pad=new buff; ...
    (microsoft.public.vc.mfc)
  • Problem in correct performance of calling a dialog in a DLL(Window
    ... I use VC++ 2008 and have two part in my project(First part: my dll project ... “Select Reader” and then select one of these substrings and send it to the ... int nPtr=0; ... static buff* pad=new buff; ...
    (microsoft.public.dotnet.languages.vc)
  • Problem in correct performance of calling a dialog in a DLL(Window
    ... I use VC++ 2008 and have two part in my project(First part: my dll project ... “Select Reader” and then select one of these substrings and send it to the ... int nPtr=0; ... static buff* pad=new buff; ...
    (microsoft.public.vc.language)
  • Re: am having a problem with pinvoke and StringBuilder[ ]
    ... DLL: Hello from TestLib.dll ... Since the String class is immutable, I have used StringBuilder in my code ... public static extern int EnumerateBoards(ref int numBoards, ...
    (microsoft.public.dotnet.framework.clr)