Take the 2-minute tour ×

I am maintaining Windows Phone 7 application. Everything worked fine. Everything still works fine on WP 8. But on WP7 app breaks. I have .sdf database in project. Below is the code I use to stream it in isolated storage.

 using (Stream input = Application.GetResourceStream(new Uri("Assets\\myDB.sdf", UriKind.Relative)).Stream)
                        // Create a stream for the new file in the local folder.
                        using (IsolatedStorageFileStream output = iso.CreateFile("myDB.sdf"))
                            // Initialize the buffer.
                            byte[] readBuffer = new byte[4096];
                            int bytesRead = -1;

                            // Copy the file from the installation folder to the local folder. 
                                output.Write(readBuffer, 0, bytesRead);

                    var listOfCities = ModelUtil.GetCities().OrderBy(c => c.Name);

This is GetCities method

        public static List<ListPickerData> GetCities()
        List<ListPickerData> cities = new List<ListPickerData>();

        using (myDataContext context = new myDataContext(ModelUtil.ConnectionString))
            var data = context.Cities.ToList();


        return cities;

And this is where it breaks: enter image description here

Does anyone know what happened? Thanks!

share|improve this question
add comment

1 Answer

Try to extract the database file from the working WP8 install, and re-add to your project. Also, what does your connection string look like?

share|improve this answer
I tried extracting database and adding it back. It doesnt work. This is my connection string: public const string ConnectionString = @"isostore:/myDB.sdf" –  drago Sep 9 '13 at 9:55
Feel free to email me a repro app, and I will look closer –  ErikEJ Sep 16 '13 at 11:02
add comment

Your Answer


