problem in using exported function in a native DLL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vijay

    #1

    problem in using exported function in a native DLL

    I'm having trouble with calling an exported function in a
    native DLL compiled with eMbedded Visual C++ using C#.

    Basicly, I have one exported function in the DLL:
    whenever i execute this exe to Pocket pc it returns
    MissingMethod Exception.

    Code for DLL is
    NativeFunctions .h

    #ifdef NATIVEDLL_EXPOR TS
    #define DLLEXPORT _declspec(dllex port)
    #else
    #define DLLEXPORT _declspec(dllim port)
    #endif
    #ifdef __cplusplus
    extern "C" {
    #endif
    DLLEXPORT int function();
    #ifdef __cplusplus
    }//end extern "C"
    #endif
    NativeFunction. cpp

    #include "stdafx.h"
    #include "NativeFunction s.h"
    int function()
    {
    return 25;
    }

    and a C# client of the DLL:

    using System;
    using System.Data;
    using System.Runtime. InteropServices ;

    namespace Client
    {
    class Class1
    {
    [ DllImport("Nati veFunction.dll" , EntryPoint="fun ction") ]
    public static extern int function();

    static void Main(string[] args)
    {
    int x = function();
    MessageBox.Show (x.toString());
    }
    }
    }


  • Mattias Sjögren

    #2
    Re: problem in using exported function in a native DLL

    [color=blue]
    >Basicly, I have one exported function in the DLL:
    >whenever i execute this exe to Pocket pc it returns
    >MissingMetho d Exception.[/color]

    It's probably exported with a decorated (mangled) name. Try running

    dumpbin /exports NativeFunction. dll

    and see what the real exported name is.



    Mattias

    --
    Mattias Sjögren [MVP] mattias @ mvps.org

    Please reply only to the newsgroup.

    Comment

    Working...