Search:
Namespaces
Discussions
.NET v1.1
Feedback
COM Interop and Variant Return Type
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngmigrate' list
.
Clark Evans
-- Moved from [aspngfreeforall] to [aspngmigrate] by Charles M. Carroll <
Click here to reveal e-mail address
> --
Does anyone know what the expected type should be when a COM object
returns a variant (byte array)? I might add that this is using the
release version of the Framework (and VS.NET, if that matters).
Here's my situation. I have a VB6 COM object which generates a report,
exports that report to PDF as a variant (byte array), and then returns
the variant (byte array) that is the PDF. On a web form, I call out to
the COM component, and then BinaryWrite the returned PDF (byte array) to
the Response.
Instantiation of the component, generation, and export of the report all
work perfectly well. I just can't seem to get the results back to my
web form. No matter what type I try, I receive this (rather unhelpful)
error:
Specified array was not of the expected type.
Exception Details:
System.Runtime.InteropServices.SafeArrayTypeMismatchException: Specified
array was not of the expected type.
Here is the calling code (which worked like a charm in Beta2, I might
add):
MyComponent.MyClass rpt = new MyComponent.MyClass();
byte[] buffer = (byte[])rpt.GetPDF();
//write out the PDF
Response.Clear();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.BinaryWrite(buffer);
Can anyone shed some light on what I'm doing wrong?
Thanks,
Clark Evans
Entredea Inc.
Reply to this message...
Anders.Vikstrom@banqit.com
Hi Clark,
What exactly is the return type from your VB6 object? If it is a =
variant
containing a byte array the .NET type should be Byte(). If it is a =
variant
array (safearray) the .NET type should be Object().=20
Regards,
Anders Vikstr=F6m
SW Engineering, BANQIT AB
http://www.banqit.com
mailto:
Click here to reveal e-mail address
Phone: +46 8 7594737
-----Original Message-----
From: Clark Evans [mailto:
Click here to reveal e-mail address
]
Sent: den 18 februari 2002 17:11
To: aspngmigrate
Subject: [aspngmigrate] COM Interop and Variant Return Type
-- Moved from [aspngfreeforall] to [aspngmigrate] by Charles M. Carroll
<
Click here to reveal e-mail address
> --
Does anyone know what the expected type should be when a COM object
returns a variant (byte array)? I might add that this is using the
release version of the Framework (and VS.NET, if that matters).
Here's my situation. I have a VB6 COM object which generates a report,
exports that report to PDF as a variant (byte array), and then returns
the variant (byte array) that is the PDF. On a web form, I call out to
the COM component, and then BinaryWrite the returned PDF (byte array) =
to
the Response.
Instantiation of the component, generation, and export of the report =
all
work perfectly well. I just can't seem to get the results back to my
web form. No matter what type I try, I receive this (rather unhelpful)
error:
Specified array was not of the expected type.=20
Exception Details:
System.Runtime.InteropServices.SafeArrayTypeMismatchException: =
Specified
array was not of the expected type.
Here is the calling code (which worked like a charm in Beta2, I might
add):
MyComponent.MyClass rpt =3D new MyComponent.MyClass();
byte[] buffer =3D (byte[])rpt.GetPDF();
//write out the PDF
Response.Clear();
Response.ClearHeaders();
Response.ContentType =3D "application/pdf";
Response.BinaryWrite(buffer);
Can anyone shed some light on what I'm doing wrong?
Thanks,
Clark Evans
Entredea Inc.
| [aspngmigrate] member
Click here to reveal e-mail address
=3D YOUR ID
|
http://www.asplists.com/asplists/aspngmigrate.asp
=3D JOIN/QUIT
Reply to this message...
System.Runtime.InteropServices.SafeArrayTypeMismatchException
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com