473,588 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Handling System._ComObje ct -- using CCW

Hi

I am calling .NET components from my Classical ASPs.
For this I strong named my assemblies, then registered them in the resistry
( using RegAsm), and put them in GAC (using GacUtil) .
Everything worked fine and my ASPs were able to call and use them.

The problem comes when my ASP code assigns an ASP object variable to a
property of a class in the assembly like:
oDotNetObject(" Name") = Request("Name")
( where oDotNetObject is a class in my registered assembly )

The COM Callable Wrapper sends it as System._ComObje ct to .NET Runtime which
then throws exception as nothing is allowed on System._ComObje ct. On the
other hand, passing it as Variant solves the problem.
Dim varName = Request("Name")
oDotNetObject(" Name") = varName

But this would require a significant change in my ASP pages. I want to
modify only my .NET components. Is there any way I can use this
System._ComObje ct in my managed code or any way I can make CCW to handle it.
I was trying to use System.Runtime. InteropServices .Marshal namespace to use
the System._ComObje ct I have not been able to do it.

Thanks in anticipation
Varun
Jul 19 '05 #1
2 4405
Thanks Oisin

But here my problem is that I am working on a huge application and I cant
change this usage in ASP files.
So I have to find a solution in .Net component -- as you said -- i will have
to marshal a com object
Any ideas about that!

Thanks
Varun

"Oisin Grehan" <oi****@nospam. iol.ie.> wrote in message
news:OF******** ******@tk2msftn gp13.phx.gbl...
By assigning Request("Name") to the property, you are using a bad habit most of us have by relying on default properties. Take a look at this:

<%
Dim strName
strName = Request("Name")
%>

The ASP engine will assigning the default property (which happens to be
"Item") to the variable and everything will be fine. However, when you use:
oDotNetObject(" Name") = Request("Name")

You are relying on the DotNet class to retrieve the default property from
the COM object "Request". If you use:

oDotNetObject(" Name") = Request("Name") .Item

Everything should be mostl likely be fine as you are not longer marshalling a COM object, but rather a simple string.

Hope this helps,

- Oisin

"Varun Singal" <va**********@i nduslogic.com> wrote in message
news:u$******** ******@tk2msftn gp13.phx.gbl...
Hi

I am calling .NET components from my Classical ASPs.
For this I strong named my assemblies, then registered them in the

resistry
( using RegAsm), and put them in GAC (using GacUtil) .
Everything worked fine and my ASPs were able to call and use them.

The problem comes when my ASP code assigns an ASP object variable to a
property of a class in the assembly like:
oDotNetObject(" Name") = Request("Name")
( where oDotNetObject is a class in my registered assembly )

The COM Callable Wrapper sends it as System._ComObje ct to .NET Runtime

which
then throws exception as nothing is allowed on System._ComObje ct. On the
other hand, passing it as Variant solves the problem.
Dim varName = Request("Name")
oDotNetObject(" Name") = varName

But this would require a significant change in my ASP pages. I want to
modify only my .NET components. Is there any way I can use this
System._ComObje ct in my managed code or any way I can make CCW to handle

it.
I was trying to use System.Runtime. InteropServices .Marshal namespace to

use
the System._ComObje ct I have not been able to do it.

Thanks in anticipation
Varun


Jul 19 '05 #2
Varun, surely it is more work to facilitate this than to spend a while with
global find/replace with regex on those ASP files? Marshalling COM objects
instead of strings is hugely inefficient, incredibly lazy as well as just
plain wrong. But, if you really are a masochist (or an assembly
programmer -- same thing), keep reading:

First of all, I hope you're comfortable with COM interop, IDL, type
libraries and other such nasties. I'm not an interop specialist nor a COM
guru by any means, so I can only try to direct you. Right, since you're
passing in a System._ComObje ct object, I believe you'll need to use the
MarshalAs attribute to tell .NET that you're expecting
UnmanagedType.I Dispatch. "Request" is an IDispatch object. If we inspect the
IDL with OleView (tool included with VS) by pointing it at the ASP type
library available at C:\Program Files\Microsoft Visual
Studio\Common\I DE\IDE98\asp.tl b assuming you've got Vstudio 6.0 installed in
the default location, you can see the following info (trimmed down for
brevity) for IRequest:

[odl, uuid(D97A6DA0-A861-11CF-93AE-00A0C90C2BD8), hidden, dual,
oleautomation]
interface IRequest : IDispatch {
[id(00000000), propget]
HRESULT Item([in] BSTR bstrVar, [out, retval] IDispatch** ppObjReturn);

HRESULT QueryString([out, retval] IRequestDiction ary** ppDictReturn);
HRESULT Form([out, retval] IRequestDiction ary** ppDictReturn);
};

You'll see that Item is the default property (IDL id of 0), it returns an
IDispatch interface, most likely this one in your case:

