Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 May 11th, 2005, 01:57 AM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem accessing a .dll component in asp.net page

Hi, I'm a beginner of ASP.NET. When I was reading Wrox's ASP.NET 1.1 for beginner, I couldn't get the example in Chapter 13 to work. Please help me to tackle this problem, the exapmle contains a helloworld component that returns a string to the aspx page, but I couldn't get it to run, the server gives me an error cs0246:

CS0246: The type or namespace name 'WroxComponents' could not be found (are you missing a using directive or an assembly reference?)

Line 2: <%@ import Namespace="WroxComponents" %>
Source File: C:\htdocs\aspx\soccer\HellowWorldExample.aspx Line: 2


Here is my code for the component:
// HelloWorld.cs
namespace WroxComponents
{
   using System;
   public class HelloCS
   {
      public HelloCS() { }

      public String SayHello()
      {return "Hello World - I'm a C# component!";}
   }
}

I compiled it with the command:
csc /t:library /r:System.dll /out:bin/HelloWorldCS.dll HelloWorld.cs


and my aspx page looks like this:
//aspx page,
<%@ Page Language="C#" %>
<%@ import Namespace="WroxComponents" %>
<script runat="server">

    public void Page_Load()
    {
      HelloCS MyCSComponent = new HelloCS();
      lblMessageCS.Text = aaa.MyCSComponent.SayHello();
    }

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            Our component says:
        </p>
        <p>
            <asp:Label id="lblMessageCS" runat="server"></asp:Label>
        </p>
    </form>
</body>
</html>


 
Old May 11th, 2005, 09:47 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Where does this page live on your server?
How are the IIS virtual directories set up?

The path C:\htdocs\aspx\soccer must exist as a virtual directory in IIS so that the application will look at the bin folder underneath it. Otherwise, the .NET runtime will not find the .DDL file you compiled.

-Peter
 
Old May 11th, 2005, 08:05 PM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

planoie,thanks for your post.
I run my aspx pages in Apache Server (I used Apache's CLI project and the mod_aspdotnet module to run asp.net pages with apache)
So I'm wondering if the asp.net application will act as if it's ran in IIS. If so how can i setup the virtual directory thing?
Thanks a lot Peter.

 
Old May 11th, 2005, 08:14 PM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

to provide more information, C:\htdocs\ is setup as my web root, so is virtual hosting still necessary?


 
Old May 11th, 2005, 09:55 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I've never used ASP.NET on anything other than IIS so I don't know how it will behave in other environments.

-Peter
 
Old May 10th, 2006, 07:31 AM
Registered User
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Put the file in the C:\htdocs\bin folder and it should work.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing a .NET DLL from Classic ASP crmpicco ASP.NET 1.0 and 1.1 Basics 11 September 9th, 2007 09:51 PM
Accessing dataset obj (in .dll) from an aspx page arulkumar ASP.NET 1.0 and 1.1 Basics 2 August 8th, 2005 10:29 PM





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