简体   繁体   English

连接到 xamarin 中的 sql 服务器

[英]Connection to sql server in xamarin

I have my data access layer developed for my wcf and win forms applications.我为我的wcf开发了data access layer ,并win forms应用程序。 I just started Xamarin forms application and want to connect to sql server using my current data access layer .我刚刚启动Xamarin forms应用程序,并想使用我当前的data access layer连接到sql server Nevertheless i got an issue when trying to connection.Open() and getting following error.尽管如此,我在尝试connection.Open()并出现以下错误时遇到了问题。 Is there any way to do that?有没有办法做到这一点?

System.Net.Security.Native assembly:<unknown assembly> type:<unknown type> member:(null)\n  at (wrapper managed-to-native) Interop+NetSecurityNative.ImportPrincipalName(Interop/NetSecurityNative/Status&,string,int,Microsoft.Win32.SafeHandles.SafeGssNameHandle&)\n  at Microsoft.Win32.SafeHandles.SafeGssNameHandle.CreatePrincipal (System.String name) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs:39 \n  at System.Net.Security.SafeDeleteNegoContext..ctor (System.Net.Security.SafeFreeNegoCredentials credential, System.String targetName) [0x0001c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/System/Net/Security/Unix/SafeDeleteNegoContext.cs:46 \n  at System.Net.Security.NegotiateStreamPal.EstablishSecurityContext (System.Net.Security.SafeFreeNegoCredentials credential, System.Net.Security.SafeDeleteContext& context, System.String targetName, System.Net.ContextFlagsPal inFlags, System.Net.Security.SecurityBuffer inputBuffer, System.Net.Security.SecurityBuffer outputBuffer, System.Net.ContextFlagsPal& outFlags) [0x0000b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/System/Net/Security/NegotiateStreamPal.Unix.cs:166 \n  at System.Net.Security.NegotiateStreamPal.InitializeSecurityContext (System.Net.Security.SafeFreeCredentials credentialsHandle, System.Net.Security.SafeDeleteContext& securityContext, System.String spn, System.Net.ContextFlagsPal requestedContextFlags, System.Net.Security.SecurityBuffer[] inSecurityBufferArray, System.Net.Security.SecurityBuffer outSecurityBuffer, System.Net.ContextFlagsPal& contextFlags) [0x00037] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/System/Net/Security/NegotiateStreamPal.Unix.cs:240 \n  at System.Data.SqlClient.SNI.SNIProxy.GenSspiClientContext (System.Data.SqlClient.SNI.SspiClientContextStatus sspiClientContextStatus, System.Byte[] receivedBuff, System.Byte[]& sendBuff, System.Byte[] serverName) [0x0006b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/SNI/SNIProxy.cs:113 \n  at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.GenerateSspiClientContext (System.Byte[] receivedBuff, System.UInt32 receivedLength, System.Byte[]& sendBuff, System.UInt32& sendLength, System.Byte[] _sniSpnBuffer) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/TdsParserStateObjectManaged.cs:240 \n  at System.Data.SqlClient.TdsParser.SNISSPIData (System.Byte[] receivedBuff, System.UInt32 receivedLength, System.Byte[]& sendBuff, System.UInt32& sendLength) [0x00007] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.cs:6488 \nSystem.Net.Security.Native assembly:<unknown assembly> type:<unknown type> member:(null)\n  at (wrapper managed-to-native) Interop+NetSecurityNative.ImportPrincipalName(Interop/NetSecurityNative/Status&,string,int,Microsoft.Win32.SafeHandles.SafeGssNameHandle&)\n  at Microsoft.Win32.SafeHandles.SafeGssNameHandle.CreatePrincipal (System.String name) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs:39 \n  at System.Net.Security.SafeDeleteNegoContext..ctor (System.Net.Security.SafeFreeNegoCredentials credential, System.String targetName) [0x0001c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/System/Net/Security/Unix/SafeDeleteNegoContext.cs:46 \n  at System.Net.Security.NegotiateStreamPal.EstablishSecurityContext (System.Net.Security.SafeFreeNegoCredentials credential, System.Net.Security.SafeDeleteContext& context, System.String targetName, System.Net.ContextFlagsPal inFlags, System.Net.Security.SecurityBuffer inputBuffer, System.Net.Security.SecurityBuffer outputBuffer, System.Net.ContextFlagsPal& outFlags) [0x0000b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/System/Net/Security/NegotiateStreamPal.Unix.cs:166 \n  at System.Net.Security.NegotiateStreamPal.InitializeSecurityContext (System.Net.Security.SafeFreeCredentials credentialsHandle, System.Net.Security.SafeDeleteContext& securityContext, System.String spn, System.Net.ContextFlagsPal requestedContextFlags, System.Net.Security.SecurityBuffer[] inSecurityBufferArray, System.Net.Security.SecurityBuffer outSecurityBuffer, System.Net.ContextFlagsPal& contextFlags) [0x00037] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/System/Net/Security/NegotiateStreamPal.Unix.cs:240 \n  at System.Data.SqlClient.SNI.SNIProxy.GenSspiClientContext (System.Data.SqlClient.SNI.SspiClientContextStatus sspiClientContextStatus, System.Byte[] receivedBuff, System.Byte[]& sendBuff, System.Byte[] serverName) [0x0006b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/SNI/SNIProxy.cs:113 \n  at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.GenerateSspiClientContext (System.Byte[] receivedBuff, System.UInt32 receivedLength, System.Byte[]& sendBuff, System.UInt32& sendLength, System.Byte[] _sniSpnBuffer) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/TdsParserStateObjectManaged.cs:240 \n  at System.Data.SqlClient.TdsParser.SNISSPIData (System.Byte[] receivedBuff, System.UInt32 receivedLength, System.Byte[]& sendBuff, System.UInt32& sendLength) [0x00007] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.cs:6488

Sorry I can't comment to answer yet (not enough reputation), but can you make sure your code is .NET Standard (preferably 2.0 compliant) if using it with Xamarin as a portable class library...Xamarin can't use just any .NET dll unfortunately...also, since I suspect that this might not be (the only) an issue for you could you give more info on the structure of your solution, maybe it's an issue with an assembly not being referenced and being linked out of the final build (ie could you make sure it's not working in both Debug as well as Release mode - if you've not modified the Build settings - or just make sure the linker is not going through your code when trying to reduce the final build package size). Sorry I can't comment to answer yet (not enough reputation), but can you make sure your code is .NET Standard (preferably 2.0 compliant) if using it with Xamarin as a portable class library...Xamarin can't use just any .NET dll 不幸的是......另外,因为我怀疑这可能不是(唯一的)问题,您能否提供有关解决方案结构的更多信息,也许这是一个没有引用和链接的程序集的问题最终构建(即您能否确保它在调试和发布模式下都不起作用 - 如果您没有修改构建设置 - 或者只是确保 linker 在尝试减少最终版本时没有通过您的代码构建 package 尺寸)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM