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
-
-
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