Groups | Blog | Home
all groups > dotnet interop > june 2004 >

dotnet interop : Calling C# COM from ASP script code


Patrick Ruhnow
6/29/2004 2:48:23 PM
Hi,

i have a managed COM component with an array as parameter like this:
public byte[] ProcessPdfDocument(string reportPath, string identifier,
string boType, string userName, bool storeDocument, string[] parameters)

Now i want to call this method out of an ASP Page (JScript) :

var bo = Server.CreateObject("DocumentProcessing.DocProcessor");
var theArray = new Array();//"12541", "de", "True");
theArray[0] = "12541";
theArray[1] = "de";
theArray[2] = "True";

var reportStream = bo.ProcessPdfDocument("/Offer/myOffer", "12541", "Offer",
"theUser", true, theArray)

Now the following error occours:
--------------------------------------
(0x800A0005)
Invalid procedure call or argument
-----------------------------------------

i tried also the MarshalAsAttribute like this:
public byte[] ProcessPdfDocument(string reportPath, string identifier,
string boType, string userName, bool storeDocument,

[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_BSTR)]
string[] parameters)



but unfortunately without success!

thankful for every assistance



regards

Patrick Ruhnow

Chua Wen Ching
7/2/2004 3:42:01 AM
Hi Patrick Ruhnow,

I am not sure how you do. But this is how i simulate it in c# and vbscript.

C#:

public byte[] CallValue(string message, bool isValue)
{
char [] messageValue = message.ToCharArray();
byte [] messageByte = Encoding.ASCII.GetBytes(messageValue);
return messageByte;
}

VBScript:

<%
set myObject=Server.CreateObject("Lib.ProjectDemor")
dim test
test = myObject.CallValue("hello world", true)
Response.Write(test)
%>

Output:
?????d

Hope it helps you somehow. As I do not have your codes. Correct me if i am wrong.

Thanks.
--
Regards,
Chua Wen Ching :)


[quoted text, click to view]
AddThis Social Bookmark Button