Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

System.AccessViolationException Opening Readonly SDF

129 views
Skip to first unread message

Ross

unread,
Aug 14, 2007, 6:16:01 PM8/14/07
to
Hi all,

I have the following issue - my installer package build script performs the
following steps:

-Build product binaries
-A C# app creates a new SDF, creates tables, indexes and populates it with
data
-The app selects the row count from each table after it is populated
-The SDF and binaries are built into an MSI

When the product is installed, the SDF file is installed as a readonly file.
When run, the product opens the file in SHARED READ mode. Only one
connection is opened to the file.

If the build machine is a Vista machine, the installed product is able to
access the SDF perfectly on any other Vista machine, but fails on XP. If the
build machine is XP, everything works on target XP machines, but fails on
Vista.

The stack trace is at the end of the message.

When failing, if the SDF is made writable, and accessed once, it is slow
when opening it for the first time, but after it can be set back to readonly
and will work from then on.

I can only assume, that there is some difference in the way the file is
persisted under XP and Vista, and that under an operating system other than
the build OS, it insists on rewriting the indexes or something.

Further suggestive of this is that if an SDF file is created under Vista,
then opened once (writeable) under XP, it will then only be usable in
readonly mode on XP machines, and will fail to open under Vista

Any ideas? My preference is to have this file installed as readonly, as
patching it is a lot easier.

Stack Trace:

System.AccessViolationException: Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.
at System.Data.SqlServerCe.NativeMethods.OpenStore(IntPtr pOpenInfo,
IntPtr pfnOnFlushFailure, IntPtr& pStoreService, IntPtr& pStoreServer,
IntPtr& pQpServices, IntPtr& pSeStore, IntPtr& pTx, IntPtr& pQpDatabase,
IntPtr& pQpSession, IntPtr& pStoreEvents, IntPtr& pError)
at System.Data.SqlServerCe.SqlCeConnection.Open(Boolean silent)
at System.Data.SqlServerCe.SqlCeConnection.Open()
...

Ginny Caughey [MVP]

unread,
Aug 15, 2007, 10:31:46 AM8/15/07
to
Ross,

Do you know if you have the same problem with any file or if it's specific
to SDF files?

--
Ginny Caughey
Device Application Development MVP


"Ross" <Ro...@discussions.microsoft.com> wrote in message
news:FAD323AF-3739-4CA1...@microsoft.com...

Ross

unread,
Aug 16, 2007, 9:14:14 PM8/16/07
to
Hi,

The problem is specific to the SDF files. All other aspects of the product
function perfectly, regardless of build / target machines. Any other
executables / dlls can be set to readonly mode and function perfectly.

The SQL CE engine just seems to insist on modifying the file when an SDF
built on XP is used on Vista or vice versa. This is quite frustrating as I
would really like to be able to install the file as readonly, never have it
be modified on the target system and have it be easily patchable with diffs,
without a lot of install- / patch-time trickery. The other minor downside of
the unknown modification made to the file are that, when used for the first
time on the 'other' OS, with the file writeable, there is a noticable delay
while opening the SDF for the first time (and only the first time).

Thanks,

Ross

0 new messages