My environment Windows 8 Pro with Visual Studio 2010 Ultimate with WP 7.1.1 SDK installed.
I have a WP 7.1.1 application with a SQL CE database. There are 2 databases, the one that comes with the initial package and another stored in Isolated Storage. On Application_Launching the code compares the version of both databases and if the one from the package is greater it replaces the one from Isolated Storage. On the first run of the app with the simulator closed, the app starts fine and copies the database to isolate storage. On the second run The following code:
using (SportsDataContext db = new SportsDataContext(DBConnectionString))
{
var setting = db.Settings.Where(s => s.SettingID == (Int16)Settings.DatabaseVersion).SingleOrDefault();
if (setting == null)
return false;
newVersion = setting.Value;
}
Throws the exception:
Access to the database file is not allowed. [ 1981,File name = \Applications\Install\{GUID}\Install\{FileName}.sdf,SeCreateFile ]
Also, leaving the emulator running and uninstalling the app and re running it makes it work.
UPDATE The reason it works on the first run is because the code above is not executed (on purpose). Running it again makes the code above run and bomb.
This used to work fine before on Windows 7 and without VS 2012. What might be causing the problem?
UPDATE I reverted all my changes back prior to making any changes with my new Windows 8 setup and it works as expected. As soon as I open the sdf file with VS 2010 using Server Explorer and modify it I get the same problem when debugging the app. Weird!