472,342 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,342 software developers and data experts.

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

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
Nov 18 '05 #1
3 3668
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" <co***@testmail.com> wrote in message
news:eK*************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2
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" <ke***@takempis.com> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
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" <co***@testmail.com> wrote in message
news:eK*************@TK2MSFTNGP11.phx.gbl...
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


Nov 18 '05 #3
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" <co***@testmail.com> wrote in message
news:eK*************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

99
by: Jim Hubbard | last post by:
It seems that Microsoft not only does not need the classic Visual Basic developer army (the largest army of developers the world has ever seen), but...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a...
1
by: Rhek | last post by:
Hello, I have just moved an ASP Classic website to a new hosting company that has a number of .NET components available. The website works fine...
1
by: Alfredo Magallón Arbizu | last post by:
Hello, I need to pass the contents of a dataset to the client in order to use these contents with javascript. What is the best way to achieve...
0
by: Alexander | last post by:
Stituation: ----------------------- 1) COM+ application with .NET components (using regasm, interfaces etc.) 2) ASP (classic) creates an instance...
61
by: academic | last post by:
When I declare a reference variable I initialize it to Nothing. Now I'm wondering if that best for String variables - is "" better? With...
9
by: Anil Gupte | last post by:
I am having a problem using Multidim arrays. I want to create an array which as I understand it is dimensioned as: dim xyz (rows,columns) as...
8
by: antonyliu2002 | last post by:
We are extending a web application written in classic ASP long time ago. We will add more components to this web application in ASP.NET 2.0. To...
2
by: Garg | last post by:
Hi All, I am facing one problem if you are having any solution please tell me. I have to pass an array from javascript to servlet. for this i...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.