Could not load file or assembly

I had a similar problem. The mistake I was doing was I was trying to execute the .exe present in the ../obj/x86/Release, whereas I am supposed to execute the .exe present in ../bin/Release. (I am absolute newbie to C#).

(I also noticed that in this ../bin/Release directory , the referenced .dll file is copied locally.)


This is most probably connected to some system (mis)configuration.

However, by design SQL Server CE is just a single DLL, which may be shipped together with your product.
This means that you can just set Copy local to True in the reference properties of System.Data.SqlServerCe, and you are done.


Apparently this can be solved by adding a <qualifyAssembly> element to the app.config file. Adding the following has my app running smoothly:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <qualifyAssembly partialName="System.Data.SqlServerCe" fullName="System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
    </assemblyBinding>
</runtime>

Thanks!