473,395 Members | 1,658 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,395 software developers and data experts.

Passing Classic ASP Request.BinaryRead SafeArray to C# com interop component

skeptics
Trying to pass a SafeArray that i get form Request.BinaryRead Method in classic asp to a c# com interop component. In this thread i found a solution to pass and cast a normal asp safearray in to a c# array: http://bytes.com/groups/net/114755-p...to_threadtools

but no matter what i try. i cant pass a array that i get from Request.BinaryRead Method in to the component. i always get a error like this :
(0x80004003) Object reference not set to an instance of an object.

com
Expand|Select|Wrap|Line Numbers
  1.  
  2. namespace foo
  3. {
  4.     [Guid("AD627CAC-BC38-445b-8929-05B8315EBBCF")]
  5.     [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
  6.     public interface Ibar
  7.     {
  8.         [DispId(1)]
  9.         string errorMessage
  10.         {
  11.             get;
  12.         }
  13.  
  14.         [DispId(2)]
  15.         void readSafeArray(object[] safearray);
  16.  
  17.     }
  18.  
  19.     [Guid("003BC37A-888A-4bcd-A384-4D398AC85564")]
  20.     [ClassInterface(ClassInterfaceType.None)]
  21.     [ProgId("foo.cfoo")]
  22.     public class cfoo : Ibar
  23.     {
  24.  
  25.         private String _errorMessage;
  26.  
  27.         public cfoo()
  28.         {
  29.  
  30.         }
  31.  
  32.         public void readSafeArray(object[] safearray)
  33.         {
  34.             Array arr = (Array)safearray;
  35.  
  36.             _errorMessage += arr.Length.ToString();
  37.         }
  38.  
  39.  
  40.         public string errorMessage
  41.         {
  42.             get
  43.             {
  44.                 return _errorMessage;
  45.             }
  46.  
  47.         }
  48.  
  49.     }
  50. }
  51.  
  52.  
  53.  
Classic ASP code

Expand|Select|Wrap|Line Numbers
  1. <% 
  2.  
  3. Dim ff 
  4. Set ff = CreateObject("foo.cfoo")
  5.  
  6. Dim sar
  7.  
  8. 'this doesn't work
  9.  
  10. sar = Request.BinaryRead(Request.totalBytes)
  11. ff.readSafeArray(sar)
  12.  
  13.  
  14. Response.Write(ff.errorMessage)
  15.  
  16. 'this works
  17.  
  18. Dim arr(2) 
  19. arr(0) = CByte(1) 
  20. arr(1) = CByte(2)
  21. arr(2) = CByte(3)
  22.  
  23. ff.readSafeArray(arr)
  24.  
  25. Response.Write(ff.errorMessage)
  26.  
  27. %> 
  28.  
  29.  
can someone point me in the right direction please

thanks
Jul 3 '09 #1
0 3194

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

Similar topics

6
by: Patrick | last post by:
Following earlier discussions about invoking a .NET class library via ..NET-COM Interop (using regasm /tlb) at...
2
by: F. Nolet | last post by:
Hi, With IIS 6 - ASP : I try to upload a file of 125,000,000 bytes. To do it, I use this code : Request.BinaryRead(Request.TotalBytes) I get this error :
2
by: Arpan | last post by:
Under what circumstances can Request.BinaryRead() be useful & when should it be used? Assume that the value of Request.Form("anyvalue") is "a" (without the quotes). The output of <%...
6
by: Karl Stankiewicz | last post by:
Does any know how to return a recordset object from COM+ component written in C# so that it can be used as a Recordset in classic ASP? I have the frame component written i'm just not sure what...
0
by: msnews.microsoft.com | last post by:
Hello folks, We really need to create an ATL component which can transfer array of bytes to C# client. The reason we had to do that so that plain VB client would still be able to use the same...
5
by: Tronster Hartley | last post by:
I've written an ATL 7.1 component and have a C# 1.1 client that is consuming it. The ATL component has a method with a that returns a SAFEARRAY of INTs, but my C# component chokes on it. The...
3
by: Mark | last post by:
Hi From what I understand, you can pass arrays from classic ASP to .NET using interop, but you have to change the type of the.NET parameter to object. This seems to be because classic ASP passes...
1
by: Brendan Grant | last post by:
I’ve got a C# library that I’ve built into a COM component that will be used from a VC++ 6 application and while the creation of the COM object side of things seem to be working fine, using the...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.