Results 1 to 10 of 10
Thread: PInvokeimbalance (C#, SDK 3)
-
29-08-2011, 13:10 #1
-= TeamSpeak User =-
- Join Date
- Feb 2010
- Location
- Germany
- Posts
- 11
PInvokeimbalance (C#, SDK 3)
Hello
using the SDK simple client sample with C# and .net 4 on my Win7 64bit, but compiling it to x86 due to compatibility issues results me with a PInvokeImbalance error with this line:
which is defined here:Code:uint error = ts3client.ts3client_initClientLib(ref cbs, ref cbs_rare, LogTypes.LogType_CONSOLE, null, "");
Compiling it as x64 is working correctly. I would so far prefer the x86 way since not everyone is owning an x64 system yet ...Code:[DllImport("ts3client_win32.dll", EntryPoint = "ts3client_initClientLib")] public static extern uint ts3client_initClientLib(ref client_callback_struct arg0, ref client_callbackrare_struct arg1, LogTypes arg2, string arg4, string arg5);
Thank you for any hints
-
29-08-2011, 14:09 #2
-= TeamSpeak Team =-
- Join Date
- Jul 2002
- Location
- Germany
- Posts
- 2,836
Hi,
first off, I must confess I have zero knowledge of C#, but from searching "PInvokeImbalance" I found http://social.msdn.microsoft.com/For...-02b2324bfcd7/ which makes references about the calling convention being important. As the SDK docs say, the TS3 SDK uses cdecl calling convention (and not stdcall). I hope this helps.
-
29-08-2011, 15:18 #3
-= TeamSpeak User =-
- Join Date
- Dec 2009
- Location
- Frankfurt/Main
- Posts
- 15
There should be an ohter mistake in the Example. Also the callbacks in the csharp example are the old ones. Will it beeing updated?
-
29-08-2011, 15:41 #4
-= TeamSpeak User =-
- Join Date
- Feb 2010
- Location
- Germany
- Posts
- 11
That hint about the CallingConvention was fine. Thank you!
Now it stops with an "System.AccessViolationException - Trying to read/write protected memory." with this line:
I'd be happy if we can solve this toots3client.ts3client_startConnection(scHandlerID, identity, "127.0.0.1", 9987, "client", ref defaultarray, "", "secret");
-
30-08-2011, 07:54 #5
-
30-08-2011, 16:19 #6
-= TeamSpeak User =-
- Join Date
- Feb 2010
- Location
- Germany
- Posts
- 11
Thank you for trying to help.
For bad luck the site about the AccessViolation is not really pointing to what might cause that read/write error with x86 compilation. It works for x64 using the exactly same syntax.
The line
refers to this definition:ts3client.ts3client_startConnection(scHandlerID, identity, "127.0.0.1", 9987, "client", ref defaultarray, "", "secret");
and the identity and defaultarray are defined like this:[DllImport("ts3client_win64.dll", EntryPoint = "ts3client_startConnection", CharSet = CharSet.Ansi)]
public static extern uint ts3client_startConnection(uint64 arg0, string identity, string ip, uint port, string nick, ref string defaultchannelarray, string defaultchannelpassword, string serverpassword);
One of these seem to cause the accessviolation, but how to define them in another way ...?string identity = Marshal.PtrToStringAnsi(identityPtr);
string defaultarray = "";
I wonder, if the x86 version of the .DLL is working for anyone? I tested it also on a native 32bit Vista system with exactly the same error (Accessviolation) in the same line.
-
30-08-2011, 16:19 #7
-= TeamSpeak User =-
- Join Date
- Feb 2010
- Location
- Germany
- Posts
- 11
Thank you for trying to help.
For bad luck the site about the AccessViolation is not really pointing to what might cause that read/write error with x86 compilation in this case. It works for x64 using the exactly same syntax.
The line
refers to this definition:ts3client.ts3client_startConnection(scHandlerID, identity, "127.0.0.1", 9987, "client", ref defaultarray, "", "secret");
and the identity and defaultarray are defined like this:[DllImport("ts3client_win32.dll", EntryPoint = "ts3client_startConnection", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ts3client_startConnection(uint64 arg0, string identity, string ip, uint port, string nick, ref string defaultchannelarray, string defaultchannelpassword, string serverpassword);
One of these seem to cause the accessviolation, but how to define them in another way ...?string identity = Marshal.PtrToStringAnsi(identityPtr);
string defaultarray = "";
I wonder, if the x86 version of the .DLL is working for anyone? I tested it also on a native 32bit Vista system with exactly the same error (Accessviolation) in the same line.
-
30-08-2011, 16:37 #8
-= TeamSpeak User =-
- Join Date
- Aug 2011
- Posts
- 1
Hello everyone,
I have tested it on a Windows 7, 32bit System, using Visual C# 2010 Express, and I get the exact same error on the same line.
I've also tried to alter the two lines you mentioned, but with no success.
As we are stuck at the same point I can't really helo you, but I'm really interested in hearing any other ideas on what to do...
Valandur
EDIT:
Interesting is the fact that if you open the example solution for C# made by TeamSpeak then the default compile configuration is x64. This could mean that the TeamSpeak developers did not test the SDK on a 32bit System.
-
31-08-2011, 20:29 #9
-= TeamSpeak User =-
- Join Date
- Feb 2010
- Location
- Germany
- Posts
- 11
Hello again
so this is meaning, that the 32bit version of the dll is not working with managed code, right?
That's sad since this means you cannot code for a wider audience
Could any TeamSpeak official put some light into this matter (i.ex. confirming it is not working or bringing a fixed version or give us a hint on how to do it right or some other sign of life hehehe)?
Thank you
-
06-09-2011, 10:39 #10
-= TeamSpeak Team =-
- Join Date
- Jun 2008
- Location
- Krün, Germany
- Posts
- 464
For reference, the solution should be here: http://forum.teamspeak.com/showthrea...334#post295334
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)


Reply With Quote

