I have created an UWP application for Windows 10 Fall Creators update (16299) with EF Core and Microsoft SQL.
This all works great when testing the application using debug or deploy from Visual Studio. But if I create a package for the app store I get a validation failure. The app then also doesn't connect to the database (screen turns red in my example).
Can anybody help, I'm at a loss?
For testing I already tried turning off .NET Native toolchain and optimize code
Edit: Seems to work if the SQL server is a remote server (Local doesn't work, only when debugging from visual studio)
File C:\Program Files\windowsapps\****************_1.0.0.0_x64__79e7p26z62emy\sni.dll has failed the AppContainerCheck check.
```c#
public MainPage()
{
this.InitializeComponent();
try
{
using (DBTestContext testDB = new DBTestContext())
{
testDB.Database.OpenConnection();
}
// Green
this.MainGrid.Background = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0));
}
catch
{
// Red
this.MainGrid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
}
}
```
EF Core version: 2.0.1
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10 Fall Creators update (16299)
IDE: Visual Studio 2017 15.5.5
Local doesn't work
Last I knew, this was a by-design feature of UWP. I think there is some magic registry key you can set to enable connections to localhost.
File sni.dll has failed the AppContainerCheck check.
This looks like the wrong version of System.Data.SqlClient.dll is being used. You could try updated the package version.
You my friend are my personal hero!
You are absolutely correct and it solved my problem.
Now if I look at it I also understand why the app testing was breaking my application. It has a test in it called "Clear the network isolation loopback exemption". This is why it worked in visual studio debugging and not when released.
For future reference, this command solves the problem:
CheckNetIsolation.exe LoopbackExempt 鈥揳 鈥搉={appname}
I still get the sni.dll error in the tests, but at least the app is working now. I'll look into tickering with different versions. Using System.Data.SqlClient 4.4.2 at the moment.
For testing purposes I installed Visual Studio 2017 15.5.6 on another machine. Created a new empty UWP app. After adding System.Data.SqlClient the validation starts failing with "sni.dll has failed the AppContainerCheck check"
I have tested the following versions of the package
4.4.2
4.4.1
4.2.0
4.1.0
Everything seems to work in the package, but it won't pass the store validation.
I can confirm that the prerelease System.Data.SqlClient 4.5.0-preview2-25707-02 does work. Hopefully when 4.5 comes out official this problem will be solved.
Same goes for Microsoft.EntityFrameworkCore.SqlServer 2.1.0-preview2-30002