Problem passing VB COM+ ASP Request object to .NET component System.Web.HTTPRequest through COM interop 
Author Message
 Problem passing VB COM+ ASP Request object to .NET component System.Web.HTTPRequest through COM interop

I'm having a problem using .Net COM interop to pass an ASP Request
object from a COM+ object into a new .Net component.

The reason I want to do this is that we have a lot of existing COM+
objects that all use a common error handler COM+ object. We modified
this COM+ error handler to run in .NET to support another business
unit's .NET framework needs. I want to be able to migrate our basic
infrastructure components (the errorhandler, logger and Data Access
Component) to .Net first since they are common across all applications
so we can then slowly migrate old COM objects to .Net or re-write them
in .Net directly, but to do this the errorhanlder needs to be able to
accept calls from both COM+ and .Net objects.

The pre-existing VB COM+ (Win2000)objects reference the ASP type
library, but the .Net version of the error handler uses the
System.Web.HTTPRequest namespace.

When the COM+ object tries to call the .Net object, i get the
following error:

"Unable to cast object of type System.__ComObject to type
System.Web.HttpRequest"

The other String, Integer, and Boolean properties seem to work fine
from COM+ to .NET.

I've tried adding a reference to the COM+ ASP library and using this
to type the property in the .Net component instead of using the
namespace, but this causes the native .Net calls to fail and also does
not fix the COM interop problem.

I'm thinking of modifying the .Net object to have two interfaces, one
for the namespace and one for the old request object and then only
expose the COM interface through interop, but I'm not sure it will
work (I'll try it next).

I've been using Appleman's book (Moving to VB.Net), the news groups,
and MSDN, but unfortunatly, I haven't found anything on this exactly.
Also, they all seem to think this type of usage is going to be rare --
COM to .NEt -- assuming that we will do new development in native .NET
and obsolete the COM+ overtime. As I mentioned, I would prefer to
migrate common infrastructue components to .Net first, then either
migrate or rewrite as necessary.

I'm a .Net newbie so any help you can offer is great -- thanks in
advance!



Wed, 02 Feb 2005 03:19:47 GMT  
 Problem passing VB COM+ ASP Request object to .NET component System.Web.HTTPRequest through COM interop
I managed to get the project to work by adding a second
property to the .net component that handles the
asptyplibrary.request object, but now I'm having trouble
accessing the properties of the asptypelibrary.request
object.

I'm trying to get some ServerVariables and the QueryString
out of the ASPRequest object. The name space logic works
with the .net type, but I get the following error when I
try to get the ServerVariable values -- here's the code
I'm trying to use in the .Net component:

URL = CStr(ASPRequestObject.ServerVariables.Item("URL"))

(URL is a string typed property)

I get the following error:

Cast from type 'IStringList' to type 'String' is not valid.

I get that error on with the QueryString method and
various permutations of the ServerVariable call (with
item, key, default).

I know I'm missing somehting with the object model and com
interop -- I see that its returning an object rather than
a string. How do I work with this structure?

Thanks for the help!

Quote:
>-----Original Message-----
>I'm having a problem using .Net COM interop to pass an
ASP Request
>object from a COM+ object into a new .Net component.

>The reason I want to do this is that we have a lot of
existing COM+
>objects that all use a common error handler COM+ object.
We modified
>this COM+ error handler to run in .NET to support another
business
>unit's .NET framework needs. I want to be able to migrate
our basic
>infrastructure components (the errorhandler, logger and
Data Access
>Component) to .Net first since they are common across all
applications
>so we can then slowly migrate old COM objects to .Net or
re-write them
>in .Net directly, but to do this the errorhanlder needs
to be able to
>accept calls from both COM+ and .Net objects.

>The pre-existing VB COM+ (Win2000)objects reference the
ASP type
>library, but the .Net version of the error handler uses
the
>System.Web.HTTPRequest namespace.

>When the COM+ object tries to call the .Net object, i get
the
>following error:

>"Unable to cast object of type System.__ComObject to type
>System.Web.HttpRequest"

>The other String, Integer, and Boolean properties seem to
work fine
>from COM+ to .NET.

>I've tried adding a reference to the COM+ ASP library and
using this
>to type the property in the .Net component instead of
using the
>namespace, but this causes the native .Net calls to fail
and also does
>not fix the COM interop problem.

>I'm thinking of modifying the .Net object to have two
interfaces, one
>for the namespace and one for the old request object and
then only
>expose the COM interface through interop, but I'm not
sure it will
>work (I'll try it next).

>I've been using Appleman's book (Moving to VB.Net), the
news groups,
>and MSDN, but unfortunatly, I haven't found anything on
this exactly.
>Also, they all seem to think this type of usage is going
to be rare --
>COM to .NEt -- assuming that we will do new development
in native .NET
>and obsolete the COM+ overtime. As I mentioned, I would
prefer to
>migrate common infrastructue components to .Net first,
then either
>migrate or rewrite as necessary.

>I'm a .Net newbie so any help you can offer is great --
thanks in
>advance!
>.



Wed, 02 Feb 2005 07:27:47 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Looking for feedback on code handling COM/ASP and .NET/ASPx Request object

2. Returning an object with sub objects from vb component (COM) to ASP

3. Using VB/ASP.net to save user requested web data

4. Passing Form Fields to VB.NET Custom Business Object in an ASP.NET Code Behind Page

5. Problem using a UNC Path within a COM component in asp.net

6. ASP Request Object into ASP.Net

7. Passing object from VB to COM component

8. Returning Dataset to ASP.NET from .NET Component / Business Object Serialization

9. Problem with passing an ADODB.Recordset between com+ components

10. Problem with passing an ADODB.Recordset between com+ components

11. com object will not read registry when com object called from asp (vb works fine)

12. MAC address of ASP.NET Request or VB.NET connection

 

 
Powered by phpBB® Forum Software