Caliburn.Micro + MEF + SQL CE together produce exception Cannot open 'Db\Some.sdf'. Provider 'System.Data.SqlServerCe.3.5' not installed.

Jan 28, 2011 at 6:25 PM

Hi I am really confuse with this behavior. I use Caliburn.Micro as MVVM framework in my WPF app, MEF is used on export view models classes.

Now I need use SQL compact DB in my app. So I create *dbml file with sqlmetal, because on DB access I would like to use LINQ TO SQL.

First I create simple class which do CRUD operations DB.

Here is it:


public interface IDbManager{}

    public class DbManager : IDbManager
        //_dc is DataContext class
        private Spiri_SQL_CE_DB _dc;

        public DbManager()
            //string connStr = System.Configuration.ConfigurationManager.AppSettings["connstr"];
            //_dc = new Spiri_SQL_CE_DB(connStr);

            _dc = new Spiri_SQL_CE_DB(@"Db\Spiri_SQL_CE_DB.sdf");

This class is used in view model class which is WPF window.

    public class ArchiveViewModel :Screen,IArchiveViewModel

        private IDbManager _dbManager;

        public ArchiveViewModel(IDbManager dbManager)
            _dbManager = dbManager;


And this window I open from screen with WindowManager class.

    public class MessengerViewModel : Screen, IMessengerViewModel

        private IWindowManager _windowManager;

        public MessengerViewModel(IWindowManager windowManager)
            _windowManager = windowManager;

        public void OpenArchive()
            var w =  IoC.Get<IArchiveViewModel>();

If I run app I get this error:

The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

1) Cannot open 'Db\Spiri_SQL_CE_DB.sdf'. Provider 'System.Data.SqlServerCe.3.5' not installed.

Resulting in: An exception occurred while trying to create an instance of type 'Spirit.DbManager.DbManager'.

Resulting in: Cannot activate part 'Spirit.DbManager.DbManager'.
Element: Spirit.DbManager.DbManager -->  Spirit.DbManager.DbManager -->  AssemblyCatalog (Assembly="Spirit, Version=, Culture=neutral, PublicKeyToken=null")

Resulting in: Cannot get export 'Spirit.DbManager.DbManager (ContractName="Spirit.DbManager.IDbManager")' from part 'Spirit.DbManager.DbManager'.
Element: Spirit.DbManager.DbManager (ContractName="Spirit.DbManager.IDbManager") -->  Spirit.DbManager.DbManager -->  AssemblyCatalog (Assembly="Spirit, Version=, Culture=neutral, PublicKeyToken=null")


I am really confuse with this error:

1) Cannot open 'Db\Spiri_SQL_CE_DB.sdf'. Provider 'System.Data.SqlServerCe.3.5' not installed.


  • I use Window 7 x64, I have installed SQL Server CE for .NET4.0, .NET3.5
  • WPF use .NET4.0 and is x86
  • In WPF I have reference on assembly

I create small repo project but I get same error:

Repo project you can find here:

I think problem code is here:

_dc = new Spiri_SQL_CE_DB(@"Db\Spiri_SQL_CE_DB.sdf");

Spiri_SQL_CE_DB class is from *.dbml file.

I create view model class without MEF I get the same error!

So I try use DbManager class in WPF app without Calibur.Micro and MEF and it works good.

I really don’t know what is bad, I search with google 2 hours but any advice don’t solve this error.

If anybody can help I would be very glad.

Jan 29, 2011 at 3:21 PM

I was a little reluctant to consider the issue dependent on CM in any way.
Yet, I had a look at the repro; I had some problem fixing the references, but I finally managed to compile.
I removed the missing control libraries and using MEF from the 4.0 runtime instead of the version you're using (from codeplex source, I guess).
In this scenario, the application started successfully, with no errors from the line you pointed out.
I also tested your existing binaries, and the app completes the bootstrap as well.

Jan 30, 2011 at 1:41 PM

Thank, problem is solved, someone (my teacher) has broken  installation of SQL SERVER CE. And the assebmly  not regirstred in GAC.

So he gave me F, because he didn’t test my school project, I came to his house, check window folder :D and solved the problem :DDDDD