<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: PowerBuilder - Error calling an external function in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaa-p/458062#M71943</link>
    <description>&lt;P&gt;A .Net DLL can only be used by a .Net application unless it is exposed as COM. To use a COM DLL from PowerBuilder you need to use the ConnectToNewObject function to establish an OLEObject variable. See the excellent article on pbdj linked above for more detail.&lt;/P&gt;&lt;P&gt;Alternately you could abandon the .Net DLL entirely and call the encryption functions directly. I have two different sample apps:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.topwizprogramming.com/freecode_cryptoapi.html" target="test_blank"&gt;http://www.topwizprogramming.com/freecode_cryptoapi.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.topwizprogramming.com/freecode_bcrypt.html" target="test_blank"&gt;http://www.topwizprogramming.com/freecode_bcrypt.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Apr 2017 16:47:52 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2017-04-07T16:47:52Z</dc:date>
    <item>
      <title>PowerBuilder - Error calling an external function</title>
      <link>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaq-p/458057</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to call a function located in a DLL that was developed for us. When I try to run the script it is showing me the following error: "Error opening DLL library Encryption.dll for external function at line ....... ".  &lt;/P&gt;&lt;P&gt;How I am defining the External functions on PowerBuilder?&lt;/P&gt;&lt;P&gt;    Function string EncryptStringAES &amp;amp;&lt;BR /&gt;     (string  plainText, &amp;amp;&lt;BR /&gt;      string sharedSecret &amp;amp;&lt;BR /&gt;     ) Library "Encryption.dll" Alias For "EncryptStringAES"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;    Function string DecryptStringAES &amp;amp;&lt;BR /&gt;     (string  cipherText, &amp;amp;&lt;BR /&gt;      string sharedSecret &amp;amp;&lt;BR /&gt;     ) Library "Encryption.dll" Alias For "DecryptStringAES"&lt;/P&gt;&lt;P&gt;How they are in the DLL ? &lt;/P&gt;&lt;P&gt;The class name is Crypto, and it is in the Encryption
