0

Hi sir,


I am making a win32 dll in VC++.NET 2005. I make an add funtion in it and then i call it from C# using System.Runtime.InteropServices;

[DllImport("MXFWrapperMarvel.dll", EntryPoint = "add")]
static extern int add(int a, int b);

----------------------MXFWrapperMarvel.dll------------without header files---------------
#include "stdafx.h"
#include <AtlConv.h>

#ifdef _MANAGED
#pragma managed(push, off)
#endif

extern "C" __declspec(dllexport) int APIENTRY add(int a, int b)
{
    return a+b;
}


BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
    return TRUE;
}

#ifdef _MANAGED
#pragma managed(pop)
#endif
-------------------------------------------------------------------------------------------------

this add function working correctly.


But I want to include some header files of third party SDK.

---------------------MXFWrapperMarvel.dll-------------with header files-------------------

#include "stdafx.h"
#include <AtlConv.h>


#include "MOG/MXFComponents/EssenceAnalyzer/MPEG/EssenceTypes.h"
#include "MOG/MXFComponents/EssenceAnalyzer/AES3/EssenceTypes.h"
#include "MOG/MXFComponents/EssenceAnalyzer/BWave/EssenceTypes.h"
#include "MOG/MXFComponents/EssenceAnalyzer/AES3/S302M/EssenceTypes.h"

#ifdef _MANAGED
#pragma managed(push, off)
#endif

extern "C" __declspec(dllexport) int APIENTRY add(int a, int b)
{
    return a+b;
}


BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
    return TRUE;
}

#ifdef _MANAGED
#pragma managed(pop)
#endif

--------------------------------------------------------------------------------------------------

My code is compiled successfully, no errors and warnings. But when calling the add() function then, a runtime exception is raising while calling add() fuction...

"Unable to load DLL 'MXFWrapperMarvel.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"

The dll is also placed on the right path but still raising exception. If I remove the above header files from dll code then my code also compiled successfully as well as add() function is also functioning correctly. But after just including those header files in dll code, it is compiled successfully but raised the above exception at runtime while calling add() function and my code jumps to the catch block .

Please guide me how can I resolve this problem.

--
Regards,
Asif

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by cikara21
0
//...maybe this impl. can help

[DllImport("./MXFWrapperMarvel.dll", EntryPoint = "add")]
static extern int APIENTRY add(int a, int b);
//...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.