Solved

Class Namespace not Accessible by User Control

Posted on 2006-06-16
5
862 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

828 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