T
Tony Liu
Dear All:
I create a very simple DLL by using EVC to test the problem. (The platform I
am working for those program is WinCE.NET)
*******************************************************
The header looks like:
#ifdef TESTDLL_EXPORTS
#define TESTDLL_API __declspec(dllexport)
#else
#define TESTDLL_API __declspec(dllimport)
#endif
TESTDLL_API LONG fnTestF(FLOAT var1);
*******************************************************
The C source looks like:
#include "stdafx.h"
#include "TestDll.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
TESTDLL_API LONG fnTestF(FLOAT var1)
{
return 0;
}
*******************************************************
The DEF file look like:
LIBRARY TestDll
EXPORTS
fnTestF
*******************************************************
After build up this DLL, I try to write a C# program to call this function.
The C# program looks like:
[DllImport("testdll.dll")]
private static extern Int32 fnTestF
(
Single fPeriod
);
When I call this function likes bellow:
Single fVal = 0.1f;
Int32 i32Ret;
try
{
i32Ret = fnTestF(fVal);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Exception!");
}
I always get an exception called "NotSupportedException".
Any idea about this?
Thanks!
Tony Liu
I create a very simple DLL by using EVC to test the problem. (The platform I
am working for those program is WinCE.NET)
*******************************************************
The header looks like:
#ifdef TESTDLL_EXPORTS
#define TESTDLL_API __declspec(dllexport)
#else
#define TESTDLL_API __declspec(dllimport)
#endif
TESTDLL_API LONG fnTestF(FLOAT var1);
*******************************************************
The C source looks like:
#include "stdafx.h"
#include "TestDll.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
TESTDLL_API LONG fnTestF(FLOAT var1)
{
return 0;
}
*******************************************************
The DEF file look like:
LIBRARY TestDll
EXPORTS
fnTestF
*******************************************************
After build up this DLL, I try to write a C# program to call this function.
The C# program looks like:
[DllImport("testdll.dll")]
private static extern Int32 fnTestF
(
Single fPeriod
);
When I call this function likes bellow:
Single fVal = 0.1f;
Int32 i32Ret;
try
{
i32Ret = fnTestF(fVal);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Exception!");
}
I always get an exception called "NotSupportedException".
Any idea about this?
Thanks!
Tony Liu