SQL Server Compact Toolbox standalone – including all managed DLLs in a single .exe

The latest release of the standalone version of my SQL Server Compact Toolbox, mainly for users that do not have Visual Studio 2010 Pro or higher, is available as a single .exe. It was actually a Tweet from @scottgal, that pointed me towards this excerpt from Jeffery Richters’ CLR via C#, Third Edition.

In order to implement in the WPF application, that is the standalone Toolbox, I added the following code to App.xaml.cs (and a Startup handler to App.xaml):

private void Application_Startup(object sender, StartupEventArgs e)
AppDomain.CurrentDomain.AssemblyResolve += (ssender, args) =>
//string[] names = this.GetType().Assembly.GetManifestResourceNames();

String resourceName = "ErikEJ.SqlCeToolbox." +
new AssemblyName(args.Name).Name + ".dll";

using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
Byte[] assemblyData = new Byte[stream.Length];
stream.Read(assemblyData, 0, assemblyData.Length);
return Assembly.Load(assemblyData);


I also added all the Managed libraries that the Toolbox uses as Embedded Resources.
I use the following libraries, all from CodePlex:
WPF Property Grid 
http://wpg.codeplex.com/ (for the SqlCeConnectionStringBuilder)
Sample usage
http://kbcsv.codeplex.com/ (for .csv file import)
Sample usage
SQL Server Compact Scripting Library (for database scripting) 
Sample usage Sample usage
FabTab WPF Tab Control (the SQL Editor tabs)
Sample usage
And the Microsoft Data Connection Dialog (to prompt fro a SQL Server Connection) from http://archive.msdn.microsoft.com/Connection
Sample usage
Hope you find this tip useful.

Write a Comment

Your email address will not be published. Required fields are marked *