找不到 WCF 数据服务类型
我正在尝试将 WCF 数据服务从 VS2010 中托管的移动到开发 Web 服务器。当我将代码移至 IIS7 应用程序时,出现以下错误:
类型“Aaa.Bbb.Services.ZzzEntities”,作为 ServiceHost 指令中的 Service 属性值提供,或在配置元素 system.serviceModel/serviceHostingEnvironment/ 中提供找不到服务激活。
ZzzEntities.svc
<%@ ServiceHost
Language = "C#"
Factory = "System.Data.Services.DataServiceHostFactory,
System.Data.Services, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
Service = "Aaa.Bbb.Services.ZzzEntities" %>
ZzzEntities.svc.cs
using Aaa.Bbb.Domain.Entities;
using System.Data.Services;
using System.Data.Services.Common;
using System.ServiceModel.Web;
namespace Aaa.Bbb.Services {
public class ZzzEntities:DataService<Domain.EntityFramework.Context> {
public static void InitializeService(DataServiceConfiguration config) {
config.UseVerboseErrors = true;
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion =
DataServiceProtocolVersion.V3;
}
}
}
编辑:此外,还编译了 Aaa.Bbb.Services.dll
并在 IIS7 Web 应用程序的 \bin 目录中。
编辑:按照此处的说明进行操作时,我在尝试执行以下操作时收到以下错误创建 ZzzEntities
的实例 - System.TypeLoadException:无法从程序集中加载类型“ZzzEntities” 'Aaa.Bbb.Services,版本=1.0.0.0,文化=中性,PublicKeyToken=null'。
使用 .NET Reflector,我可以清楚地看到 Aaa.Bbb.Services.dll 包含一个名为 ZzzEntities
的类,因此我真的不明白为什么无法创建我的类型。
I'm trying to move a WCF Data Service from hosted within VS2010 to a development web server. When I move the code to an IIS7 application, I get this error:
The type 'Aaa.Bbb.Services.ZzzEntities', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
ZzzEntities.svc
<%@ ServiceHost
Language = "C#"
Factory = "System.Data.Services.DataServiceHostFactory,
System.Data.Services, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
Service = "Aaa.Bbb.Services.ZzzEntities" %>
ZzzEntities.svc.cs
using Aaa.Bbb.Domain.Entities;
using System.Data.Services;
using System.Data.Services.Common;
using System.ServiceModel.Web;
namespace Aaa.Bbb.Services {
public class ZzzEntities:DataService<Domain.EntityFramework.Context> {
public static void InitializeService(DataServiceConfiguration config) {
config.UseVerboseErrors = true;
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion =
DataServiceProtocolVersion.V3;
}
}
}
EDIT: Also, Aaa.Bbb.Services.dll
is compiled and in the \bin directory of the IIS7 web application.
EDIT: Following the instructions here I get the following error when trying to create an instance of ZzzEntities
- System.TypeLoadException: Could not load type 'ZzzEntities' from assembly 'Aaa.Bbb.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Using .NET Reflector I can clearly see that the Aaa.Bbb.Services.dll contains a class called ZzzEntities
so I'm really lost about why my type can't be created.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是命名空间之间的冲突。我正在使用 Microsoft WCF Data Services 2011 CTP2,因此我必须将其添加到我的
system.web/compilation/assemblies
中的 web.config 文件中:This was a conflict between namespaces. I'm using Microsoft WCF Data Services 2011 CTP2, so I had to add this to my web.config file in
system.web/compilation/assemblies
: