我正在维护 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;
}
这就是它崩溃的地方:
有谁知道发生了什么?谢谢!