我写了一个非常简单的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;
}
}
这是webconfig文件
<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="data source=|DataDirectory|\ConfigurationData.sdf;password=123;persist security info=True"" 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.DataService 1.CreateDataSourceInstance() 在 System.Data.Services.DataService
1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider&amp; metadataProviderInstance,IDataServiceQueryProvider&amp; queryProviderInstance,BaseServiceProvider&amp; builtInProvider,Object&amp; dataSourceInstance)在System.Data.Services.DataService 1.CreateProvider() 在 System.Data.Services.DataService
1.HandleRequest( )在System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody)在SyncInvokeProcessRequestForMessage(Object,Object [],Object [])在System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance,Object [] inputs,Object []&amp; outputs)在System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)在System.ServiceModel.Dispatcher.ImmutableDispatchRuntim e.ProcessMessage5(MessageRpc&安培; rpc)在System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)在System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
答案 0 :(得分:1)
任何人都可以帮助我?
WCF可以帮助您:
有关详细信息,请参阅服务器日志。
Configure tracing并查看异常发生的位置。由于它发生在DbContext
构造函数中,我假设有一些数据库访问。检查运行应用程序池的帐户,并验证此帐户是否可以访问数据库。