Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Passing arrays from Classic ASP to .NET components - How do you do this transparently?

Reply
Thread Tools

Passing arrays from Classic ASP to .NET components - How do you do this transparently?

 
 
Mark
Guest
Posts: n/a
 
      12-04-2003
Hi

From what I understand, you can pass arrays from classic ASP to .NET using
interop, but you have to change the type of the.NET parameter to object.
This seems to be because classic ASP passes a variant containing an array,
and interop expects a parameter of type object if you are passing a variant
(you are expected to cast it to the correct type in your code). I'd like to
find a way of passing arrays so that you don't need to change the types of
all arrays to object in method signatures - since this throws away compile
time type checking.

Has anyone got any ideas as to how we could do this? (Unless you use a type
library, ASP queries the CCW for type information - although what is
returned can be changed by overriding the correct method(s) in the object's
IReflect interface).

We have come up with a number of ideas which include writing a wrapper class
which customises IDispatch by overriding IReflect, but does anyone have a
simpler solution? Are there any commercial components which can solve this
problem? We also considering using web services but I don't think that we
would get the same OO semantics using this approach, would we? We could
write a simple .NET wrapper class for each .NET class or we could add extra
methods to the original class in order to solve this problem. Writing a
wrapper object in COM has also been considered, as has passing the data as a
string (which would not be very transparent, it would be inefficient). We
also considered writing our own collection classes which we would us instead
of arrays, but it might be difficult to make this transparent.

Any ideas would be really appreciated..

Thanks

Mark


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      12-04-2003
I'm afraid you're way off. ASP and ASP.Net are 2 different technologies.
There is no interop that you can use to communicate between the 2. They live
in different application domains; different processes, different memory
spaces. The only way an ASP app can talk to an ASP.Net app (or vice versa)
is via HTTP. That is, you can send an HTTP request from one to the other,
passing data in the form of Query String or Form Post. Well, you could have
one write to a file or database as well, and have the other read it.

Interop is used for DLLs, COM objects, Windows API calls, etc.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Mark" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> From what I understand, you can pass arrays from classic ASP to .NET using
> interop, but you have to change the type of the.NET parameter to object.
> This seems to be because classic ASP passes a variant containing an array,
> and interop expects a parameter of type object if you are passing a

variant
> (you are expected to cast it to the correct type in your code). I'd like

to
> find a way of passing arrays so that you don't need to change the types of
> all arrays to object in method signatures - since this throws away compile
> time type checking.
>
> Has anyone got any ideas as to how we could do this? (Unless you use a

type
> library, ASP queries the CCW for type information - although what is
> returned can be changed by overriding the correct method(s) in the

object's
> IReflect interface).
>
> We have come up with a number of ideas which include writing a wrapper

class
> which customises IDispatch by overriding IReflect, but does anyone have a
> simpler solution? Are there any commercial components which can solve this
> problem? We also considering using web services but I don't think that we
> would get the same OO semantics using this approach, would we? We could
> write a simple .NET wrapper class for each .NET class or we could add

extra
> methods to the original class in order to solve this problem. Writing a
> wrapper object in COM has also been considered, as has passing the data as

a
> string (which would not be very transparent, it would be inefficient). We
> also considered writing our own collection classes which we would us

instead
> of arrays, but it might be difficult to make this transparent.
>
> Any ideas would be really appreciated..
>
> Thanks
>
> Mark
>
>



 
Reply With Quote
 
 
 
 
Matthew W. Jackson
Guest
Posts: n/a
 
      12-05-2003
I haven't tried it, but I'm pretty sure you can write a Class Library in
..NET, register it as a COM object, and call it from ASP.

If VB6 can call a .NET library, I see no reason why ASP couldn't either.

--Matthew W. Jackson

"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm afraid you're way off. ASP and ASP.Net are 2 different technologies.
> There is no interop that you can use to communicate between the 2. They

live
> in different application domains; different processes, different memory
> spaces. The only way an ASP app can talk to an ASP.Net app (or vice versa)
> is via HTTP. That is, you can send an HTTP request from one to the other,
> passing data in the form of Query String or Form Post. Well, you could

have
> one write to a file or database as well, and have the other read it.
>
> Interop is used for DLLs, COM objects, Windows API calls, etc.
>
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
>
> "Mark" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi
> >
> > From what I understand, you can pass arrays from classic ASP to .NET

using
> > interop, but you have to change the type of the.NET parameter to object.
> > This seems to be because classic ASP passes a variant containing an

