找不到 WCF 数据服务类型

发布于 2024-11-14 16:37:15 字数 1802 浏览 3 评论 0原文

我正在尝试将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

煮酒 2024-11-21 16:37:15

这是命名空间之间的冲突。我正在使用 Microsoft WCF Data Services 2011 CTP2,因此我必须将其添加到我的 system.web/compilation/assemblies 中的 web.config 文件中:

<add assembly="Microsoft.Data.Services, Version=4.99.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="Microsoft.Data.Services.Client, Version=4.99.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

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:

<add assembly="Microsoft.Data.Services, Version=4.99.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="Microsoft.Data.Services.Client, Version=4.99.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文