1
votes

I'm new to monodevelop and csharp litle experience in the past.

Trying to do this example: 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. Are you missing a using directive or an assembly reference? (CS0246) (TestAsyncGet)

Thank you for any help.

Have in references System.Net also is complaining about:

Projects/TestAsyncGet/TestAsyncGet/Program.cs(13,13): Error CS0825: The contextual keyword `var' may only appear within a local variable declaration (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

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();
1
IPEndPoint should work as long as you have using System.Net; at the top of the file. Is your code exactly as the one in the sample? The other error indicates you also have some syntactic error in your code. - svick
I'm now trying to run this code from the command line: See above for details please. - Fernando André
Int64.Parse("192.168.0.33") doesn't make any sense. Just use IPAddress.Parse("192.168.0.33") to get the IPAddress. - svick

1 Answers

1
votes

Make sure you are:

  • building with the .NET 4.0 profile. That will select the dmcs compiler and will enable the var keyword syntax;

  • have a reference to System.dll assembly in your project. 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);

  • have a using System.Net; at the top of your file.

With those conditions you should be able to compile this code correctly.