[odl, uuid(D97A6DA0-A85F-11DF-83AE-00A0C90C2BD8), helpstring("Dic tionary for
Request collections"), hidden, dual, oleautomation]
interface IRequestDiction ary : IDispatch {
[id(00000000), propget]
HRESULT Item([in, optional] VARIANT Var, [out, retval] VARIANT*
pVariantReturn) ;
};

Again, you can see the default property for the IRequestDiction ary is Item
also, which returns a variant. This is the variant you need to get your
grubby hands on. All the information you'll need to imbibe and understand is
on MSDN. A good place to start is to look up the MarshalAs attribute and
pay attention to the UnmanagedType enumeration. There's some good example
code there.

Now, if this hasn't put you off, you plainly have access to the ASP
source -- is it really that huge a task to change it? Open all ASP pages in
VS.NET, use Find/Replace with Regular Expressions. Replace .*
\=\s?Request\(" {.*}\"\) with = Request("\1").I tem. Bingo, assuming that
Regex expression out of my head is correct. If you have the time, sit back
and learn COM interop. If that looks like too steep a hill to climb, change
the ASP pages, or better yet, learn Regular Expressions. It'll be the best
hour you've spend in front of the computer today and it will pay you back
many times over.

Hope this helps,

- Oisin



"Varun Singal" <va**********@i nduslogic.com> wrote in message
news:eN******** ******@tk2msftn gp13.phx.gbl...
Thanks Oisin

But here my problem is that I am working on a huge application and I cant
change this usage in ASP files.
So I have to find a solution in .Net component -- as you said -- i will have to marshal a com object
Any ideas about that!

Thanks
Varun

"Oisin Grehan" <oi****@nospam. iol.ie.> wrote in message
news:OF******** ******@tk2msftn gp13.phx.gbl...
By assigning Request("Name") to the property, you are using a bad habit

most
of us have by relying on default properties. Take a look at this:

<%
Dim strName
strName = Request("Name")
%>

The ASP engine will assigning the default property (which happens to be
"Item") to the variable and everything will be fine. However, when you

use:

oDotNetObject(" Name") = Request("Name")

You are relying on the DotNet class to retrieve the default property from the COM object "Request". If you use:

oDotNetObject(" Name") = Request("Name") .Item

Everything should be mostl likely be fine as you are not longer

marshalling
a COM object, but rather a simple string.

Hope this helps,

- Oisin

"Varun Singal" <va**********@i nduslogic.com> wrote in message
news:u$******** ******@tk2msftn gp13.phx.gbl...
Hi

I am calling .NET components from my Classical ASPs.
For this I strong named my assemblies, then registered them in the

resistry
( using RegAsm), and put them in GAC (using GacUtil) .
Everything worked fine and my ASPs were able to call and use them.

The problem comes when my ASP code assigns an ASP object variable to a
property of a class in the assembly like:
oDotNetObject(" Name") = Request("Name")
( where oDotNetObject is a class in my registered assembly )

The COM Callable Wrapper sends it as System._ComObje ct to .NET Runtime

which
then throws exception as nothing is allowed on System._ComObje ct. On the other hand, passing it as Variant solves the problem.
Dim varName = Request("Name")
oDotNetObject(" Name") = varName

But this would require a significant change in my ASP pages. I want to
modify only my .NET components. Is there any way I can use this
System._ComObje ct in my managed code or any way I can make CCW to
handle it.
I was trying to use System.Runtime. InteropServices .Marshal namespace
to use
the System._ComObje ct I have not been able to do it.

Thanks in anticipation
Varun



Jul 19 '05 #3

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

Similar topics

9
3193
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is indeed also true for our language of choice, Python. Its file type allows some extraordinary convenient access like: for line in open("blah"): handle_line(line)
7
5980
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
2
336
by: Varun Singal | last post by:
Hi I am calling .NET components from my Classical ASPs. For this I strong named my assemblies, then registered them in the resistry ( using RegAsm), and put them in GAC (using GacUtil) . Everything worked fine and my ASPs were able to call and use them. The problem comes when my ASP code assigns an ASP object variable to a property of a class in the assembly like: oDotNetObject("Name") = Request("Name")
4
27926
by: m96 | last post by:
hi, i'm trying to make a query to a ldap server (version v2 or v3 doen't matter) with c#. the query works just fine but the problem is that i can't read the custom attributes/fields, since .net gives the following error: System.NotImplementedException: Handling of this ADSVALUE type is not yet implemented (type = 0xb). after googling for a long time i found out that many other have the same
4
2519
by: aaj | last post by:
Hi all I have an automated application, that runs in the middle of the night. If certain 'non system' errors occur (things like malformed files, missing files etc..), I send an automatic Email and write a record to the database. This is handled in a class. When these errors occur, once Emailed and written I want to just end the App, simple as that.
9
2221
by: Gustaf | last post by:
I'm confused about structured error handling. The following piece of code is a simplification of a class library I'm working on. It works, and it does what I want, but I'm still not convinced that I have been doing it right. I think I overdo it. Please have a look: -- using System; using System.IO;
16
2532
by: Chuck Cobb | last post by:
I'm implementing a centralized exception handling routine using the Enterprise Library Exception Management Application Block. I trap all unhandled exceptions to one place using the following method: // --- Create an Exception Handler for Thread Exceptions ---------------- Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException);
4
13533
by: Rob | last post by:
Hey all, So.. a simple FormView/SqlDataSource to handle inserting records into a table. The table has a primary key that the user enters (eg DiscountCode). If the user enters a duplicate the database complains about a primary key violation (which is what I want) and an exception is thrown. The OnInserted event of the SqlDataSource provides access to the exception so, presumably, you can provide nice handling for various errors. For...
0
1608
by: sandy | last post by:
I have a AxWebBrowser class. I wish to locate a specific element in its HTMLDocument which has a specific 'style'. I use the following code to access the element with the specific style:- IHTMLDocument2 doc = (HTMLDocumentClass)Browser1.Document; if( doc.body != null && doc.body.all != null) { foreach(IHTMLElement el in (IHTMLElementCollection)doc.body.all)
0
7927
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7857
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8220
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7981
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6632
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5723
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3846
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1194
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.