Cook Computing

.NET 2.0 May Break XML-RPC.NET Apps

November 6, 2005 Written by Charles Cook

In May I reported to the MSN Product Feedback Center a problem with .NET 2.0 beta 2 which broke existing XML-RPC.NET applications. The bug report was later marked as fixed, in particular "This bug will be fixed in RTM milestone.". Unfortunately the problem still exists in the release version of .NET 2.0.

Therefore any applications which create a XML-RPC.NET proxy based on an interface which is not declared as public will fail on the call to XmlRpcProxyGen.Create. For example, this example will fail:


[XmlRpcUrl("http://www.cookcomputing.com/sumAndDiff.rem")] 
interface ISumAndDiff
{ 
  [XmlRpcMethod] 
  SumAndDiffValue SumAndDifference(int x, int y);
}

static void Main(string[] args)
{
  ISumAndDiff proxy = (ISumAndDiff)XmlRpcProxyGen.Create(typeof(ISumAndDiff));
  SumAndDiffValue ret = proxy.SumAndDifference(2, 3);
}

The workaround is to specify that an earlier version of the .NET runtime should be used with the application, by creating or modifying the application config file. For example, if your application's executable is myapp.exe, the application config file is called myapp.exe.config and is placed in the same directory as the executable. It needs to specify the supported runtime as follows:


<?xml version ="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v1.1.4322" /> 
  </startup>
</configuration> 

This example uses version 1.1 of the runtime. To check which pre-2.0 versions of the runtime are installed on your machine, run the following commands in a command prompt window:


cd %windir%\microsoft.net\framework
dir v*

If you are building an application, the solution is to ensure that any interfaces used in XmlRpcProxyGen.Create are public.