Solved

Referencing a method from another namespace

Posted on 2006-10-30
3
272 Views
Last Modified: 2010-04-16
I must be missing something simple! Please help before I start banging  my head against my desk!!! I am referencing a method in a class from a different namespace. I cannot pick up my other method with the intellisense in the class that I am trying to call it fromHere is some sample code below:

using mytest2.x

namespace mytest
{
public class ServerOptions : System.Windows.Forms.Form
    {
          //***I can't this line below to appear in intellisense
           ExcelPreferences
    }
}

**************************************************
This code below is another .cs file:
**************************************************

using System;
using System.Collections.Generic;
using System.Text;

namespace mytest2.x
{
    class ExcelPreferences
    {
        const string constEnableViewDataInExcel = "EnableViewDataInExcel";
        const string constDefaultViewDataInExcel = "true";

        public ExcelPreferences()
        {

        }

        /// <summary>
        /// Gets or sets the boolean for the enable function.
        /// </summary>
        public static bool EnableViewDataInExcel
        {
            get
            {
                RegistryPreferences m_pPreferences = new RegistryPreferences();
                return (bool.Parse(m_pPreferences.GetPreference(constEnableViewDataInExcel, constDefaultViewDataInExcel)));
            }
            set
            {
                RegistryPreferences m_pPreferences = new RegistryPreferences();
                m_pPreferences.SetPreference(constEnableViewDataInExcel, value.ToString());
            }
        }
    }
}
0
Comment
Question by:lmred
3 Comments
 
LVL 13

Accepted Solution

by:
joechina earned 125 total points
Comment Utility
your class ExcelPreferences is private.
Change it to public
0
 
LVL 6

Expert Comment

by:der_jth
Comment Utility
Actually, ExcelPreferences is internal (that is the default visibility for top-level classes). But yes, making it "public class ExcelPreferences" will do the trick, as will compiling both the files into a single assembly (csc /out:myprog.exe first.cs second.cs, or making them a single project in Visual Studio).
0
 
LVL 1

Author Comment

by:lmred
Comment Utility
I don't believe this!!! I wasted hours on such a stupid mistake. I didn't even notice that because I thought the default was public. Thanks so much guys!!!

Lmred
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Put text in a picture ASP.NET C# 2 35
Handling arrays 14 33
c#.net application + check if already running 5 48
Duplicate a row 2 28
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

763 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

7 Experts available now in Live!

Get 1:1 Help Now