DataContext System.Security.VerificationException错误

时间:2013-09-06 14:16:43

标签: c# windows-phone-7 sql-server-ce windows-phone

我正在维护Windows Phone 7应用程序。一切都很好。在WP 8上,一切仍然正常。但在WP7应用程序中断。我在项目中有.sdf数据库。下面是我用来在隔离存储中传输它的代码。

 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. 
                            while ((bytesRead = input.Read(readBuffer, 0, readBuffer.Length)) > 0)
                            {
                                output.Write(readBuffer, 0, bytesRead);
                            }
                        }
                    }

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

这是GetCities方法

        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;
    }

这就是它破裂的地方: enter image description here

有谁知道发生了什么?谢谢!

1 个答案:

答案 0 :(得分:0)

尝试从正在运行的WP8安装中提取数据库文件,然后重新添加到项目中。另外,你的连接字符串是什么样的?