-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: Support SQLite database migrations #21
Labels
Milestone
Comments
Good old System.Data.SQLite.dll doesn't ILMerge. boo. |
This may be my answer... http://stackoverflow.com/q/6616923/18475 |
Wow, now that is some crazy code right there... lol public void enable_loading_from_merged_assembly()
{
AppDomain.CurrentDomain.AssemblyResolve += (sender, e) => load_sqlite_data_assembly(e.Name);
} private Assembly load_sqlite_data_assembly(string assembly_name)
{
if (assembly_name.to_lower().StartsWith("system.data.sqlite"))
{
string resources_path = Path.Combine(output_path, "resources");
string sqlite_file = Path.Combine(resources_path, "System.Data.SQLite.dll");
FileInfo sqlite_dll = new FileInfo(sqlite_file);
Log.bound_to(this).log_a_debug_event_containing("Loading System.Data.SQLite.dll from '{0}'. If it doesn't exist then it will be created from '{1}'.", sqlite_file, ApplicationParameters.sqlite_dll_resource);
if (!sqlite_dll.Exists)
{
if (!Directory.Exists(resources_path)) Directory.CreateDirectory(resources_path);
Assembly executing_assembly = Assembly.GetExecutingAssembly();
using (FileStream fs = sqlite_dll.OpenWrite())
using (Stream resource_stream = executing_assembly.GetManifestResourceStream(ApplicationParameters.sqlite_dll_resource))
{
const int size = 4096;
byte[] bytes = new byte[size];
int number_of_bytes;
while ((number_of_bytes = resource_stream.Read(bytes, 0, size)) > 0)
{
fs.Write(bytes, 0, number_of_bytes);
}
fs.Flush();
fs.Close();
resource_stream.Close();
}
}
return Assembly.LoadFrom(sqlite_file);
}
return null;
} |
Fixed in 05d56aa |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: