Solved

Class Namespace not Accessible by User Control

Posted on 2006-06-16
5
867 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

630 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