namespace.&lt;/P&gt;&lt;P&gt;      public  static string EncryptStringAES(string plainText, string sharedSecret)&lt;/P&gt;&lt;P&gt;      public static string DecryptStringAES(string cipherText, string sharedSecret)&lt;/P&gt;&lt;P&gt;I am using PB 10.2.1 , for now!&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 20:37:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaq-p/458057</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-04-06T20:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBuilder - Error calling an external function</title>
      <link>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaa-p/458058#M71939</link>
      <description>&lt;P&gt;Hi Luis;&lt;/P&gt;&lt;P&gt;   If your DLL developer did not create the DLL as per Unicode specifications - as is PB 10.x - you might need to add the following to the external declaration, as follows ....&lt;/P&gt;&lt;P&gt; Function string EncryptStringAES &amp;amp;&lt;BR /&gt; (string plainText, &amp;amp;&lt;BR /&gt; string sharedSecret &amp;amp;&lt;BR /&gt; ) Library "Encryption.dll" Alias For "EncryptStringAES&lt;STRONG&gt;;ansi&lt;/STRONG&gt;"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; Function string DecryptStringAES &amp;amp;&lt;BR /&gt; (string cipherText, &amp;amp;&lt;BR /&gt; string sharedSecret &amp;amp;&lt;BR /&gt; ) Library "Encryption.dll" Alias For "DecryptStringAES&lt;STRONG&gt;;ansi&lt;/STRONG&gt;"&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;Regards ... Chris&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 21:51:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaa-p/458058#M71939</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-04-06T21:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBuilder - Error calling an external function</title>
      <link>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaa-p/458059#M71940</link>
      <description>&lt;P&gt;Chris, thanks for your answer. &lt;/P&gt;&lt;P&gt;The developer is not sure about the Unicode specifications, but as you said I added the &lt;STRONG&gt;;ansi&lt;/STRONG&gt; keyword on both, and I still have the same problem.  &lt;/P&gt;&lt;P&gt;Luis.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 21:59:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaa-p/458059#M71940</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-04-06T21:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBuilder - Error calling an external function</title>
      <link>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaa-p/458060#M71941</link>
      <description>&lt;P&gt;Another way to show my issue:&lt;/P&gt;&lt;P&gt; --------------------------------------------&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;The dll was built on the .NET 2.0 and 4.0 Framework trying to identify the issue.&lt;/P&gt;&lt;P&gt; ---&lt;/P&gt;&lt;P&gt;using System;&lt;/P&gt;&lt;P&gt;using System.Collections.Generic;&lt;/P&gt;&lt;P&gt;using System.Text;&lt;/P&gt;&lt;P&gt;namespace Test&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;publicclassClass1&lt;/P&gt;&lt;P&gt; 
{&lt;/P&gt;&lt;P&gt;publicstring HelloWorld()&lt;/P&gt;&lt;P&gt; 
{&lt;/P&gt;&lt;P&gt;return"Hello";&lt;/P&gt;&lt;P&gt; 
}&lt;/P&gt;&lt;P&gt;publicstring HelloWorld2(string test)&lt;/P&gt;&lt;P&gt; 
{&lt;/P&gt;&lt;P&gt;return test;&lt;/P&gt;&lt;P&gt; 
}&lt;/P&gt;&lt;P&gt;publicvoid HelloWorld3(string test1, outstring test2 )&lt;/P&gt;&lt;P&gt; 
{&lt;/P&gt;&lt;P&gt; 
test2 = test1;&lt;/P&gt;&lt;P&gt; 
}&lt;/P&gt;&lt;P&gt; 
}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt; -----------------------------------------&lt;/P&gt;&lt;P&gt; Local external Function definition:&lt;/P&gt;&lt;P&gt;Function string HelloWorld2 &amp;amp;&lt;BR /&gt; (string test &amp;amp;&lt;BR /&gt; ) Library "Test.dll" Alias For "HelloWorld2;ansi"&lt;/P&gt;&lt;P&gt; -----------------------------------------&lt;/P&gt;&lt;P&gt;Calling the external function:&lt;/P&gt;&lt;P&gt;String ls_value, ls_returned&lt;/P&gt;&lt;P&gt;ls_value = Trim(sle_source.text)&lt;/P&gt;&lt;P&gt;ls_returned = HelloWorld2(ls_value)&lt;/P&gt;&lt;P&gt;IF Not IsNull(ls_returned) THEN&lt;BR /&gt; sle_encrypted.text = ls_returned&lt;BR /&gt;END IF&lt;/P&gt;&lt;P&gt;-----------------------------------------&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 03:35:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaa-p/458060#M71941</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-04-07T03:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBuilder - Error calling an external function</title>
      <link>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaa-p/458061#M71942</link>
      <description>&lt;P&gt;I think you have a .NET assembly and not a normal dynamic link library. The file extension for an assembly is .DLL but it is not a real Windows DLL! So you can't use it this way.&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.asp.net/t/1536669.aspx?Difference+between+normal+DLL+net+DLL" target="test_blank"&gt;https://forums.asp.net/t/1536669.aspx?Difference+between+normal+DLL+net+DLL&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You may use the assembly as a COM object.&lt;/P&gt;&lt;P&gt;&lt;A href="http://pbdj.sys-con.com/node/1668463" target="test_blank"&gt;http://pbdj.sys-con.com/node/1668463&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 06:25:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaa-p/458061#M71942</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-04-07T06:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBuilder - Error calling an external function</title>
      <link>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaa-p/458062#M71943</link>
      <description>&lt;P&gt;A .Net DLL can only be used by a .Net application unless it is exposed as COM. To use a COM DLL from PowerBuilder you need to use the ConnectToNewObject function to establish an OLEObject variable. See the excellent article on pbdj linked above for more detail.&lt;/P&gt;&lt;P&gt;Alternately you could abandon the .Net DLL entirely and call the encryption functions directly. I have two different sample apps:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.topwizprogramming.com/freecode_cryptoapi.html" target="test_blank"&gt;http://www.topwizprogramming.com/freecode_cryptoapi.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.topwizprogramming.com/freecode_bcrypt.html" target="test_blank"&gt;http://www.topwizprogramming.com/freecode_bcrypt.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 16:47:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaa-p/458062#M71943</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-04-07T16:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBuilder - Error calling an external function</title>
      <link>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaa-p/458063#M71944</link>
      <description>&lt;P&gt;Thanks everyone for your comments, they were very helpful for me.&lt;/P&gt;&lt;P&gt; For now we will use a third party DLL for the encryption process. Your information will help me when we migrate to PB 12.6 in a couple of months. &lt;/P&gt;&lt;P&gt;Thanks!!! &lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 14:29:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/powerbuilder-error-calling-an-external-function/qaa-p/458063#M71944</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-04-14T14:29:47Z</dc:date>
    </item>
  </channel>
</rss>

