Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 1st, 2004, 11:10 PM
Authorized User
 
Join Date: Mar 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default Server.CreateObject problem

I converted my asp page to aspx, now Server.CreateObject doesn't work for a registered COM object
that I used before. There is no error message. I just get empty output.

Very simple code:

 dim Obj
 Obj = Server.CreateObject("Test.Application")
 call Obj.MyMethod(StrIn, StrOut)
 Obj = Nothing


How can I fix this?

(ASP.NET v1.1, WinXp Pro IIS v5.1)

 
Old April 2nd, 2004, 03:40 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Are you using Visual Studio .NET? If so, add a reference to the DLL, and VS will create a wrapper for the COM object. Then in your code, you can instantiate the control like you would any other control.
Don't use Server.CreateObject, but something like this:

Dim Obj As Test.Application
Obj = New Test.Application()

You can also use a tool called TlbImp.exe to convert your type library to a .NET assembly.

Cheers,

Imar



---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old April 2nd, 2004, 04:13 AM
Authorized User
 
Join Date: Mar 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default


It's a 3rd party component, so no, I can't add anything to the DLL. I tried using TlbImp.exe
on it and it created another DLL, but I don't know what to do with this new DLL. It doesn't
have any export functions, and can't register it either.

 
Old April 2nd, 2004, 04:18 AM
Authorized User
 
Join Date: Mar 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oh, you mean create a wrapper for this DLL and try to use the wrapper instead?

I could probably try to do that, but this 3rd party component is already an ActiveX
component, it works fine with ASP, so I didn't think it would matter with
ASP.NET.

 
Old April 2nd, 2004, 04:22 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

That is correct. The new DLL it creates cannot be registered. It's not a COM DLL, it's a .NET assembly, ready for XCopy deployment.

You'll need to move the new DLL to the Bin folder of your application, so it becomes accessible by your ASP.NET application.

You don't have to add anything to the old DLL. The tool creates a new DLL that acts as a wrapper. That is, you app talks to your new DLL which in turn relays its messages to the old DLL.

Search Google for TlbImp.exe and ASP.NET and you'll find plenty of examples, like: http://www.aspalliance.com/articleVi...aId=377&pId=-1

This may not be the best article, but it was the first I found. There are lots more....

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old April 2nd, 2004, 03:29 PM
Authorized User
 
Join Date: Mar 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the info. Small detail: where is the 'bin' directory?

When I installed ASP.NET on my computer, it didn't create one.

But it did create some other directories:
C:\Inetpub\wwwroot\aspnet_client
C:\Inetpub\wwwroot\aspnet_client\system_web
C:\Inetpub\wwwroot\aspnet_client\system_web\1_1_43 22

 
Old April 2nd, 2004, 03:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You are supposed to create the bin directory.

 
Old April 2nd, 2004, 09:54 PM
Authorized User
 
Join Date: Mar 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the one-line answer, but you didn't say where I should create it.

Found it!
Response.Write ("BinDirectory: " & HttpRuntime.BinDirectory & "<BR>")

 
Old April 3rd, 2004, 05:12 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Usually, the Bin folder is located directly under the application's root.

So, for the default Web site, that would be:

C:\Inetpub\wwwroot\Bin

And for a custom Application you created it could be something like:

C:\Inetpub\wwwroot\MyApplication\Bin

Did you get it to work?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old April 3rd, 2004, 12:57 PM
Authorized User
 
Join Date: Mar 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Great! Got it working. I used your example:

 Dim Obj As Test.Application
 Obj = New Test.Application()

 I believe this header is also necessary:
<% @Import Namespace="test" %>


 I tried using Server.CreateObject, but it gave me errors:

 Dim Obj
 Obj = Server.CreateObject("test.Application")


Server Error in '/' Application.
--------------------------------------------------------------------------------

Could not create an object of type 'test.Application'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Could not create an object of type 'test.Application'.


I hope the string isn't case sensitive. I tried both cases,
still gives me an error. Doesn't matter, the first way works great.
Thanks.
 :)








Similar Threads
Thread Thread Starter Forum Replies Last Post
What is Server,CreateObject("File.clsFile")? SMM Classic ASP Professional 0 May 7th, 2007 08:31 AM
How To use server.createobject in c# ranakdinesh C# 0 November 4th, 2005 08:18 AM
Server.CreateObject Failed patwadd Classic ASP Databases 3 February 7th, 2005 05:46 PM
Server.CreateObject Failed ckwizard77 Classic ASP Components 2 October 23rd, 2004 09:41 AM
Server.CreateObject("Outlook.Application") Dave Sell Classic ASP Professional 1 September 4th, 2004 01:44 PM





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