First of all, Let me explain what I’m trying to achieve : I am trying to create a Portable Windows Application (32-bit) which performs Indexing of a sort and stores it in the database. I want the application to be self-contained in terms of database management. Whenever the application is run, It should look at a pre-decided location (App data perhaps) to see whether the database exists there or not and if the database does not exist (deleted by user or First run), then create it using the Scripts that I will attach to the Exe.
I decided on using SQL Server CE to fulfil my requirement and it works good as such, that it allows me to create databases on the fly and generate tables in it, if any are missing. But I’m unable to incorporate it into the Portable application. If I have to share my application with anyone, I have to share the exe along with the dlls separately which is something that I want to avoid. The main dll in question is System.Data.SqlServerCe.dll which I need to provide but this dll has dependency on certain native dlls : Microsoft.VC90.CRT, sqlceca40.dll, sqlcecompact40.dll, sqlceer40EN.dll, sqlceme40.dll, sqlceqp40.dll, sqlcese40.dll (which reside in a separate folder structure of their own – x86 and amd64).
I decided to try embedding the dlls into my exe and using the code as shown in this answer :Embedding unmanaged dll into a managed C# dll (Mark’s answer), I succeeded in doing the same but the application fails to load the native dlls as the System.Data.SqlServerCe.dll looks for the native dlls, expecting the presence of the folder structure, which however is not present in the embedded resources and fails.
So how can I solve this issue without resorting to an installer ? Or maybe any alternate better approach to achieve what I am trying ? Thanks in advance.
You should mark your app as x86 only. Then extract the unmanaged dll and System.Data.SqlServerCe.dll to the same folder as your .exe. Require the vc++ runtime to be installed (or .net 3,5 sp1, which installs the vc++ runtime)