473,326 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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:
================================================== =======
Expand|Select|Wrap|Line Numbers
  1. Set jpg = Server.CreateObject("ad_jpeg.Jpeg")
  2. jpg.openBinary(rs("prev"))      'prev is sql 2008 image type
  3.  
  4. my .net dll function
  5. =========================================================
  6.     Public Function openBinary(ByVal gln As Object) As Boolean
  7.         If gln Is Nothing Then
  8.             lastError = "No binary data"
  9.             Return False
  10.         Else
  11.             Try
  12.                 Dim img As Image
  13.                 Dim ms = New MemoryStream(CType(gln, Byte()))
  14.                 img = Image.FromStream(ms)
  15.                 If img IsNot Nothing Then
  16.                     jpeg = img
  17.                     Return True
  18.                 Else
  19.                     lastError = "Incoming data error"
  20.                     Return False
  21.                 End If
  22.             Catch ex As Exception
  23.                 lastError = "Incoming type of data : " & gln.GetType().ToString & vbCrLf & ex.ToString
  24.                 Return False
  25.             End Try
  26.         End If
  27.     End Function

asp browse this error:
Incoming type of data : System.__ComObject
System.InvalidCastException: 'System.__ComObject' cannot assing byte type etc....
Dec 25 '14 #1

✓ answered by adincergok

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

My code here:
=====================================
Expand|Select|Wrap|Line Numbers
  1.     Public Function openBinary(ByVal gln As String) As Boolean
  2.         If String.IsNullOrEmpty(gln) Then
  3.             lastError = "No binary data"
  4.             Return False
  5.         Else
  6.             Try
  7.                 Dim array() As Byte = System.Text.Encoding.Unicode.GetBytes(gln)
  8.                 Dim img As Image
  9.                 Dim ms = New MemoryStream(array)
  10.                 img = Image.FromStream(ms)
  11.                 If img IsNot Nothing Then
  12.                     jpeg = img
  13.                     Return True
  14.                 Else
  15.                     lastError = "Incoming data error"
  16.                     Return False
  17.                 End If
  18.             Catch ex As Exception
  19.                 lastError = "Incoming type of data : " & gln.GetType().ToString & vbCrLf & ex.ToString
  20.                 Return False
  21.             End Try
  22.         End If
  23.     End Function

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

My code here:
=====================================
Expand|Select|Wrap|Line Numbers
  1.     Public Function openBinary(ByVal gln As String) As Boolean
  2.         If String.IsNullOrEmpty(gln) Then
  3.             lastError = "No binary data"
  4.             Return False
  5.         Else
  6.             Try
  7.                 Dim array() As Byte = System.Text.Encoding.Unicode.GetBytes(gln)
  8.                 Dim img As Image
  9.                 Dim ms = New MemoryStream(array)
  10.                 img = Image.FromStream(ms)
  11.                 If img IsNot Nothing Then
  12.                     jpeg = img
  13.                     Return True
  14.                 Else
  15.                     lastError = "Incoming data error"
  16.                     Return False
  17.                 End If
  18.             Catch ex As Exception
  19.                 lastError = "Incoming type of data : " & gln.GetType().ToString & vbCrLf & ex.ToString
  20.                 Return False
  21.             End Try
  22.         End If
  23.     End Function
Dec 25 '14 #2

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

Similar topics

4
by: Mario Pranjic | last post by:
Hi! I have a scalar function that returns integer: xview (int) Now, I'm trying to build a procedure that has the following select inside: select atr1, xview(atr2) from tablename
1
by: Bryan Parkoff | last post by:
I know how to write "Pointer to Function" inside struct or class without using static, but I have decided to add static to all functions inside struct or class because I want member functions to be...
3
by: darrel | last post by:
In my XSLT, I'm trying to write out some dynamic URLs. I can't put an actual xsl:value-of field inside a URL: <a href="<xsl:value-of select="linkUrl"/>"> But I can do this: <a...
6
by: jchao123 | last post by:
Dear All, I have an MDB file (Access 2000/XP) which contains generic routines I use in various apps (eg, API calls, File access classes etc). I have compiled into an MDE file which I reference...
16
by: Saroj | last post by:
Is there an way for a function to know who called him ?
2
by: Syl | last post by:
Hi Group - I have a function to send an email to a client after they have successfully submitted a form on my site. I have a 2nd function that prints their input to the browser as a confirmation....
2
by: sumanthsclsdc | last post by:
Hello friends, I have a problem, I implemented a class which uses tkinter and displays the window as required, the class will create a window with listbox and inserts some items into it, I...
15
by: dspfun | last post by:
Hi, Is it possible to print the function name of the calling function? For example, f1() and f2() both calls f3(), in f3() I would like to print the name of the function calling f3() which...
4
by: MasterVision | last post by:
Hey folks, I have .NET Solution with the combinations of VB, C/C++ and C# projects on it. I have no problem calling C/C++ function inside my VB project but I dont know how to do the same with C#...
1
by: guy13 | last post by:
Hi all, Need enlightenment about the following: I'm trying to adapt my php pages to mysqli. Everything seems to work after a few minor changes except a number of functions (as far as I can tell...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.