Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Windows Application
hi all,
 
i am developing windows application project using c#.
 
in my application am getting two errors, actually i had tried many ways but i coudnt find what it as happen in my code below.
 
my errors are:
 
The type or namespace name 'LogMsgType' could not be found (are you missing a using directive or an assembly reference?)
 
The type or namespace name 'DataMode' could not be found (are you missing a using directive or an assembly reference?)

 

 
my code is:
 

 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using CSOCR.Properties;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.IO.Ports;
using System.Threading;
 
namespace CSOCR
{
    public partial class Form1 : Form
    {
 
        // The main control for communicating through the RS-232 port
        private SerialPort comport = new SerialPort();
 
        // Various colors for logging info
        private Color[] LogMsgTypeColor = { Color.Blue, Color.Green, Color.Black, Color.Orange, Color.Red };
        
        // Temp holder for whether a key was pressed
        private bool KeyHandled = false;
 
        private Settings settings = Settings.Default;
        public Form1()
        {
            // Load user settings
            settings.Reload();
 
            // Build the form
            InitializeComponent();
 
            // Restore the users settings
            InitializeControlValues();
 
            // Enable/disable controls based on the current state
            EnableControls();
 
            // When data is recieved through the port, call this method
            comport.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
            comport.PinChanged += new SerialPinChangedEventHandler(comport_PinChanged);
        }
      
       
              
        private void Log(LogMsgType msgtype, string msg)           //  this is my first error
        {
            rtfTerminal.Invoke(new EventHandler(delegate
            {
                rtfTerminal.SelectedText = string.Empty;
                rtfTerminal.SelectionFont = new Font(rtfTerminal.SelectionFont, FontStyle.Bold);
                rtfTerminal.SelectionColor = LogMsgTypeColor[(int)msgtype];
                rtfTerminal.AppendText(msg);
                rtfTerminal.ScrollToCaret();
            }));
        }
       
        private DataMode CurrentDataMode                        // this is my second error
        {
            get
            {
                if (rbHex.Checked) return DataMode.Hex;
                else return DataMode.Text;
            }
            set
            {
                if (value == DataMode.Text) rbText.Checked = true;
                else rbHex.Checked = true;
            }
        }
    }
}
please find out my code above and let me know where i did mistake in my code,so that i can rectify my mistakes.
 
thanks in advance.
 
[edit]Code block added - OriginalGriff[/edit]
Posted 23-Apr-13 1:09am
Edited 23-Apr-13 1:20am
v2
Comments
AlluvialDeposit at 23-Apr-13 6:14am
   
In which assembly do you find DataMode and LogMsgType? Did you reference these assemblies in your project?
stellus at 23-Apr-13 6:50am
   
no

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Exactly how you fix this depends on where the two classes "LogMsgType" and "DataMode" are defined:
If they are within the same project, but in a different namespace then you need to add a using statement.
If they are in a different project, or in an external DLL, then you need both a reference to the project/DLL and a using statement.
 
Put your cursor in one of the two class names, and a blue line will appear at the beginning. Hover the mouse over the blue line and a drop down will appear. Open the drop down.
If it contains two solutions (a "using" solution and a fully qualified name) then you probably need a using statement, so select that. If is contains two solutions ("Generate class for 'xxx'" and "Generate new type...") then you need to add a reference as well.
  Permalink  
Comments
stellus at 23-Apr-13 8:06am
   
thanks for yr solution,
i tried your way which you mentioned by the above code,
but am not getting the drop down list.
what i do exactly ,
in which reference i can add?
 
thanks.
OriginalGriff at 23-Apr-13 8:28am
   
:laugh:
I can't tell you - it's your class, and only you know where it is! (Remember, I can't see your screen from here...)
Did you get the blue line?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 BillWoodruff 173
3 Sergey Alexandrovich Kryukov 170
4 PIEBALDconsult 160
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 23 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100