编辑- 我让它与 SL 3 运行时一起工作......我必须删除对 System.ServiceModel 和 System.Net 的所有旧引用并将它们从这个位置添加回来(我运行 x64 窗口)
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0
一旦我这样做了-它起作用了!抱歉,如果您仍然以 2.0 运行时为目标,但我想我会发布此更新,以防将来有人发现此页面...
这可能只是“我的问题”,因为我使用 x64 窗口......这是新的 proj 文件对于程序集引用的样子:
<Reference Include="System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\System.Net.dll</HintPath>
</Reference> <Reference Include="System.ServiceModel, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\System.ServiceModel.dll</HintPath>
</Reference>
=============== 下面的旧答案===============
我一直在尝试做同样的事情,但没有运气,所以我会说“目前无法做到”,这真的很烦人......
如果您查看 reference.cs 和发出的 .cs,则类的顶部会向您显示使用“添加服务引用”您会得到:
// This code was auto-generated by Microsoft.Silverlight.ServiceReference, version 2.0.5.0
使用 SlSvcUtil (顺便说一句 v3.0 工具)你得到:。
// This code was auto-generated by slsvcutil, version 3.0.40624.0
所以我认为你不能“向后移植”到 v2.0。不幸的是 - 您也不能在 3.0 运行时使用 SlSvcUtil!(我觉得这很可笑——或者我无法让它正常工作)
我的目标是 3.0 运行时并使用 SlSvcUtil 和“开箱即用”它告诉我
The type or namespace name 'FaultContractAttributeAttribute' does not exist
in the namespace 'System.ServiceModel' (are you missing an assembly reference?)
该类确实存在于 System.ServiceModel 3.0.* 中,但 Silverlight 使用的是 2.0.* ,但它不存在......最重要的是 - 尝试添加对 3.0 版本的引用,您会收到以下问候:
You can't add a reference to System.ServiceModel.dll as it was not built against the
Silverlight runtime. Silverlight projects will only work with Silverlight assemblies
所以即使你在 v3.0 上——你会是 SOL——就像我一样......
希望有人可以回复告诉我们该怎么做,但我认为这是不可能的......有人 - 请证明我错了!:)
对不起...