0

If have an application (let's call it A, CF 3.5) which calls another application (B, CF 3.5 as well) within the same directory to delegate some work (downloading a file). This works well, as long as the SQL Server CE assemblies (3.5 SP2) are not loaded by application A. If they are, application B will crash with random file system errors (e.g. assemblies which cannot be loaded) and and a lot of exceptions in filesys.exe. Here's the content of the error report generated by Windows Mobile:

Bucket Parameters

EvntType: WinCE50lbException

AppName: filesys.exe

AppVer: 5.2.0.0

AppStamp: 29ccdda8

ModName: vcefsd.dll

ModVer: 5.2.0.0

ModStamp: 52652c34

Offset: 000017a0

OwnName: B.exe

OwnVer: 1.0.0.0

OwnStamp: 5003c932

This error will occur several times even after debugging has ended and both applications do no longer run. An example of the error which occurs in application B itself:

File or assembly name 'OpenNETCF.Drawing, Version=2.2.0.0, Culture=neutral, PublicKeyToken=...' or one of its dependencies, was not found.

The assembly name changes from time to time (it can be the CF 3.5 assemblies as well). The error occurs in the emulator (always), but never on a real device. If application A is downloading the file instead of delegating the work to B, no error will occur.

I suspect the storage card driver of the emulator to cause this error, but I have no idea how I can debug the issue any further.

Note: Application A loads the locally deployed SQL CE libraries (sqlceoledb35.dll, sqlcese35.dll, sqlceqp35.dll, sqlceme35.dll, sqlceca35.dll, sqlcecompact35.dll) using the following API call:

[DllImport("coredll.dll")]
private static extern IntPtr LoadLibrary(string fileName);

Update

After I removed the OpenNETCF references for a test I got this exception:

Unable to read configuration file '...\some.config': UnauthorizedAccessException

Which is an exception wrapped by our configuration manager (I can't debug it because it occurs in B). Application A reads that file but closes and releases it right away after deserialization.

Gene
  • 4,192
  • 5
  • 32
  • 56
  • How did you get a CF 2.0 application to use the SQLCE 3.5 assemblies? AFAIK, the SQLCE 3.5 libraries require the use of CF 3.5. – tcarvin Jul 16 '12 at 13:02
  • @tcarvin hm, I can reference and use them with a CF 2.0 library. But it doesn't matter, the error occurs with our CF 3.5 clients, too. I changed the question accordingly. Thank you for this hint. – Gene Jul 16 '12 at 13:23
  • 1
    You are lucky if this only happnes in the emuklator. I've seen this kind of thing on devices too. Anyway, why do you use LoadLibrary on the SQLCE libs? – tcarvin Jul 16 '12 at 14:22
  • `LoadLibrary` is used to load the DLLs directly from their deployment directory. This can be the same directory the application is located in, or any other directory (e.g. the installation path of SQLCE). I'll take a look at that piece of code to check whether this is the cause of the failures. – Gene Jul 16 '12 at 15:01
  • I'm not saying it is the problem, but there should be no need to `LoadLibrary` on a .NET Assembly. Use Assembly.LoadFrom instead. – tcarvin Jul 16 '12 at 15:33
  • Those are libraries written in unmanaged code (C/C++ I'd say). The `System.Data.SqlServerCe.dll` is referenced normally. But as I said, I'll take a look into it. Thank you :) – Gene Jul 17 '12 at 06:59

1 Answers1

0

It looks like you are also using one of the OpenNETCF tools.

Have you verified that you are disposing of these components as necessary?

EDIT: When reading or writing to some.config file, be sure to use a lock around it to prevent other processes from trying to access this resource at the same time.

private object objSomeConfig = new Object();

public string GetSomeConfig() {
  string data = null;
  lock (objSomeConfig) {
    data = ....; // fill in your code
  }
  return data;
}
  • I removed all code referencing the OpenNETCF for a test, but the problem remains. But generally speaking our solution releases all resources. – Gene Jul 17 '12 at 06:47
  • About this: `Unable to read configuration file '...\some.config': UnauthorizedAccessException` Look at how A and B are reading from `some.config`. My **guess** is one or more are trying to read from it at the same time. Just a guess, though. –  Jul 17 '12 at 13:36
  • They both read it at startup. When A launches B, A has already read the configuration and released the resources. – Gene Jul 17 '12 at 14:57
  • You may want to use a [lock](http://msdn.microsoft.com/en-us/library/c5kehkcz(v=vs.71).aspx) ...just in case. –  Jul 17 '12 at 15:23