<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[c++ dll in vb.net: Parameter (datentypen) Probleme!]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe folgende einfache c++ dll:</p>
<pre><code class="language-cpp">extern &quot;C&quot; __declspec(dllexport) __int64 _stdcall XArCAPIFunc(char* xml, __int64 Zahl1, __int64 Zahl2, __int64 Zahl3)
{
	return Zahl1 + Zahl2;
}
</code></pre>
<p>In einer <a href="http://VB.net" rel="nofollow">VB.net</a> Konsolenanwendung rufe ich diese wie folgt auf:</p>
<pre><code>Module Module1
    Private Declare Function Funktion Lib &quot;C:\Dokumente und Einstellungen\xxx\Desktop\test\C PLUS PLUS\dllVersuch\Debug\dllVersuch.dll&quot; Alias &quot;_Funktion@28&quot; (ByVal xml As String, ByRef Zahl1 As Long, ByRef Zahl2 As Long, ByVal Zahl3 As Long) As Long

    Sub Main()
        Console.WriteLine(Funktion(&quot;test&quot;, 1, 2, 3))
        Console.ReadLine()

    End Sub

End Module
</code></pre>
<p>Den Alias-Namen für die Funktion &quot;_Funktion@28&quot; habe ich via <em>dumpbin.exe /exports dllVersuch.dll</em> herausgefunden.<br />
Meine erste Frage: Warum funktioniert das so nicht? Normalerweise müsste meine Ausgabe doch sein: 3 (weil 1+2 = 3)...<br />
Stattdessen erhalte ich folgenden Fehler:</p>
<blockquote>
<p>Ein Aufruf an die PInvoke-Funktion &quot;TestKonsole1!TestKonsole1.Module1::Funktion&quot; hat das Gleichgewicht des Stapels gestört. Wahrscheinlich stimmt die verwaltete PInvoke-Signatur nicht mit der nicht verwalteten Zielsignatur überein. Überprüfen Sie, ob die Aufrufkonvention und die Parameter der PInvoke-Signatur mit der nicht verwalteten Zielsignatur übereinstimmen.</p>
</blockquote>
<p>Danke für eure Hilfe,</p>
<p>schnitzl0r</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/292589/c-dll-in-vb-net-parameter-datentypen-probleme</link><generator>RSS for Node</generator><lastBuildDate>Sun, 16 Aug 2026 20:57:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/292589.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 13 Sep 2011 12:48:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to c++ dll in vb.net: Parameter (datentypen) Probleme! on Tue, 13 Sep 2011 13:02:16 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe folgende einfache c++ dll:</p>
<pre><code class="language-cpp">extern &quot;C&quot; __declspec(dllexport) __int64 _stdcall XArCAPIFunc(char* xml, __int64 Zahl1, __int64 Zahl2, __int64 Zahl3)
{
	return Zahl1 + Zahl2;
}
</code></pre>
<p>In einer <a href="http://VB.net" rel="nofollow">VB.net</a> Konsolenanwendung rufe ich diese wie folgt auf:</p>
<pre><code>Module Module1
    Private Declare Function Funktion Lib &quot;C:\Dokumente und Einstellungen\xxx\Desktop\test\C PLUS PLUS\dllVersuch\Debug\dllVersuch.dll&quot; Alias &quot;_Funktion@28&quot; (ByVal xml As String, ByRef Zahl1 As Long, ByRef Zahl2 As Long, ByVal Zahl3 As Long) As Long

    Sub Main()
        Console.WriteLine(Funktion(&quot;test&quot;, 1, 2, 3))
        Console.ReadLine()

    End Sub

End Module
</code></pre>
<p>Den Alias-Namen für die Funktion &quot;_Funktion@28&quot; habe ich via <em>dumpbin.exe /exports dllVersuch.dll</em> herausgefunden.<br />
Meine erste Frage: Warum funktioniert das so nicht? Normalerweise müsste meine Ausgabe doch sein: 3 (weil 1+2 = 3)...<br />
Stattdessen erhalte ich folgenden Fehler:</p>
<blockquote>
<p>Ein Aufruf an die PInvoke-Funktion &quot;TestKonsole1!TestKonsole1.Module1::Funktion&quot; hat das Gleichgewicht des Stapels gestört. Wahrscheinlich stimmt die verwaltete PInvoke-Signatur nicht mit der nicht verwalteten Zielsignatur überein. Überprüfen Sie, ob die Aufrufkonvention und die Parameter der PInvoke-Signatur mit der nicht verwalteten Zielsignatur übereinstimmen.</p>
</blockquote>
<p>Danke für eure Hilfe,</p>
<p>schnitzl0r</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2118705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2118705</guid><dc:creator><![CDATA[cRz_-]]></dc:creator><pubDate>Tue, 13 Sep 2011 13:02:16 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dll in vb.net: Parameter (datentypen) Probleme! on Tue, 13 Sep 2011 12:59:00 GMT]]></title><description><![CDATA[<p>Funktion nimmt zwei Parameter, Du importierst sie aber mit vier Parametern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2118713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2118713</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Tue, 13 Sep 2011 12:59:00 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dll in vb.net: Parameter (datentypen) Probleme! on Tue, 13 Sep 2011 13:02:47 GMT]]></title><description><![CDATA[<p>LordJaxom schrieb:</p>
<blockquote>
<p>Funktion nimmt zwei Parameter, Du importierst sie aber mit vier Parametern.</p>
</blockquote>
<p>Sorry, war falsch kopiert. Ist editiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2118716</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2118716</guid><dc:creator><![CDATA[cRz_-]]></dc:creator><pubDate>Tue, 13 Sep 2011 13:02:47 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dll in vb.net: Parameter (datentypen) Probleme! on Tue, 13 Sep 2011 13:03:55 GMT]]></title><description><![CDATA[<p>In deiner C++-Funktion hast du 2 Parameter vom Typ __int64 bzw. Quadword. In deiner VB-Funktions-Dekleration hast du 1 Parameter vom verwalteten Typ System.String und 3 vom Typ Long. Fällt dir was auf?</p>
<p>edit: Mist, einer war schneller <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2118717</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2118717</guid><dc:creator><![CDATA[Jonas OSDever]]></dc:creator><pubDate>Tue, 13 Sep 2011 13:03:55 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dll in vb.net: Parameter (datentypen) Probleme! on Tue, 13 Sep 2011 13:12:44 GMT]]></title><description><![CDATA[<p>Du konvertierst System.String in char*. Wenn dann musst du Über System.Text.Encoding.irgendwas deinen System.String in ein Byte-Array konvertieren. Weiß jetzt aber grade nicht wie du das mit dem Zeiger hinkriegst.</p>
<p>edit: Ach ja, wenn du den String weiterverarbeiten willst denk dran das .NET Unicode benutzt und char für ASCII Zeichen ausgelegt ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2118722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2118722</guid><dc:creator><![CDATA[Jonas OSDever]]></dc:creator><pubDate>Tue, 13 Sep 2011 13:12:44 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dll in vb.net: Parameter (datentypen) Probleme! on Tue, 13 Sep 2011 13:57:52 GMT]]></title><description><![CDATA[<p>das verstehe ich nicht so ganz?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2118746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2118746</guid><dc:creator><![CDATA[cRz_-]]></dc:creator><pubDate>Tue, 13 Sep 2011 13:57:52 GMT</pubDate></item></channel></rss>