0% found this document useful (0 votes)
197 views

Calling DLL Function Inside Classic ASP

The document discusses calling a .NET DLL function from classic ASP and passing image data to it. The OP was getting an error casting the image data to a byte array. In the response, they share the code they used to successfully pass the image data as a string by encoding it to bytes.

Uploaded by

synergicx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
197 views

Calling DLL Function Inside Classic ASP

The document discusses calling a .NET DLL function from classic ASP and passing image data to it. The OP was getting an error casting the image data to a byte array. In the response, they share the code they used to successfully pass the image data as a string by encoding it to bytes.

Uploaded by

synergicx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

472,081 Members Sign in Join

Post +

Home Posts Topics Members

home > topics > asp / active server pages > questions > calling dll function inside classic asp

Join Bytes to post your question to a community of 472,081 software developers and data experts.

Calling DLL Function inside Classic ASP


adincergok
3

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:


================================================== =======

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.ToStrin
                Return False
            End Try
        End If

asp browse this error:


Incoming type of data : System.__ComObject
System.InvalidCastException: 'System.__ComObject' cannot assing byte type etc....

Dec 25 '14 #1

Follow Post Reply

✓ answered by adincergok
I've solved myself successfully (I've try all data types)...

My code here:
=====================================
    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.ToStr
                Return False
            End Try
        End If
    End Function

1 3994

Tchibo Black 'N White 10'lu Tchibo Espresso Vanilya Tchibo Matara Taşıma Tchibo Caffè Crema Rich Tchibo Ofis Malzemeleri
Kapsül Kahve 10'lu Kapsül Kahve Çantası, Lacivert Aroma 10'lu Kapsül Kahve Dosyası

59,90 TL 64,90 TL 219 TL 59,90 TL 289 TL

adincergok
3

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

My code here:
=====================================
    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

Dec 25 '14 #2

reply

Post your reply

Sign in to post your reply or Sign up for a free account.

Post Reply

Similar topics

newbe question: calling function inside select Microsoft SQL


4 posts views Thread by Mario Pranjic | last post: by Server

Pointer to Function Inside Struct using Static C / C++


1 post views Thread by Bryan Parkoff | last post: by

Adding a function INSIDE a quoted text element .NET Framework


3 posts views Thread by darrel | last post: by

Addin calling function in Parent Microsoft Access /


6 posts views Thread by jchao123 | last post: by VBA

Calling function name C / C++


16 posts views Thread by Saroj | last post: by

Calling a Function inside the SendMail PHP


2 posts views Thread by Syl | last post: by

returning control back to calling function Python


2 posts views Thread by sumanthsclsdc | last post: by
Print function name of calling function? C / C++
15 posts views Thread by dspfun | last post: by

Calling C# function inside VB.NET project .NET Framework


4 posts views Thread by MasterVision | last post: by

Calling a function inside another function doesn't seem to work anymore with mysqli PHP
1 post views Thread by guy13 | last post: by

Next meeting for Access User Groups - Europe Microsoft Access /


3 posts views Thread by isladogs | last post: by VBA

Next Meeting for Access Lunchtime User Group Microsoft Access /


reply views Thread by isladogs | last post: by VBA

What Makes Product Development Lean? Software


1 post views Thread by beacampos | last post: by Development

How PDDON's online drawing surprised you? Web Applications


reply views Thread by pddon | last post: by

create a game with ps3 style graphics by myself, is it possible? how can I do it? General
reply views Thread by BenitoJuares | last post: by

How do we call a function with parameters and use output returning true/false in php? PHP
reply views Thread by bakertaylor28 | last post: by

Forrester: Four Digital Intelligence Products of AsiaInfo Included in China Data Governance Ecology Report General
reply views Thread by antdb | last post: by

Group serial number Microsoft Access /


2 posts views Thread by Bright1Light | last post: by VBA

How to create a custom shortcut menu command Microsoft Access /


7 posts views Thread by bounthong | last post: by VBA

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.

BYTES.COM © 2023
About Bytes
Advertise Follow us! Get the Latest Bytes Updates
Terms Of Use
Privacy Policy
Contact Us
Sitemap

You might also like