无法连接到VPN C#

时间:2018-12-12 20:47:26

标签: c# mysql visual-studio

当我离开通过VPN连接的办公室时,似乎无法用代码连接到MySQL数据库。我可以通过VPN连接到phpMyAdmin和MySQL数据库。在VPN上时,我确实曾经能够设法运行此代码,今天我将笔记本电脑带到办公室并连接到本地局域网,而无需更改代码,我的项目就可以正常工作

在使用VPN时收到的错误是

  

HelpdeskTickets.exe错误:0:无法连接到任何指定的MySQL主机。   引发异常:System.Data.Entity.dll中的“ System.Data.EntityException”

我认为我有一个与此问题类似的问题here,我尝试了原始问题的解决方案,但没有成功

  

总结:如果您打开和关闭连接,由于某些愚蠢的原因,Windows会保留TCP端口供将来使用。多次执行后,它会耗尽可用的端口。   …..    在Vista / 2008上,您可以使用netsh将其更改为以下内容:   netsh int ipv4设置dynamicport tcp start = 300 num = 50000

为实体框架自动编写代码时,我不使用连接池

任何人都可以建议解决此问题的方法吗?

这是我的连接字符串的详细信息,如果需要,我可以发布更多代码

    <?xml version="1.0" encoding="utf-8"?>
<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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />

    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider></providers>
  </entityFramework>
  <connectionStrings>
      <add name="ostEntitiesv2" connectionString="metadata=res://*/HelpdeskModel.csdl|res://*/HelpdeskModel.ssdl|res://*/HelpdeskModel.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=MyServer; user id=Myid;password=Mypassword;persistsecurityinfo=True;database=ost&quot; " providerName="System.Data.EntityClient"   />
     </connectionStrings>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.9.9.0" newVersion="6.9.9.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

<system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <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.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data></configuration>

0 个答案:

没有答案