2

我有一个基于从 MySQL 模式创建的 EntityFramework 模型创建为 WFC 数据服务的 Web 服务。当我在 Visual Studio 中运行 Web 服务时,会创建 Web 服务并且我能够检索数据。我在本地运行测试,但 Web 服务连接到远程数据库(MySQL-net/connector 6.6.4.0)。它运行得像个冠军。

当我将数据服务发布到我的共享主机提供商时,我的问题就开始了。当我这样做时,我收到以下错误消息:

    The server encountered an error processing the request. The exception message is 'Exception has been thrown by the target of an invocation.'. See server logs for more details. The exception stack trace is:

at System.RuntimeFieldHandle.GetValue(RtFieldInfo field, Object instance, 
RuntimeType fieldType, RuntimeType declaringType, Boolean& domainInitialized)
at System.Reflection.RtFieldInfo.InternalGetValue(Object obj, Boolean     doVisibilityCheck, Boolean doCheckConsistency)
at System.Reflection.RtFieldInfo.GetValue(Object obj)
at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
at system.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)
at system.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config)
at System.Data.Entity.Internal.LazyInternalConnection.Initialize() 
at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel() 
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() 
at System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes()
at System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext() at lambda_method(Closure , Object ) 
at System.Data.Services.Providers.DbContextHelper.GetObjectContext(Object o) 
at System.Data.Services.Caching.MetadataCache`1.TryLookup(Type serviceType, Object dataContextInstance) 
at System.Data.Services.Providers.BaseServiceProvider.LoadMetadata() 
at System.Data.Services.DataService`1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider& metadataProviderInstance, IDataServiceQueryProvider& queryProviderInstance, BaseServiceProvider& builtInProvider, Object& dataSourceInstance) 
at System.Data.Services.DataService`1.CreateProvider() 
at System.Data.Services.DataService`1.HandleRequest() 
at System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody) 
at SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] ) 
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) 
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) 
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

我的 Web.Config 文件如下所示:

    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
       <system.web>
        <compilation debug="true" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          </assemblies>
        </compilation>
        <customErrors mode="Off"></customErrors>
      </system.web>
      <connectionStrings>
        <add name="UgyvediAdatbazisEntities" connectionString="metadata=res://*/ugyvediDbModell.csdl|res://*/ugyvediDbModell.ssdl|res://*/ugyvediDbModell.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=UgyvediAdatbazis.db.10115243.hostedresource.com;user id=UgyvediAdatbazis;password=*******;database=UgyvediAdatbazis&quot;" providerName="System.Data.EntityClient" />
      </connectionStrings>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="v11.0" />
          </parameters>
        </defaultConnectionFactory>
      </entityFramework>
      <system.serviceModel>
        <diagnostics>
          <messageLogging logMalformedMessages="true"
                          logMessagesAtServiceLevel="true"
                          logMessagesAtTransportLevel="true"
                          logEntireMessage="true"
                          maxMessagesToLog="10000"/>
        </diagnostics>
        <behaviors>
          <serviceBehaviors>
            <behavior name="Hibajelzes" >
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
          <webHttpBinding>
            <binding name="NoAuth">
              <security mode="None">
                <!--<transport clientCredentialType="None"></transport>-->
              </security>               
            </binding>
          </webHttpBinding>
          <basicHttpBinding>
            <binding name="NoAuth">
              <security mode="None"></security>
            </binding>
            <binding name="BasicAuth">
              <security mode="Transport">
                <transport clientCredentialType="Basic" />
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <services>
          <service name="UgyvediWebApp.UgyvediDataService" behaviorConfiguration="Hibajelzes">
            <endpoint address=""
                      binding="webHttpBinding"
                      bindingConfiguration="NoAuth"
                      contract="System.Data.Services.IRequestHandler">          
            </endpoint>
          </service>
        </services>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">

          <baseAddressPrefixFilters>
            <!--<add prefix="http://www.omegabridge.com/ugyvediservice/"/>-->
          </baseAddressPrefixFilters>
        </serviceHostingEnvironment>
      </system.serviceModel>

      <system.data>
        <DbProviderFactories>
          <add
                name="MySQL Data Provider"
                invariant="MySql.Data.MySqlClient"
                description=".Net Framework Data Provider for MySQL"
                type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, 
                      Version=6.6.4.0, Culture=neutral, 
                      PublicKeyToken=c5687fc88969c44d"
            />
        </DbProviderFactories>

      </system.data>

      <system.webServer>
        <httpErrors errorMode="Detailed"/>
        <asp scriptErrorSentToBrowser="true"/>
      </system.webServer>

    </configuration>

我认为我的问题出在 MySQL 连接器上,但我无法弄清楚到底是什么。MySQL.Data、MySQL.Data.Entity 和 MySQL.Web 被引用并设置为 Copy Local。我什至尝试使用嵌入式数据服务诊断,但 wcf 跟踪文件只返回之前显示的堆栈跟踪。

请。如果有小伙子有任何想法如何解决这个问题,请与我分享。

4

0 回答 0