找不到类型或命名空间名称'OperationStatus'(您是否缺少using指令或程序集引用?) [英] The type or namespace name 'OperationStatus' could not be found (are you missing a using directive or an assembly reference?)

查看:123
本文介绍了找不到类型或命名空间名称'OperationStatus'(您是否缺少using指令或程序集引用?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想在一个单独的文件中编写函数定义,并根据需要从另一个文件中调用这些函数。我正在使用C#。我想要定义所有函数的文件如下 -



using System;



namespace WTA


{


static class FTPClient


{


{


public static class OperationStatus


{


public void OperationStatusOK()


{


byte [] data_OK = new byte [1024];


string result_OK ="< response result = \" ok \"< / response>" ;;



log(result_OK);


//编码为ASCII


data_OK = Encoding.ASCII .GetBytes(result_OK);


尝试


{


//将数据字节发送到连接的套接字


client.Send(data_OK,data_OK.Length,SocketFlags.None);


}


catch(ObjectDisposedException)


{


log(" ObjectDisposedException-> OperationStatusOK()");


}


catch(ArgumentOutOfRangeException)


{


log(" ArgumentOutOfRangeException-> OperationStatusOK()");


}


catch(ArgumentNullException)


{


log(" ArgumentNullException-> OperationStatusOK()");


}


catch(SocketException)


{


log(" SocketException-> OperationStatusOK()");


}


}


}


}


}



我想从中调用OperationStatusOK()函数的文件如下 -



使用System;



使用System.ComponentModel;


使用System.Data;


使用System.Drawing;


使用System.Text;


使用System.Windows.Forms;


使用System.IO;


使用System.Net;


using System .Net.Sockets;


使用System.Xml;


使用System.Diagnostics;


using System.Data.Common;


使用System.Threading;


使用System.Security.Permissions ;



namespace WTA


{


public partial class WTA :表格


{


................. ................................ //一些代码


................ ................................


OperationStatus OS = new OperationStatus(); // ERROR LINE


OS。 OperationStatusOK();


................................................ ...


................................................. ...... //一些代码


}


}


但在构建期间我收到错误 - 类型或命名空间名称'无法找到OperationStatus(您是否缺少using指令或程序集参考?)



我需要帮助很严重。提前谢谢。


解决方案

嗨Abhishek,


从第一堂课中删除这一行并尝试

静态类FTPClient

{


{





文件
如果它仍然不起作用,请告诉我。

问候,
Malleswar


I want to write function definitions in one separate file and call those functions according to necessity from another file. I am using C#.The file where i want to define all the function is as follows-

 

using System;

 

namespace WTA

{

   static class FTPClient

   {

      {

      public static class OperationStatus

      {

         public void OperationStatusOK()

         {

            byte[] data_OK = new byte[1024];

            string result_OK = "<response result=\"ok\"</response>";

 

            log(result_OK);

            //Encode to ASCII

            data_OK = Encoding.ASCII.GetBytes(result_OK);

            try

            {

               //Send bytes of data to the connected socket

               client.Send(data_OK, data_OK.Length, SocketFlags.None);

            }

            catch (ObjectDisposedException)

            {

               log("ObjectDisposedException->OperationStatusOK()");

            }

            catch (ArgumentOutOfRangeException)

            {

               log("ArgumentOutOfRangeException->OperationStatusOK()");

            }

            catch (ArgumentNullException)

            {

               log("ArgumentNullException->OperationStatusOK()");

            }

            catch (SocketException)

            {

               log("SocketException->OperationStatusOK()");

            }

         }

      }

   }

}

 

The file from which I want to call OperationStatusOK() function is as follows-

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.IO;

using System.Net;

using System.Net.Sockets;

using System.Xml;

using System.Diagnostics;

using System.Data.Common;

using System.Threading;

using System.Security.Permissions;

 

namespace WTA

{

   public partial class WTA : Form

   {

         .................................................//some codes

          ................................................

         OperationStatus OS = new OperationStatus();//ERROR LINE

         OS. OperationStatusOK();

        ...................................................

.......................................................//some codes

     }

}

But during build i am getting error-The type or namespace name 'OperationStatus' could not be found (are you missing a using directive or an assembly reference?)

 

I require help badly. Thanks’ in advance.

        

解决方案

Hi Abhishek,


Remove this lines from the first class and try


static class FTPClient

   {

      {



}

}


Please let me knwo if it still does not work.

Regards,
Malleswar


这篇关于找不到类型或命名空间名称'OperationStatus'(您是否缺少using指令或程序集引用?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