Connecting Tech Pros Worldwide Forums | Help | Site Map

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

skeptics's Avatar
Newbie
 
Join Date: Jul 2009
Posts: 1
#1: Jul 3 '09
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

Reply