1. Sudarsan Dash
  2. PowerBuilder
  3. Friday, 22 June 2018 19:05 PM UTC

When I tries to create a 

appeondotnetcomponent myComCaller 

I am getting  appeondotnetcomponent as illegal datatype. Please hep to how it will work

I am using PB 2017 R2

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 22 June 2018 19:13 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Sudarsan;

       Just make sure that you add the Appeon_WorkArounds.PBL to your application's Target library list. You should be able to locate this library in the "C:\inetpub\wwwroot\appeon\developTempFile\appeon_workarounds" folder. Then the Class assignment should work properly.

HTH

Regards ... Chris

Comment
  1. Sudarsan Dash
  2. Wednesday, 27 June 2018 09:49 AM UTC
Hi Chris,



Thanks, for your awesome answer. I ran into another problem. I had my class and the dll is in the target folder. But when I tries to call the functions I am not able to get the result.



My .Net Class



Imports System.IO

Imports System.Text.RegularExpressions



Public Class TelsFileProcessor



    Public Function GetNumRecordsSynchronous(ByVal filePath As String) As Integer

        Dim numRecords As Integer = 0

        Dim regex As New Regex("(\bNUMBER\b)(\s*)(=)(\s*)(')(\s*)(\d+)(\s*)(')")



        Using reader As New StreamReader(filePath)

            'count lines until we find [TRAILER]

            Dim line As String = reader.ReadLine()

            While Not line Is Nothing

                If 0 = String.CompareOrdinal(line.Trim(), "[TRAILER]") Then

                    Exit While

                End If

                numRecords += 1

                line = reader.ReadLine()

            End While



            'look for line with the following pattern: NUMBER = ' 12345 '

            line = reader.ReadLine()

            While Not line Is Nothing

                Dim matches = regex.Matches(line)

                If matches.Count = 1 Then

                    If Convert.ToInt32(matches(0).Groups.Item(7).Value) = numRecords Then

                        Return numRecords

                    Else

                        Return -1

                    End If

                End If

                line = reader.ReadLine()

            End While

        End Using

        Return -1

    End Function



   Please help me in resolving the error.



    Public Sub CopyRecordsSynchronous(ByVal srcFilePath As String, ByVal dstFilePath As String)

        If File.Exists(dstFilePath) Then

            File.Delete(dstFilePath)

        End If

        Dim recordCount As Integer = GetNumRecordsSynchronous(srcFilePath)

        Using reader As New StreamReader(srcFilePath)

            Using writer As New StreamWriter(dstFilePath)

                For i As Integer = 1 To recordCount

                    Dim line = reader.ReadLine()

                    writer.WriteLine(line)

                Next

            End Using

        End Using

    End Sub



End Class



My Powerbuilder Code:



// Define Variables



long lRet



int iResult



string strError



appeondotnetcomponent comcaller



 



 



//create appeondotnetcomponent instance and set properties



 



comcaller = create appeondotnetcomponent



comcaller.componenttype = '1'



comcaller.typelib = 'Utility.dll'



comcaller.classdescript = 'TelsFileProcessor'



any paramlist[]



 



paramlist[1] = as_destination_file



paramlist[2] = as_insert_file



 



 



//invoke component method



 



lRet = comcaller.of_execinterface("CopyRecordsSynchronous" , paramlist)



 



if Integer(lRet) = 0 then



iResult = comcaller.ReturnValue



 



else



 



strError = comcaller.ErrorText



MessageBox("Error",strError)



end if



 



My file Copy is not working.



 

  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 27 June 2018 20:36 PM UTC
Hi Sudarsan;



  Did you get a chance to trace what is happening in your .NET component when its called via the "of_execinterface" method?



Regards ... Chris

  1. Helpful
  1. Sudarsan Dash
  2. Thursday, 28 June 2018 08:38 AM UTC
Hi Chris,



My Code works with OLE one as below:



// Calling the .Net COM Component for File Copy

OLEObject fileProcessor

fileProcessor = CREATE OLEObject

fileProcessor.ConnectToNewObject("Utility.TelsFileProcessor")

 lb_ret = fileProcessor.CopyRecordsSynchronous(this.is_samin_destination_files, this.is_samin_insert_files)

DESTROY fileProcessor



 

  1. Helpful
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.