我试图移植作为SQL Server数据库前端的Web API。 web api在Windows下工作正常,并且在部署到IIS时,可以从Windows上的.Net Core开始工作,但在从OSX或Linux中运行时会出现连接错误。在OS X上使用.Net代码连接到SQL Server
从Windows中工作在Visual Studio中的连接字符串是
connectionString="data source=A\B;initial catalog=C;
persist security info=True;user id=X; password=Y;
MultipleActiveResultSets=True;App=EntityFramework"
providerName="System.Data.SqlClient"
,然后将其转化为连接字符串的.NET核心变异为:
Server=A\B;Database=C;user id=X;password=Y;
该项目编译正常,甚至可以在Windows的.Net核心下运行,但是从* nix机器运行时会崩溃。
的错误是:
Unhandled Exception: System.Data.SqlClient.SqlException:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: TCP
Provider, error: 35 - An internal exception was caught) --->
System.AggregateException: One or more errors occurred. (No such device
or address) --->
System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: No
such device or address
我可以ping的地址,但我想有效的地址(A)和服务器实例(B)的组合不具有下* nix中一个简单的斜线工作。
你说的崩溃。究竟发生了什么?您的Mac能否解析名称A以指向正确的机器? – TZHX
我用更好的描述更新了这个问题。在任何情况下,我的机器确实可以ping通A,所以错误可能是A \ B的组合,这应该以其他方式给出? –
什么*是*'A'? IP地址,FQDN,服务器名称?你能用任何其他工具连接到服务器吗?仅仅因为你可以ping一个地址并不意味着你可以连接到一个命名实例。 –