2
votes

I'm trying to follow this tutorial to create a proxy class for my WCF service for a MonoTouch project, but when I run the command

C:\Program Files\Microsoft SDKs\Silverlight\v3.0\Tools\SlSvcUtil.exe /noConfig http://yourdomain/yourservice/wsdl

I get the following error:

Error: Could not load file or assembly 'C:\Program Files (x86)\Microsoft Silverlight\5.0.61118.0\System.Runtime.Serialization.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Looking under C:\Program Files (x86)\Microsoft SDKs\Silverlight\v3.0\Libraries\Client doesn't have a System.Runtime.Serialization.dll. Maybe that's the problem and it tries to use the latest .net dll, which won't work with Silverlight.

Any ideas?

2
According to MT support there might be an issue when Silverlight 5 is installed. I was able to create the proxy on another machine without Silverlight 5 installed. - Jonas Stawski

2 Answers

3
votes

This seems to be an issue when multiple SDKs (WP7.1, WP7.1.1, Silverlight 3, 4, or 5) are installed on the same machine. The solution is to tell SlSvcUtil to use the right assembly and .net version by adding an SlSvcUtil.exe.config file to the same folder where SlSvcUtil lives, which in my case is %PROGRAMFILES(x86)%\Microsoft SDKs\Silverlight\v3.0\Tools:

<?xml version ="1.0"?> 
<configuration> 
 <startup> 
  <supportedRuntime version="v4.0"/> 
  <supportedRuntime version="v2.0.50727"/> 
 </startup> 
</configuration>
1
votes

Why not just create a new Silverlight 3.0 project with Visual Studio 2010 and then add the service the Visual Studio way..

Then you can grab the code generated and import that code into MonoTouch..

As far as the command line goes, I bet it does something like this:

slsvcutil http://yourdomain.com/yourservice/wsdl /edb /namespace:"*,SilverlightApplication1.ServiceReference1" /ct:System.Collections.ObjectModel.ObservableCollection`1 /r:"%PROGRAMFILES%\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\System.Windows.dll"

At least the command line utility reports this is what it does when creating a service reference from VS.