简体   繁体   English

使用System.Net; 找不到IPEndPoint

[英]using System.Net; IPEndPoint not found

I'm new to monodevelop and csharp litle experience in the past. 过去,我是monodevelop和csharp litle经验的新手。

Trying to do this example: http://sharpsnmplib.codeplex.com/wikipage?title=600009&referringTitle=KB 尝试执行此示例: http ://sharpsnmplib.codeplex.com/wikipage?title=600009&referringTitle= KB

I get and error 我明白了

TestAsyncGet/Program.cs(32,32): Error CS0246: The type or namespace name `IPEndPoint' could not be found. TestAsyncGet / Program.cs(32,32):错误CS0246:找不到类型或名称空间名称“ IPEndPoint”。 Are you missing a using directive or an assembly reference? 您是否缺少using指令或程序集引用? (CS0246) (TestAsyncGet) (CS0246)(TestAsyncGet)

Thank you for any help. 感谢您的任何帮助。

Have in references System.Net also is complaining about: 参考文献System.Net中还抱怨:

Projects/TestAsyncGet/TestAsyncGet/Program.cs(13,13): Error CS0825: The contextual keyword `var' may only appear within a local variable declaration (CS0825) (TestAsyncGet) Projects / TestAsyncGet / TestAsyncGet / Program.cs(13,13):错误CS0825:上下文关键字“ var”可能仅出现在局部变量声明(CS0825)(TestAsyncGet)中

Running from the command line: 从命令行运行:

mono TestAsyncGet.exe System.FormatException: Input string was not in the correct format at System.Int64.Parse (System.String s) [0x00000] in :0 at TestAsyncGet.Program.Main (System.String[] args) [0x00000] in :0 mono TestAsyncGet.exe System.FormatException:输入字符串的格式不正确,位于System.Int64.Parse(System.String s)[0x00000]中,位于TestAsyncGet.Program.Main的:0中(System.String [] args)[0x00000 ]在:0中

GetRequestMessage message = new GetRequestMessage(0,
                VersionCode.V1,
                new OctetString("stvtelco"),
                new List<Variable> {new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.4"))});
    long ip = Int64.Parse("192.168.0.33");
            var endpoint = new IPEndPoint(new IPAddress(ip), 161);

            message.BeginGetResponse(endpoint, new UserRegistry(), endpoint.GetSocket(), ar => {
                var response = message.EndGetResponse(ar);
                Console.WriteLine(response);
            }, null);
            Console.Read();

Make sure you are: 确保您是:

  • building with the .NET 4.0 profile. .NET 4.0配置文件进行构建。 That will select the dmcs compiler and will enable the var keyword syntax; 这将选择dmcs编译器并启用var关键字语法;

  • have a reference to System.dll assembly in your project. 在您的项目中有对System.dll程序集的引用。 This is where System.Net namespace resides on the regular framework (that's a bit different for Silverlight since it has a System.Net.dll assembly); 这就是System.Net命名空间驻留在常规框架上的位置(对于Silverlight而言,这有点不同,因为它具有System.Net.dll程序集);

  • have a using System.Net; using System.Net; at the top of your file. 在文件的顶部。

With those conditions you should be able to compile this code correctly. 在这些条件下,您应该能够正确地编译此代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM