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

  • Question

  • 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: [url]http://bytes.com/groups/net/114755-passing-safearray-bytes-vbscript-managed-com-object-c#goto_threadtools[/url]

    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.

    component

    namespace foo
    {
        [Guid("AD627CAC-BC38-445b-8929-05B8315EBBCF")]
        [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
        public interface Ibar
        {
            [DispId(1)]
            string errorMessage
            {
                get;
            }
    
            [DispId(2)]
            void readSafeArray(object[] safearray);
    
        }
    
        [Guid("003BC37A-888A-4bcd-A384-4D398AC85564")]
        [ClassInterface(ClassInterfaceType.None)]
        [ProgId("foo.cfoo")]
        public class cfoo : Ibar
        {
    
            private String _errorMessage;
    
            public cfoo()
            {
               
            }
    
            public void readSafeArray(object[] safearray)
            {
                Array arr = (Array)safearray;
    
                _errorMessage += arr.Length.ToString();
            }
    
    
            public string errorMessage
            {
                get
                {
                    return _errorMessage;
                }
    
            }
    
        }
    }


    Classic ASP code

    Dim ff
    Set ff = CreateObject("foo.cfoo")
    
    Dim sar
    
    'this doesn't work
    
    sar = Request.BinaryRead(Request.totalBytes)
    ff.readSafeArray(sar)
    
    
    Response.Write(ff.errorMessage)
    
    'this works
    
    Dim arr(2)
    arr(0) = CByte(1)
    arr(1) = CByte(2)
    arr(2) = CByte(3)
    
    ff.readSafeArray(arr)
    
    Response.Write(ff.errorMessage)

    can someone point me in the right direction please

    thanks
    Friday, July 3, 2009 5:50 PM

Answers

All replies