473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 3764
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 now they don't need ANY Windows developer at a...
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 starting point. void TheMainFunc() { // Body of...
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 after the move with one exception. We were...
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 that? Normally I use controls like a grid or...
0
by: Alexander | last post by:
Stituation: ----------------------- 1) COM+ application with .NET components (using regasm, interfaces etc.) 2) ASP (classic) creates an instance of a object using Server.CreateObject. The...
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 Nothing I assume no memory is set aside nor GC'ed But...
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 String I want to populate it with rows from a...
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 use the web application, our web users will have...
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 created one array and pass that through submitting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.