[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Can't access a class developed outside of native namespace

Posted on 2007-08-02
4
Medium Priority
?
263 Views
Last Modified: 2008-01-09
OK, I've looked at this much too long and am only breaking it further.  I have a class I generated outside of my solution namespace.  I've add its project to my solution, I've add the reference .dll for the class as well.  I cannot "get" to the methods or properties defined within the class.  They are declared public, not sure what to do.........:

Class code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;


//using System.Text.Encoding;

namespace Keithley2701ClassLib
{
    //class General
    //{
    //}

    public static class General
    {

        //
        // Version 1.1
        // EEB
        //
        public const Int16 port = 1394;

        public static System.Net.Sockets.TcpClient KI2701Client = new System.Net.Sockets.TcpClient();

        public static System.Net.Sockets.NetworkStream KI2701Stream;

        public static string KIstatus;

        public static bool connected = false;

        public static string ip = "192.168.254.54";

        public static byte[] KIByte;

        public static string KIData;

        public static bool front = false;

        private static bool dis = false;




        public static void send(string KIData)
        {
            KI2701Stream = KI2701Client.GetStream();
            KIData = (KIData + "\r");
            //  Add control reset to the command line
            KIByte = System.Text.ASCIIEncoding.ASCII.GetBytes(KIData);
            //  Convert to byte
            KI2701Stream.Write(KIByte, 0, KIData.Length);
            //  Send data
        }

        public static void connect(string ip)
        {
            object zz;
            object z;
            try
            {
                KI2701Client.Connect(ip, port);
                KI2701Stream = KI2701Client.GetStream();
                if ((KI2701Stream.CanWrite && KI2701Stream.CanRead))
                {
                    connected = true;
                }
                else
                {
                    connected = false;
                }
            }
            catch (Exception e)
            {
                System.Net.Sockets.SocketException errnum = new System.Net.Sockets.SocketException();
                // .ErrorCode()
                string aa;
                switch (errnum.ErrorCode)
                {
                    case 10060:
                        MessageBox.Show("Could not connect to the 2701, please recheck your connections and network settings and try again ", "Time Out Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    case 10061:
                        MessageBox.Show("Could not open connection because instrument has an open connection to another application.  Close th" +
                             "e connected application or power cycle the instrument to close existing connection", "Connection Refused !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MessageBox.Show(("Error has occured:  "
                              + (errnum.ErrorCode + ("  " + e.Message))), "Error has been detected !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                }
            }
        }



        public static void disconnect()
        {
            if ((connected == true))
            {
                send("*rst");
                connected = false;
                KI2701Stream.Close();
                KI2701Client.Close();
                KI2701Client = null;
                dis = true;
            }
            connected = false;
        }

        public static void KI2701send(string data)
        {
            // Send data
            byte senddata;
        }

        public static void KIInput(ref string KIstatus)
        {
            send("SYST:FRSW?");
            KI2701Read(ref KIData);
            if ((KIData == "1"))
            {
                KIstatus = "Front";
            }
            else
            {
                KIstatus = "Rear";
            }
        }

        public static void KI2701Read(ref string KIdata)
        {
            //  Read network stream into byte buffer
            byte[] bytes = new byte[KI2701Client.ReceiveBufferSize];
            KI2701Stream.Read(bytes, 0, KI2701Client.ReceiveBufferSize);
            KIdata = System.Text.ASCIIEncoding.ASCII.GetString(bytes);
            //  Debug.WriteLine(KIdata)
        }
    }



}
 


<Snippets of calling form code>
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Dart.PowerTCP.Sockets;
using System.Diagnostics;
using System.Data;
using System.Text;
using System.Configuration;
using System.Data.SqlClient;
using System.Threading;
using Syncfusion.Windows.Forms.Tools;
using Dart.PowerTCP;

using global::Keithley2701ClassLib;



namespace Inhallation
{
    public partial class frmVoltmeter : Form
    {
        public frmVoltmeter()
        {
            InitializeComponent();
        }

        #region Windows Control stuff
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label11;
        private System.Windows.Forms.TextBox txtStatus;
        private System.Windows.Forms.Label label12;
        private System.Windows.Forms.Label label13;
        private System.Windows.Forms.Label label14;
        private System.Windows.Forms.TextBox txtStartTime;
        private System.Windows.Forms.TextBox txtElapsedTime;
        private System.Windows.Forms.TextBox textBox4;
        private System.Windows.Forms.Label label15;
        private System.Windows.Forms.ComboBox cboPeakView;
        private System.Windows.Forms.Button btnStop;
        private System.Windows.Forms.Button btnStartExposure;
        private System.Windows.Forms.Timer timerGap;
        //private System.ComponentModel.IContainer components;
        #endregion
        public byte[] buffer = new byte[1024];
        public byte[] HPbuffer = new byte[1024];
        public byte[] DAQbuffer = new byte[1024];
        public bool HPInit = true;
        public bool DAQInit = true;
        //private Dart.PowerTCP.Sockets.Tcp tcpValve;
        //private Dart.PowerTCP.Sockets.Tcp tcpHP;
        private bool ValveConnected = false;
        private bool HPConnected = false;
        private bool DAQConnected = false;
        public int prevValvepos = 0;
        private Dart.PowerTCP.Sockets.Tcp tcp2701;
        private System.Windows.Forms.TextBox txt2701;
        private System.Windows.Forms.TextBox txtDisplay1;
        // private Dart.PowerTCP.Sockets.Tcp tcpValve;
        //private Dart.PowerTCP.Sockets.Tcp tcp2701;
        //private Dart.PowerTCP.Sockets.Tcp tcpHP;
        private System.Windows.Forms.Timer timer2701;
        private Dart.PowerTCP.Sockets.Tcp tcp2701Reset;
        string strConn = ConfigurationSettings.AppSettings["DSN"];
        public ArrayList arChamberInfo = new ArrayList();
        public ArrayList arTimers = new ArrayList();

        private global::Keithley2701ClassLib.Class1 K2701 = new Class1();

   
        If I try to access anything under K2701, I get the standard options, not the exposed methods,  What's wrong?  Thanks!


0
Comment
Question by:jvalescu
  • 2
3 Comments
 
LVL 21

Expert Comment

by:Yurich
ID: 19622404
Are you sure you listed it in your postage correctly? There is no Class1 defined in the Keithley2701 namespace :( only General. Another point - you have everything static, you don't need to create an instance of the class in this case, just use class-scope, not instance-scope, e.g:

Keithley2701ClassLib.send( "..." );

and lastly, if you added this project to your project, why do you use global? just doing this:

using Keithley2701ClassLib;

Cheers,
Yurich

should give you access to the namespace and enable intellisense for the class.
0
 
LVL 19

Expert Comment

by:drichards
ID: 19622433
And remove the assembly reference if you have put the project into the main solution.  I don't know which one has precedence, but the assembly reference is not per configuration, so you can only reference the debug or release assembly and it will be for both configurations of the dependent project.


0
 
LVL 21

Accepted Solution

by:
Yurich earned 2000 total points
ID: 19816984
I think an appropriate help was provided.

Regards,
Yurich
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Integration Management Part 2
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

834 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