服务参考未定义

时间:2016-10-17 18:15:04

标签: c# wcf kentico

我在VS中为我的Kentico Web应用程序添加了一个wcf服务(SifService)引用。我没有选择任何高级选项。我刚刚提供了wsdl地址,提供了一个命名空间(SifService)并单击OK。服务引用似乎已成功添加。但是,当我尝试在下面的代码中创建客户端的实例时,VS说无法找到类型或命名空间“SifService”。我们刚刚从Kentico 8升级到Kentico 9.相同的代码在Kentico 8代码分支中运行良好。该问题仅出现在Kentico 9分支中。

var sifClient = new SifService.SifClient();

当我尝试在VS中运行该站点时,我在浏览器中收到此错误:

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: Reference.svcmap: Could not load file or assembly 'System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


Source Error: 


[No relevant source lines]

Source File: /App_WebReferences/SifService/    Line: 1

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.

注意:在将服务引用添加到SifService之前,一切正常。

1 个答案:

答案 0 :(得分:0)

有时它是视觉工作室的错误,清理解决方案,构建,关闭视觉工作室并再次构建,对我来说它工作了几次!