using (EntityDataContext amdb = new EntityDataContext(StrConnectionString))
{
if (amdb.DatabaseExists())
{
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!isoStore.FileExists(databaseName))
{
copyDatabase = true;
}
else
{
using (IsolatedStorageFileStream databaseStream = isoStore.OpenFile(databaseName, FileMode.Open, FileAccess.Read)) // error here
{
using (Stream db = Application.GetResourceStream(new Uri(databaseName, UriKind.Relative)).Stream)
{
if (databaseStream.Length < db.Length)
copyDatabase = true;
}
}
}
}
}
else
{
//error with the database that has been packaged
}
if (copyDatabase)
new Worker().Copy(databaseName);
}
-3
A
답변
0
격리 된 저장소 액세스 모드 매개 변수에서 읽을 수있는 대신 데이터를 쓸 수 있는지 확인하십시오.
기기로 테스트 했습니까?
+0
처음 에뮬레이터를 실행할 때 오류가 발생합니다. 그 후에 닫을 때까지 제대로 작동합니다. – 1Mayur
0
데이터베이스 연결을 열어 둔 상태에서 데이터베이스 파일을 읽으 려한다고 말할 수 있습니다. DataContext는 데이터베이스 (따라서 파일)를 잠그기 때문에 동시에 읽을 수 없습니다. 고립 된 스토리지 액세스 기능을 이동하여
bool shouldCopyDatabase = false;
bool databaseExists = false;
using (EntityDataContext amdb = new EntityDataContext(StrConnectionString))
{
databaseExists = amdb.DatabaseExists();
}
if (databaseExists == true)
{
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!isoStore.FileExists(databaseName))
{
copyDatabase = true;
}
else
{
using (IsolatedStorageFileStream databaseStream = isoStore.OpenFile(databaseName, FileMode.Open, FileAccess.Read)) // error here
{
using (Stream db = Application.GetResourceStream(new Uri(databaseName, UriKind.Relative)).Stream)
{
if (databaseStream.Length < db.Length)
copyDatabase = true;
}
}
}
}
}
if (copyDatabase)
new Worker().Copy(databaseName);
: 데이터베이스 연결을 사용하여 문을 닫으면
이런 식으로 뭔가를 시도 amdb.Close()
를 호출하거나으로합니다 (EntityDataContext
개체를 닫으려고 종료하기 위해
using (EntityDataContext amdb = new EntityDataContext(StrConnectionString))
범위를 벗어나면 데이터베이스 연결을 먼저 닫을 수 있습니다.
관련 문제
- 1. IsolatedStorageFileStream에서 작동이 허용되지 않음
- 2. WP7 예외 오류 - IsolatedStorageFileStream에서 작동이 허용되지 않음
- 3. WP7 IsolatedStorageFileStream 오류 "IsolatedStorageFileStream에서 작동이 허용되지 않습니다."
- 4. IsolatedStorageFileStream에서 조작이 허용되지 않음 오류
- 5. 작동이 허용되지 않음 (1)
- 6. IsolatedStorageFileStream에서 작업이 허용되지 않습니다.
- 7. IsolatedStorageFileStream에서 작업이 허용되지 않습니다. 오류
- 8. myStore.CreateFile (fileName) 메서드의 IsolatedStorageFileStream에서 작업이 허용되지 않습니다.
- 9. connect() 오류 : 작동이 허용되지 않습니다.
- 10. 장치/dev/ttyusb0 잠금 실패 : 작동이 허용되지 않음
- 11. 경고 : GDB : 제어 터미널 설정 실패 : 작동이 허용되지 않음
- 12. 이미지를 검색 할 때 IsolatedStorageFileStream에서 작업이 허용되지 않습니다.
- 13. $ .get - 원점이 허용되지 않음
- 14. 소켓에서 "조작이 허용되지 않음"오류를 표시하지 않습니다.
- 15. 기존 코드 : mmap zero page : 작동이 허용되지 않습니다 - 어디에서 시작해야합니까?
- 16. Git 사후 수신 후크가 실패합니다 : 작동이 허용되지 않습니다.
- 17. Specail Character DB에서 허용되지 않음
- 18. 406 허용되지 않음 오류가 3.1
- 19. $ .ajax() : 원점 null 허용되지 않음
- 20. jquery 라이브러리의 "문자열 생성이 허용되지 않음"
- 21. 봄 LdapTemplate - 특성 'gidNumber'예외 허용되지 않음
- 22. 드문 lchown() 오류 : 동작이 허용되지 않음
- 23. jQuery ASP.NET MVC 405 POST 허용되지 않음
- 24. ROR이 406의 JSON 반환 허용되지 않음 오류
- 25. fork()가 실패했습니다 (1 : 작업이 허용되지 않음)
- 26. 로드 로컬 infile 허용되지 않음 perl mysql
- 27. 오류 406 - 허용되지 않음 - PHP 포스트 (%)
- 28. OPTION (해시 그룹) 파생 테이블에서 허용되지 않음
- 29. 레코드에 대한 업데이트가 허용되지 않음 - 쓰기 충돌
- 30. git/gitolite push issue - 디렉토리가 허용되지 않음
질문의 제목은 예외입니다 ( – 1Mayur
). 처음으로 t가 발생합니다. ime 에뮬레이터가 실행 된 후 닫을 때까지 계속 실행됩니다. – 1Mayur
코드를 게시하는 것이 아니라 질문 자체에이 정보를 포함해야합니다. ** 코드가 무엇을하려고하고 무엇이 잘못되었는지 설명하십시오. – ChrisF