Wrox Programmer Forums
|
Classic ASP Components Discussions specific to components in ASP 3.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 15th, 2004, 11:54 AM
Registered User
 
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Instanciate .net assembly as com object from ASP

I'm not sure if this is the right forum for this, but here goes. I have designed and implemented an asp.net web app that is working well. But our company uses some 3rd party web software in ASP. Because it is 3rd party, I can't really migrate it into .net without breaking it, or at least invalidating any support they offer on it.

One of the 3rd party ASP pages is customizable, but again, cannot be changed to .net (that would entail migrating global includes that are used on other asp pages as well). Yet I need to incorporate into that ASP some functionality provided by my asp.net web app. Specifically, I need a way to call .net methods from an asp page.

Now some research gave me the following strategy.
1) Create a .net assembly that contains a class that basically wrapped method calls to the web app assembly and compile it.
2) use regasm to write the appropriate class data to the registry, so it can be called as a COM object.
3) from the ASP page use the following code:
set testobject=server.CreateObject("ogwebComLibrary.te stObject")
response.Write (testobject.getText())

Now, the response I kept getting when I viewed the ASP page was "object not set to instance" on the 2nd line: response.write(testObject.getText()).

So a bit more research turned up another way to do this.

1) Create a strong named key and apply it to that assembly. This was more complicated because all other assemples (like those associated with the webapp and the MS Data application block) also needed to be compiled with an snk.
2) use gacutil to register it in the global assembly cache
3) create object from ASP page.

Same error message.

On both occassions, I checked the registry and can see the registry keys pointing to the .net object.

Looking at the error message more closely, I can see that the ASP is not having a problem SEEING the .net object. It is having a problem instanciating it. Yet the object simple looks like this:
Code (abbreviated):

namespace ogwebComLibrary
{

public class testObject{


public testObject(){
}

public string getText(){
}
}
}
The object simply sends a processed ASP.NET page (with a single label whose text is set to "label") to an ASP page, stripping out all the html dealing with body, form, viewstate, etc. It will also handle ASP pages. Just a little test. It will really wrap calls to another assembly once I can be sure ASP can call it's methods.

And an ASP.NET page instanciates it fine. So why won't ASP create the object? It must be seeing the class in the registry (and GAC, for that matter) or I'd get a "class not found"-like exception on the "server.createobject()" line.

I tried using regsvr32.exe, no luck.

VS settings are "use com interop services".

the following lines occur just before the class declaration to enable late binding (for ASP).

[ProgId("ogwebComLibrary.testObject")]
[ClassInterface(ClassInterfaceType.AutoDual)]

I'm banging my head against the wall on this. It will not instanciate this object.

any ideas?

Ian Ohlander
[email protected]






Similar Threads
Thread Thread Starter Forum Replies Last Post
Placing HTML object in ASP.NET toddw607 ASP.NET 2.0 Basics 3 April 30th, 2008 03:58 PM
remote connection object in asp.net nirmalbarsainyan ASP.NET 2.0 Basics 1 August 9th, 2007 06:27 PM
Error to instanciate Globals.Settings.Articles monfu BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 March 14th, 2007 11:13 AM
Converting .NET 2.0 Assembly to .Net 1.x Assembly pskaushik .NET Framework 2.0 1 November 25th, 2006 01:51 PM
Making COM Object For ASP.NET Use bluethecow ASP.NET 2.0 Basics 1 September 30th, 2006 10:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.