.NETGURU
NOT ANSWERED YET: Custom COM wrapper?
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngmigrate' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Goldfarb, Christopher
Greetings,

I have a blackbox legacy COM object that just so happens to return some
user-defined objects as opposed to base types likes strings and ints. Tlbimp
understandably has difficulty with these types and defaults them to Object.
Here's a snapshot of such a class. It's "REXServiceRequestQuery", which is
a collection class of "REXServiceRequest":

http://www.warplanner.com/files/ildasm.gif

This COM object works fine in classic ASP since I can iterate through
nebulous "Variants" and late-bind. I can't get the same thing to work in
ASP.NET, because the types are Objects and I can't access the
REXServiceRequest members. I've tried casting (cannot explicitly cast), and
unsafe casting (compiles, but the objects are null at runtime).

Because this COM object was only used in ASP pages, there is no IDL file for
it. I've been doing a great deal of research and have found hints and
suggestions that I can create my own wrapper for it rather than using the
tool. This allows me to specify, for instance, that the collection is of
the correct type rather than Object.

Has anyone done something like this, and if so, could you provide an example
on how to do it for the given collection class? Or is there an option I can
set with tlbimp that I'm just missing that would make the auto-generated
wrapper work? Also, in my research I've seen it mentioned that it can be a
time consuming process. This COM object is absolutely enormous. 38
different classes, of which 9 are enums. One class has over 300
methods/properties! Am I going to have to hand-write the interfaces for all
of these items, or can I somehow edit the already-available .dll (and if so,
how do I do that)?

Thanks a ton in advance...

Cheers,
Chris Goldfarb
Sr. Web Applications Engineer
Software Solutions Group, Intel
(503) 696-6528

Reply to this message...
 
    
Brian Bilbro (VIP)
In VB.NET, you should be able to do late-binding and declare everything as
an Object.

--
Biran

----- Original Message -----
From: "Goldfarb, Christopher" <Click here to reveal e-mail address>
To: "aspngmigrate" <Click here to reveal e-mail address>
Sent: 11/30/2001 11:39 AM
Subject: [aspngmigrate] NOT ANSWERED YET: Custom COM wrapper?

[Original message clipped]

Reply to this message...
 
    
Goldfarb, Christopher
Ahhhh - that's probably it. We are using C#! There's no way to late-bind
in C#?

-----Original Message-----
From: Brian Bilbro [mailto:Click here to reveal e-mail address]
Sent: Friday, November 30, 2001 10:51 AM
To: aspngmigrate
Subject: [aspngmigrate] Re: NOT ANSWERED YET: Custom COM wrapper?

In VB.NET, you should be able to do late-binding and declare everything as
an Object.

--
Biran

----- Original Message -----
From: "Goldfarb, Christopher" <Click here to reveal e-mail address>
To: "aspngmigrate" <Click here to reveal e-mail address>
Sent: 11/30/2001 11:39 AM
Subject: [aspngmigrate] NOT ANSWERED YET: Custom COM wrapper?

[Original message clipped]

| [aspngmigrate] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngmigrate.asp = JOIN/QUIT

Reply to this message...
 
    
Brian Bilbro (VIP)
----- Original Message -----
From: "Goldfarb, Christopher" <Click here to reveal e-mail address>
Sent: 11/30/2001 2:08 PM

[Original message clipped]

I think the short answer is no...but I *believe* I've seen references to
people *claiming* you can but I don't know how.. But if you are migrating
VBScript code to .NET I would highly migrating it to VB.NET instead.

Or you could create a VB.NET component that wraps your COM object and then
use the VB.NET component in your C# code pages.

--
Brian

[Original message clipped]

Reply to this message...
 
    
Goldfarb, Christopher
Brian,

That worked like a charm. Thanks a ton.

-----Original Message-----
From: Brian Bilbro [mailto:Click here to reveal e-mail address]
Sent: Friday, November 30, 2001 12:29 PM
To: aspngmigrate
Subject: [aspngmigrate] Re: NOT ANSWERED YET: Custom COM wrapper?