array,
> > and interop expects a parameter of type object if you are passing a

> variant
> > (you are expected to cast it to the correct type in your code). I'd like

> to
> > find a way of passing arrays so that you don't need to change the types

of
> > all arrays to object in method signatures - since this throws away

compile
> > time type checking.
> >
> > Has anyone got any ideas as to how we could do this? (Unless you use a

> type
> > library, ASP queries the CCW for type information - although what is
> > returned can be changed by overriding the correct method(s) in the

> object's
> > IReflect interface).
> >
> > We have come up with a number of ideas which include writing a wrapper

> class
> > which customises IDispatch by overriding IReflect, but does anyone have

a
> > simpler solution? Are there any commercial components which can solve

this
> > problem? We also considering using web services but I don't think that

we
> > would get the same OO semantics using this approach, would we? We could
> > write a simple .NET wrapper class for each .NET class or we could add

> extra
> > methods to the original class in order to solve this problem. Writing a
> > wrapper object in COM has also been considered, as has passing the data

as
> a
> > string (which would not be very transparent, it would be inefficient).

We
> > also considered writing our own collection classes which we would us

> instead
> > of arrays, but it might be difficult to make this transparent.
> >
> > Any ideas would be really appreciated..
> >
> > Thanks
> >
> > Mark
> >
> >

>
>



 
Reply With Quote
 
Peter Strĝiman
Guest
Posts: n/a
 
      12-10-2003
Hi.

As I read you mail, what you want to do is call a compont written in .NET
from an ASP page?

First of all, your .NET component would have to be registered as a COM
component. That's quite easy if you're familiar with COM.

Regarding how to write the interface for your class so that ASP can
understand the class, you might be able to define your method like this
void method( object[] args )
but you surely can't do this
void method( int[] args )

The reason is that, as you wrote, ASP passes a variant containing an array.
But to be more specific, ASP can only operate on arrays, if they are arrays
of variants. It can't handle arrays of ints, strings or any other type.
This can only be handled by passing an array of variants where each variant
actually contains an int or a string.

Other COM aware languages, e.g. VB6 or C++, don't have any problems
operating on arrays of integers or strings, but ASP ( or VBScript to be
precise ) can't.

If you decide to go down the path of creating a .NET component to be used by
ASP, I suggest that you create a wrapper class that converts data as needed
and then call the sspecific strongly typed method on the real component

Pete

"Mark" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> From what I understand, you can pass arrays from classic ASP to .NET using
> interop, but you have to change the type of the.NET parameter to object.
> This seems to be because classic ASP passes a variant containing an array,
> and interop expects a parameter of type object if you are passing a

variant
> (you are expected to cast it to the correct type in your code). I'd like

to
> find a way of passing arrays so that you don't need to change the types of
> all arrays to object in method signatures - since this throws away compile
> time type checking.
>
> Has anyone got any ideas as to how we could do this? (Unless you use a

type
> library, ASP queries the CCW for type information - although what is
> returned can be changed by overriding the correct method(s) in the

object's
> IReflect interface).
>
> We have come up with a number of ideas which include writing a wrapper

class
> which customises IDispatch by overriding IReflect, but does anyone have a
> simpler solution? Are there any commercial components which can solve this
> problem? We also considering using web services but I don't think that we
> would get the same OO semantics using this approach, would we? We could
> write a simple .NET wrapper class for each .NET class or we could add

extra
> methods to the original class in order to solve this problem. Writing a
> wrapper object in COM has also been considered, as has passing the data as

a
> string (which would not be very transparent, it would be inefficient). We
> also considered writing our own collection classes which we would us

instead
> of arrays, but it might be difficult to make this transparent.
>
> Any ideas would be really appreciated..
>
> Thanks
>
> Mark
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multidimensional arrays and arrays of arrays Philipp Java 21 01-20-2009 08:33 AM
using .net components with classic ASP web pages Robert Miller ASP General 3 01-06-2006 07:41 PM
ASP Classic and .Net Components Rhek ASP General 1 08-30-2005 02:00 AM
Classic ASP and Dyna or Peachtree components =?Utf-8?B?Q2hyaXMgU3RvY2tzY3JhcGVy?= ASP .Net 0 06-08-2005 08:14 PM
Can Choice components respond to keyboard input like HTML Choice components? Mickey Segal Java 0 02-02-2004 10:59 PM



Advertisments