c# - 在客户端机器上部署 Winforms 应用程序
问题描述
我使用实体框架创建了一个带有本地数据库的 Windows 的 Winforms 应用程序。
在我的电脑上,应用程序运行良好;但是当我SETUP
在另一台机器上创建并安装它时,我收到以下错误:
有关调用即时调试
(JIT) 而不是此对话框的详细信息,请参阅本文末尾。************** 异常文本 **************
System.Data.Entity.Core.EntityException:基础提供程序在打开时失败。
System.Data.SqlClient.SqlException:建立与 SQL Server 的连接时发生网络相关或特定于实例的错误。服务器找不到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。(提供者:SQL 网络接口,错误:26 - 定位指定服务器/实例时出错)到 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity 标识、sqlConnectionString connectionOptions、SqlCredential 凭据、对象 providerInfo、newPassword 字符串、SecureString newSecurePassword、布尔重定向用户实例、sqlConnectionString userConnectionOptions、SessionData reconnectSessionData、DbConnectionPool 池 accessToken 字符串、布尔 applyTransientFaultHandling、SqlAuthenticationProviderManager sqlAuthProviderManager)
在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions 选项,DbConnectionPoolKey poolKey,对象 poolGroupProviderInfo,DbConnectionPool 池,DbConnection owningConnection,DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionPool.CreateObject (
DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
在 System.Data. .ProviderBase.DbConnectionPool.UserCreateRequest (DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
这是我的app.config
:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<connectionStrings>
<add name="Db_EleveBookEntities"
connectionString="metadata=res://*/EntityModelEB3.csdl|res://*/EntityModelEB3.ssdl|res://*/EntityModelEB3.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\MSSQLLocalDB;attachdbfilename= |DataDirectory|\EleveBookLocaleDB3.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Fozzy.Object" publicKeyToken="da510636ee0727d5" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.5585.19816" newVersion="1.1.5585.19816" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
解决方案
这是未连接的 SQL Server 的问题。
您可能会发现以下解决方案是正确的:
您需要启动 SQL Server 服务
在 Windows 中打开运行,输入
services.msc
,然后找到 SQL Server 并启动服务器,然后再次检查您的应用程序其次是检查您的 SQL Server 登录凭据是否对新机器有效
希望你找到解决办法
推荐阅读
- php - PHP 中的计数器在 32,768 后恢复为 0(很可能),但只有一次
- java - 每次用户输入“是”时,我都尝试添加 25,然后打印结果,但是在添加它们时它总是缺少第一个响应
- c++ - 我们如何使 std::uniform_int_distribution 加密安全?
- bash - 用 sed 替换多行文本
- r - 如何在数据框中为每个实例提供自己的行?
- looker - 一个仪表板中的 Looker Map / Store Points 和 Sales Heat Map
- reactjs - 在 react-native 的 navigationOptions 中使用上下文
- php - Regex PHP - 获取特定文本,包括新行和多个空格
- powershell - Powershell:计算属性未按预期工作
- c# - 检索数据时 GET 请求时的 HTTP 405