----- Original Message -----
From: "Goldfarb, Christopher" <Click here to reveal e-mail address>
Sent: 11/30/2001 2:08 PM

[Original message clipped]

I think the short answer is no...but I *believe* I've seen references to
people *claiming* you can but I don't know how.. But if you are migrating
VBScript code to .NET I would highly migrating it to VB.NET instead.

Or you could create a VB.NET component that wraps your COM object and then
use the VB.NET component in your C# code pages.

--
Brian

[Original message clipped]

| [aspngmigrate] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngmigrate.asp = JOIN/QUIT

Reply to this message...
 
    
Joe Stagner

The code below Dims Objects as Generic "Object" and then Creates a COM
object, an Excel Spread Sheet, and uses it - works fine.

When you include an project reference to Exec 10, VS.NET actually tells
you that it didn't find a wrapper and asks if you want it to create one
for you.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim xlApp As Object ' Excel.Application
Dim xlBook As Object ' Excel.Workbook
Dim xlSheet As Object ' Excel.Worksheet
xlApp =3D CType(CreateObject("Excel.Application"),
Excel.Application)
xlBook =3D CType(xlApp.Workbooks.Add, Excel.Workbook)
xlSheet =3D CType(xlBook.Worksheets(1), Excel.Worksheet)
' Place some text in the second row of the sheet.
xlSheet.Activate()
xlSheet.Cells(2, 2) =3D "This is column B row 2"
' Show the sheet.
xlSheet.Application.Visible =3D True
' Save the sheet to C:\test.xls directory.
xlSheet.SaveAs("C:\Test2.xls")
' Optionally, you can call xlApp.Quit to close the work sheet.
End Sub

Joe Stagner
---------------------------------------------------------
Technical Evangelist - .NET Developer Technologies
Microsoft Corporation - New England
Tel: (781) 487-6640=20
Cell: (603) 566-7945

-----Original Message-----
From: Brian Bilbro [mailto:Click here to reveal e-mail address]=20
Sent: Friday, November 30, 2001 3:29 PM
To: aspngmigrate
Subject: [aspngmigrate] Re: NOT ANSWERED YET: Custom COM wrapper?

----- Original Message -----
From: "Goldfarb, Christopher" <Click here to reveal e-mail address>
Sent: 11/30/2001 2:08 PM

> Ahhhh - that's probably it. We are using C#! There's no way to
late-bind
> in C#?

I think the short answer is no...but I *believe* I've seen references to
people *claiming* you can but I don't know how.. But if you are
migrating
VBScript code to .NET I would highly migrating it to VB.NET instead.

Or you could create a VB.NET component that wraps your COM object and
then
use the VB.NET component in your C# code pages.

--
Brian

[Original message clipped]

| [aspngmigrate] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngmigrate.asp =3D JOIN/QUIT

Reply to this message...
 
    
Craig Weldon
Hi Chris

I believe it is possible to use late binding and C#. We are planning on
publishing an article on C#Today soon on the subject of late binding, and
the scenarios where you would want to use it - I will mail you directly when
it is published if you are still interested.

Craig Weldon
C#Today Editorial
http://www.csharptoday.com/

-----Original Message-----
From: Brian Bilbro [mailto:Click here to reveal e-mail address]
Sent: Friday, November 30, 2001 8:29 PM
To: aspngmigrate
Subject: [aspngmigrate] Re: NOT ANSWERED YET: Custom COM wrapper?

----- Original Message -----
From: "Goldfarb, Christopher" <Click here to reveal e-mail address>
Sent: 11/30/2001 2:08 PM

[Original message clipped]

I think the short answer is no...but I *believe* I've seen references to
people *claiming* you can but I don't know how.. But if you are migrating
VBScript code to .NET I would highly migrating it to VB.NET instead.

Or you could create a VB.NET component that wraps your COM object and then
use the VB.NET component in your C# code pages.

--
Brian

[Original message clipped]

| [aspngmigrate] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngmigrate.asp = JOIN/QUIT

