aspnet / Templates

This repo is OBSOLETE - please see the README file for information
Other
151 stars 57 forks source link

File new template error for Windows 8.1 32 bit for individual auth. #855

Closed jkotalik closed 7 years ago

jkotalik commented 7 years ago

Steps:

  1. Download VS2017 Int Preview and dotnet preview3 on Windows 8.1 32 bit.
  2. File new... ASP.NET Core app, Web Application with Individual User Accounts Authorization
  3. Run application, try to register a new user

Expected Results: A page would show up saying to apply migrations to the database or the user is registered. Actual Results: SqlException on the SQL Server not being found. 4fce5f97

The fix I had to do was change the ConnectionStrings' DefaultConnection from mssqllocaldb to ProjectsV12.

Most likely, we would need to change https://github.com/aspnet/Templates/blob/a594b47c417593d43141d3b4eb2bc41d6ad85f20/src/Rules/StarterWeb/IndividualAuth/appsettings.json#L3 to use a variable for the database.

jkotalik commented 7 years ago

Seems to be also occurring on Win10 via @Tratcher

@danroth27 , thoughts?

danroth27 commented 7 years ago

@divega @bricelam @ajcvickers Any ideas on this one?

ajcvickers commented 7 years ago

I have not seen VS install anything other than mssqllocaldb. If VS is starting to install something different, then this will impact a lot of things--including older templates.

@bricelam @divega Are you guys aware of any change in what SQL Server version/instance VS is installing?

ajcvickers commented 7 years ago

Answer here from @ErikEJ indicates that the ProjectsV12 instance should not be used by applications.

bricelam commented 7 years ago

Weird. Does manually installing the 32-bit version of LocalDB help? Might be a setup issue.

ajcvickers commented 7 years ago

Maybe it depends on which workloads are selected in the VS install?

jkotalik commented 7 years ago

Seems to have been installed through setup. SQL Server Express 2016 localDB is checked. I will try to install the individual component and see from there.

jkotalik commented 7 years ago

Typing sqllocaldb into the command prompt worked too.

ErikEJ commented 7 years ago

Not sure it is relevant, but SQL 2016 LocalDb is only 64 bit, so cannot be installed on a 32 bit system. (SQL 2014 LocalDB comes with both 32 and 64 bit editions)

Tratcher commented 7 years ago

In my case I was trying to port a sample from 1.1 to 2.0 (https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro) and it wasn't able to create the database because A) Startup was trying to access the database and B) Program.Main was using the 1.1 pattern.

ajcvickers commented 7 years ago

@ErikEJ Very interesting. Do you know if VS 2017 installs 2014 LocalDb on a 32-bit system, or does it just not install any LocalDb?

jkotalik commented 7 years ago

It seems that my application defaulted to SQL Server 2014. I'm going to try to repro on another Windows 8.1 machine.

ErikEJ commented 7 years ago

@ajcvickers It does not, SQL Server Express 2016 LocalDb is the only component: https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community LocalDB 2014 is available here: https://www.microsoft.com/en-us/download/details.aspx?id=42299

ajcvickers commented 7 years ago

@danroth27 @divega This means that any of our templates that use a database may not work if VS is installed on a clean 32-bit machine. However, my feeling is we should probably just call this out in the release notes and have people go install the 32-bit 2014 LocalDb. What do you guys think?

(Thanks @ErikEJ!)

ErikEJ commented 7 years ago

Also make sure that the vsix that installs the template is configured to depend on LocalDB!

danroth27 commented 7 years ago

@mlorbetske @sayedihashimi Is this a regression? Or have the ASP.NET Core auth templates always been broken on 32-bit machines? Can you guys take care of getting this into the appropriate VS release notes? Post 15.3 should we fallback to SQLite on 32-bit machines?

ajcvickers commented 7 years ago

@danroth27 @mlorbetske @sayedihashimi Do we have any numbers on the percentage of people who run Visual Studio on a 32-bit OS?

jkotalik commented 7 years ago

Tested on a fresh Win 8.1 32 bit install. Same results with only a ProjectsV12 database being created.

