Solved

Class Namespace not Accessible by User Control

Posted on 2006-06-16
5
857 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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)

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now