Reply to this message...
 
    
Goldfarb, Christopher
That would be great (although VB.NET works in the interim)...

Cheers,
Chris

-----Original Message-----
From: Craig Weldon [mailto:Click here to reveal e-mail address]
Sent: Tuesday, December 04, 2001 2:16 AM
To: aspngmigrate
Subject: [aspngmigrate] Re: NOT ANSWERED YET: Custom COM wrapper?

Hi Chris

I believe it is possible to use late binding and C#. We are planning on
publishing an article on C#Today soon on the subject of late binding, and
the scenarios where you would want to use it - I will mail you directly when
it is published if you are still interested.

Craig Weldon
C#Today Editorial
http://www.csharptoday.com/

-----Original Message-----
From: Brian Bilbro [mailto:Click here to reveal e-mail address]
Sent: Friday, November 30, 2001 8:29 PM
To: aspngmigrate
Subject: [aspngmigrate] Re: NOT ANSWERED YET: Custom COM wrapper?

----- Original Message -----
From: "Goldfarb, Christopher" <Click here to reveal e-mail address>
Sent: 11/30/2001 2:08 PM

[Original message clipped]

I think the short answer is no...but I *believe* I've seen references to
people *claiming* you can but I don't know how.. But if you are migrating
VBScript code to .NET I would highly migrating it to VB.NET instead.

Or you could create a VB.NET component that wraps your COM object and then
use the VB.NET component in your C# code pages.

--
Brian

[Original message clipped]

| [aspngmigrate] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngmigrate.asp = JOIN/QUIT

| [aspngmigrate] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngmigrate.asp = JOIN/QUIT

Reply to this message...
 
    
Sten Sundblad
Craig is right; you can do late binding in C#, even if it isn't as easy
as with Visual Basic. In C# you'll have to use reflection to do late
binding. I can't give you any details; just point you in the right
direction, which is the reflection object. Good luck!

Best
/Sten

--------------------------------------------------------------------=20
Sten Sundblad, ADB-Arkitektur AB=20
Microsoft Regional Director, Sweden=20
Email: Click here to reveal e-mail address=20
WWW: http://www.adbark.se http://www.adbark.com=20
Kungsgatan 113, Box 437, 751 06 UPPSALA, SWEDEN=20
Phone: +46(0)18-69 51 00 Fax: +46(0)18-69 51 59

-----Original Message-----
From: Craig Weldon [mailto:Click here to reveal e-mail address]=20
Sent: den 4 december 2001 11:16
To: aspngmigrate
Subject: [aspngmigrate] Re: NOT ANSWERED YET: Custom COM wrapper?

Hi Chris

I believe it is possible to use late binding and C#. We are planning on
publishing an article on C#Today soon on the subject of late binding,
and
the scenarios where you would want to use it - I will mail you directly
when
it is published if you are still interested.

Craig Weldon
C#Today Editorial
http://www.csharptoday.com/

-----Original Message-----
From: Brian Bilbro [mailto:Click here to reveal e-mail address]
Sent: Friday, November 30, 2001 8:29 PM
To: aspngmigrate
Subject: [aspngmigrate] Re: NOT ANSWERED YET: Custom COM wrapper?

----- Original Message -----
From: "Goldfarb, Christopher" <Click here to reveal e-mail address>
Sent: 11/30/2001 2:08 PM

> Ahhhh - that's probably it. We are using C#! There's no way to
late-bind
> in C#?

I think the short answer is no...but I *believe* I've seen references to
people *claiming* you can but I don't know how.. But if you are
migrating
VBScript code to .NET I would highly migrating it to VB.NET instead.

Or you could create a VB.NET component that wraps your COM object and
then
use the VB.NET component in your C# code pages.

--
Brian

[Original message clipped]

| [aspngmigrate] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngmigrate.asp =3D JOIN/QUIT

| [aspngmigrate] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngmigrate.asp =3D JOIN/QUIT

Reply to this message...
 
 
System.EventArgs
System.Object




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification