开发者

WCF Data Services Type Could Not Be Found

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 -开发者_如何学Go 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.


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" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