Solved

Class Namespace not Accessible by User Control

Posted on 2006-06-16
5
861 Views
Last Modified: 2013-11-19
Hi

VS 2005
VB.NET & C#

I popped a couple of classes into my site from here:
http://aspnet.4guysfromrolla.com/articles/020205-1.aspx

Each of the three classes start:
////////////////////////////////////////////////////////////////////////////
 using System;
using System.Collections;
using System.Web;

namespace ParameterPasser
{
....
....
////////////////////////////////////////////////////////////////////////////

To use I include an Imports statement in my forms:

////////////////////////////////////////////////////////////////////////////
Imports ParamaterPasser
....
....

        ' Pass textbox values to MyPage.aspx

        Dim sesssionWrapper As SessionParameterPasser = New SessionParameterPasser("MyPage.aspx")

        ' Add some values

        sesssionWrapper("Start_Date") = Start_Date

        ' Redirect to the page, passing the parameters in the querystring

        sesssionWrapper.PassParameters() This worked great but has recently failed. I get the following warning:
////////////////////////////////////////////////////////////////////////////

This works great in everyting but a user control (ascx  file) where I get this warning:

Namespace or type specified in the Imports 'ParamaterPasser' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

and the following error:

Type 'SessionParameterPasser' is not defined.

Is there some sort of gotcha re user controls and namespaces defined in a class of the same project?

Please let me know if you need me to supply more information.
0
Comment
Question by:pootle_flump
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:kGenius
ID: 16926644
Is there a constructor provided in the C# class?

Like
public class MyClass {

'constructor
public MyClass() { }

}
0
 
LVL 7

Accepted Solution

by:
kGenius earned 500 total points
ID: 16926655
Another thougth.
When importing ParameterPasser, are you sure it is a top-level namespace? There's no other default namespace in the project properties provided? Then you should import xxx.ParameterPasser where xxx is the default namespace...

cf this MSDN article: http://support.microsoft.com/kb/304260/EN-US/

Hope this'll help
0
 
LVL 11

Author Comment

by:pootle_flump
ID: 16932626
Hi kGenius

Thanks for taking the time to help.

>>Is there a constructor provided in the C# class?
Yeppers:
Abstract class:
////////////////////////////////////////////
using System;
using System.Collections;
using System.Web;

namespace ParameterPasser
{
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    public abstract class BaseParameterPasser
    {
        #region Member Variables
        private string url = string.Empty;
        #endregion

        #region Constructors
        public BaseParameterPasser()
        {
            if (HttpContext.Current != null)
                url = HttpContext.Current.Request.Url.ToString();
        }

        public BaseParameterPasser(string Url)
        {
            this.url = Url;
        }
        #endregion
////////////////////////////////////////////
Instantiable class:
////////////////////////////////////////////
using System;
using System.Web;

namespace ParameterPasser
{
    /// <summary>
    /// Summary description for SessionParameterPasser.
    /// </summary>
    public class SessionParameterPasser : BaseParameterPasser
    {
        #region Constructors
        public SessionParameterPasser() : base() { }
        public SessionParameterPasser(string Url) : base(Url) { }
        #endregion
////////////////////////////////////////////

>>Another thougth.
I will follow it through and report back

Thanks
0
 
LVL 11

Author Comment

by:pootle_flump
ID: 16932655
Hmmmmm.

Ok - it looks like it was intermittant\ a bug. I was just refreshing my memory of the problem (having submitted it on Friday).

The Imports ParameterPasser line was underlined and causing the error. It was spelt correctly (I had copied and pasted from a working form). I typed in Imports again and what do you know - ParametPasser appeared in Intellisense (it wasn't there on Friday).

I've had similar problems with VS2005 before but normally closing down VS and reopening sorts it out. It hadn't done so this time so I posted the question. I guess it really wanted a restart lol.

Many thanks for your help kGenius
0
 
LVL 7

Expert Comment

by:kGenius
ID: 16932668
many thanx for the points ...
Glad you figured it out!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Login 17 50
SQL Exceptions 3 43
Need a starter for ETL protocol? 4 55
Initial get page response times and IIS8 15 49
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question