divega commented 7 years ago

@Tratcher showed me today a clean 32 bit Windows VM he had setup with Visual Studio 2017 15.3 Preview 7. Turns out SQL Server LocalDB 2016 shows up as a selected individual component in the VS installer, but accessing the database from the command line with sqllocaldb I mssqllocaldb shows that is version 12, i.e. SQL Server 2014.

So from this observation, it seems that Visual Studio falls back to SQL Server 2014 on a 32 bit machine.

But @Tratcher also hit the issue that he could not get his application to automatically start the automatic LocalDB instance if using IIS Express.

If he starts the instance manually in the command line (e.g. with sqllocaldb s MSSQLocalDB) then application can access the database. If the instance is stopped and he just presses F5 to start the application it did not work.

@jkotalik do you think this is the same behavior you were hitting?

He also found that using kestrel made LocaldDB did start automatically.

I think we need to identify someone in SQL Server that can help us understand if this is all by design and what could IIS Express be doing differently. I will send some emails.

jkotalik commented 7 years ago

I didn't see either Kestrel or IIS launching with msllocaldb on my installation. I tried to call sqllocaldb s MSSQLLocalDB and it fails saying it failed to start, while I can start ProjectsV12.

jkotalik commented 7 years ago

However, deleting and rerunning the kestrel instance did create and start mssqllocaldb. IIS failed this again.

divega commented 7 years ago

@jkotalik thanks. Your comment and someone from SQL confirm that when Visual Studio 2017 is installed on a 32 bit machine and the SQL Server LocalDB 2016 component is selected, the SQL Server LocalDB 2014 is installed.

It seems however that SQL Server LocalDB 2014 initial configuration may be incorrect, with registry entries pointing to a “parent instance” of the wrong version, causing it to fail to start. I have seen this being fixed by deleting the instance with sqllocaldb delete mssqllocaldb and allowing it to be recreated. However I cannot explain the differences in the interactions with Kestrel and IIS Express.

I will keep looking for an answer on this.

Cc @Tratcher

ErikEJ commented 7 years ago

@divega can you repro IIS Express/Kestrel issue?

Tratcher commented 7 years ago

The following event is logged when this happens:

Windows API call WaitForMultipleObjects returned error code: 575. Windows system error message is: {Application Error}
The application was unable to start correctly (0x%lx). Click OK to close the application.
Reported at line: 3728. 

This is logged 15 times, once per second. Nothing is logged to %LocalAppData%\Microsoft\Microsoft SQL Server Local DB\Instances\mssqllocaldb in this scenario. Workarounds like sqllocaldb delete mssqllocaldb or deleting %LocalAppData%\Microsoft\Microsoft SQL Server Local DB\Instances\ have not helped.

ErikEJ commented 7 years ago

What are the "wrong" registry keys?

Tratcher commented 7 years ago

Update: This does not repro for an ASP.NET 4 application, but it does repro for an ASP.NET Core app targeting .NET. I think this narrows it down to AspNetCoreModule and how it launches the child process. I'll debug further with @pan-wang

divega commented 7 years ago

@ErikEJ at this point I think I might have conflated a separate issue into this one. I think it must be separate because I am seeing it even in a 64 bit machine with SQL Server LocalDB 2014 and issuing sqllocaldb delete mssqllocaldb did help. Anyway, the registry keys are GUID keys under HKCU\Software\Microsoft\Microsoft SQL Server\UserInstances. There, ParentInstance had a value of MSSQL13E.LOCALDB when apparently the right value for LocalDB 2014 is MSSQL12E.LOCALDB.

Tratcher commented 7 years ago

Did some debugging with @pan-wang and eliminated ANCM. The issue does not repro when IIS Express is run from the command line, it only repros when run from VS, and again only for ASP.NET Core projects. I'll follow up with @BillHiebert when he gets back to see how the tooling is different.

Tratcher commented 7 years ago

Moving this bug to tooling: https://developercommunity.visualstudio.com/content/problem/89068/unable-to-start-localdb-when-run-from-vs-aspnet-co.html