Calling DLL Function inside Classic ASP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adincergok
    New Member
    • Dec 2014
    • 3

    Calling DLL Function inside Classic ASP

    Hello,
    I need to call .net dll function inside of classic asp.
    So i regsitered dll and tlb file with regasm.exe (and /codebase parameter). there is no problem.
    There is a sql databse and some table have image type data (inside has picture data). I want to send image data to dll function like a image or byte() type.

    my asp code part:
    =============== =============== =============== ============
    Code:
    Set jpg = Server.CreateObject("ad_jpeg.Jpeg")
    jpg.openBinary(rs("prev"))      'prev is sql 2008 image type
    
    my .net dll function
    =========================================================
        Public Function openBinary(ByVal gln As Object) As Boolean
            If gln Is Nothing Then
                lastError = "No binary data"
                Return False
            Else
                Try
                    Dim img As Image
                    Dim ms = New MemoryStream(CType(gln, Byte()))
                    img = Image.FromStream(ms)
                    If img IsNot Nothing Then
                        jpeg = img
                        Return True
                    Else
                        lastError = "Incoming data error"
                        Return False
                    End If
                Catch ex As Exception
                    lastError = "Incoming type of data : " & gln.GetType().ToString & vbCrLf & ex.ToString
                    Return False
                End Try
            End If
        End Function

    asp browse this error:
    Incoming type of data : System.__ComObj ect
    System.InvalidC astException: 'System.__ComOb ject' cannot assing byte type etc....
    Last edited by Rabbit; Dec 25 '14, 09:13 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • adincergok
    New Member
    • Dec 2014
    • 3

    #2
    I've solved myself successfully (I've try all data types)...

    My code here:
    =============== =============== =======
    Code:
        Public Function openBinary(ByVal gln As String) As Boolean
            If String.IsNullOrEmpty(gln) Then
                lastError = "No binary data"
                Return False
            Else
                Try
                    Dim array() As Byte = System.Text.Encoding.Unicode.GetBytes(gln)
                    Dim img As Image
                    Dim ms = New MemoryStream(array)
                    img = Image.FromStream(ms)
                    If img IsNot Nothing Then
                        jpeg = img
                        Return True
                    Else
                        lastError = "Incoming data error"
                        Return False
                    End If
                Catch ex As Exception
                    lastError = "Incoming type of data : " & gln.GetType().ToString & vbCrLf & ex.ToString
                    Return False
                End Try
            End If
        End Function
    Last edited by Rabbit; Dec 25 '14, 09:13 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.

    Comment

    Working...