NotSupported Exception when calling third party dll

Hi all,

I am using VB.NET and VS 2003 for PocketPC application development.

I am trying to use third party dll from my application. I am using P-invoke to call function but I am getting "NotSupported" Exception.

I have checked signature properly. That should not be the problem.

I don't have source code of this dll and also don't know which platform was used to build it.

Also I have copied third party dll in both current folder and windows folder of the device but still getting this error.

Please help me.

Thanks,

Viral



Answer this question

NotSupported Exception when calling third party dll

  • Game Squirrel

    it could simply be that whatever CF functionality the program looks for isn't supported by your platform. is it media related I've seen a lot of unsupported exceptions with multimedia API stuff, but there's a lot of OEM-specific gaps in CF implementation you have to look out for.
  • Bdenison

    Hi,

    Thanks for your reply.

    I am using following code:

    I have declared function in following way.

    'BOOL WINAPI THIRDPARTYMETHOD(LPTSTR szPath)

    <DllImport("THIRDPARTYDLL.dll")> _

    Private Shared Function THIRDPARTYMETHOD(ByRef Path As String) As Boolean

    End Function

    I am calling it in following way.

    Private Sub btnCall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCall.Click

    THIRDPARTYMETHOD("\Program files\MyProgram\Program.exe")

    End Sub

    Would you please help me in finding whats wrong with this code

    Thanks in advance,

    Viral


  • Solomonsd21

    Hi Ilya,

    Thanks for your reply. I have solved above problem. I have one more query. When I try to call function which takes arguments as double, I get "NotSupportedException". According to following article, we can't pass double type as value to core function.

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnnetcomp/html/netcfmarshallingtypes.asp

    "Long types (64-bit integer) and floating-point types (float and double) cannot be marshaled by value into unmanaged code. You should pass these values by reference."

    As I don't have source code I can't do the suggested changes. So what should be the solution Does Compact Framework 2.0 support this

    Please help me.

    Thanks in advance.

    Viral


  • blackwidow25

    Hi

    I want to call a native function which takes POINT structure of "C" by reference.

    I am passing object of System.drawing.Point structure's object by reference. I am getting exception like 0x0000005.

    May be because POINT structure of C has long members and CLR can't marshal long and floating point types

    Can't I do that

    What is alternative

    Please help me.

    Viral


  • Ramachandran.d

    Just to close the chapter - the problem here must be with passing a string ByRef. Reference types cannot be passed by reference

  • flep

    You need to post both native and managed definition that you are using

  • BAnVA

    There are two issues with that:

    1. VB Boolean (16 bit in size) and C++ BOOL (32 bit) are not the same, so BOOL should be declared as Integer (32 bit) on VB side.

    2. LPTSTR can be Unicode or it can be ASCII, depends on how DLL was compiled. If it’s Unicode, passing string is OK. If it’s ASCII, you have to convert string to array of bytes in ASCII encoding and pass that.

    Note neither issue should cause the exception you see.



  • recordus

    NETCF V1 does not support marshaling of some types to native code hence the exception. I can't tell what exactly is not supported in your case since you posted no code. That might be value type of more than 32 bits in size passed by value, structure with nested strings, function pointer and more. This article might be of help:

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnnetcomp/html/netcfadvinterop.asp



  • NotSupported Exception when calling third party dll