wcf数据服务可以在iisexpress上运行,但不能在iis中运行

问题描述 投票:-1回答:1

我写了一个非常简单的WCF数据服务。但我发现在IIS7.5上部署时无法正常工作。它只能在IIS Express上运行。

[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]   
public class WcfDataService : DataService<ConfigurationDataEntities>
{
    // This method is called only once to initialize service-wide policies.
    public static void InitializeService(DataServiceConfiguration config)
    {
        // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
        // Examples:
        config.UseVerboseErrors = true;
         config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
        // config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
    }
}

这是Web配置文件

<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework5" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="ConfigurationDataEntities" connectionString="metadata=res://*/ConfigurationDataModel.csdl|res://*/ConfigurationDataModel.ssdl|res://*/ConfigurationDataModel.msl;provider=System.Data.SqlServerCe.4.0;provider connection string=&quot;data source=|DataDirectory|\ConfigurationData.sdf;password=123;persist security info=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5" />
  </system.web>

  <entityFramework5>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework5>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>
</configuration>

这是错误消息:服务器在处理请求时遇到错误。请参阅服务器日志以获取更多详

在System.Data.Entity.DbContext..ctor(String nameOrConnectionString)在WcfDataServiceTest.ConfigurationDataEntities..ctor()位置c:\ Projects \ WcfDataServiceTest \ WcfDataServiceTest \ ConfigurationDataModel.Context.cs:行号18在invoke_constructor()在System中。 Data.Services.DataService1.CreateDataSourceInstance() 在 System.Data.Services.DataService1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider&metadataProviderInstance,IDataServiceQueryProvider&queryProviderInstance,BaseServiceProvider&builtInProvider,Object&dataSourceInstance)在System.Data.Services.DataService1.CreateProvider() 在 System.Data.Services.DataService1.HandleRequest()在System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody)在SyncInvokeProcessRequestForMessage (Object,Object [],Object [])在System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance,Object [] inputs,Object []&outputs)在System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&rpc)在System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(M essageRpc&rpc)在System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&rpc)在System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

wcf iis
1个回答
1
投票

有人可以帮帮我吗?

WCF可以帮助您:

请参阅服务器日志以获取更多详

Configure tracing并查看异常发生的位置。由于它发生在DbContext构造函数中,我假设有一些数据库访问。检查运行应用程序池的帐户,并验证此帐户是否可以访问数据库。

© www.soinside.com 2019 - 2024. All rights reserved.