cannot convert from 'method group'?

Nov 9, 2010 at 8:56 AM

Getting error:

Error 2 Argument '4': cannot convert from 'method group' to 'ARSoft.Tools.Net.Dns.DnsServer.ProcessQuery'

on the line:

server = new DnsServer(IPAddress.Any, 1, 1, processQuery);

public CDNSrelay()        
{            
using(server = new DnsServer(IPAddress.Any, 1, 1, processQuery))            
{                
server.ExceptionThrown += new EventHandler<ExceptionEventArgs>(server_ExceptionThrown);                            
}        
}

private DnsMessage processQuery(DnsMessage query, IPAddress clientAdress, ProtocolType protocol)        
{
....
}

 

anyone has any idea?

 

Dec 3, 2010 at 1:17 AM

The basic example in the documentation doesn't seem to apply to the current version of the DLL.  Below is my update version to the example.  It should answer your question:

using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Collections.Generic;
using ARSoft.Tools.Net.Dns;
using ARSoft.Tools.Net.Spf;

public class DNS_Server
{
	// Void Main
	static void Main(string[] args)
	{
		DnsServer server = new DnsServer(IPAddress.Any, 10, 10, ProcessQuery);
		
		server.ExceptionThrown += new EventHandler<ExceptionEventArgs>(server_ExceptionThrown);
		server.Start();

		Console.WriteLine("Press any key to stop server");
		Console.ReadLine();

	}
	
	// Handle DNS Requests
	static DnsMessage ProcessQuery(DnsMessageBase qquery, IPAddress clientAddress, ProtocolType protocol)
	{
		DnsMessage query = qquery as DnsMessage;
		query.IsQuery = false;

		if ((query.Questions.Count == 1)
		  && (query.Questions[0].RecordType == RecordType.Txt)
		  && (query.Questions[0].Name.Equals("example.com", StringComparison.InvariantCultureIgnoreCase)))
		{
			query.ReturnCode = ReturnCode.NoError;
			query.AnswerRecords.Add(new TxtRecord("example.com", 3600, "Hello world"));
		}
		else
		{
			query.ReturnCode = ReturnCode.ServerFailure;
		}

		return query;
	}

	// Capture any DNS server exceptions
	static void server_ExceptionThrown(object sender, ExceptionEventArgs e)
    {
        Console.WriteLine(e.Exception.ToString());
    }
	
}

Coordinator
Feb 19, 2011 at 3:34 PM

I've just updated the sample.