0

I using(and have used in the past) the technique from HERE to allow me to produce a single stand alone exe for my application. By including referenced assemblies into the executable.

My newest application makes use of Entity Framework 6, it looks as though the dll is getting included into my executable but if I do not include it in the same folder as the executable my application crashes with an error.

System.InvalidCastException: Unable to cast object of type 'System.Data.Entity.Infrastructure.SqlCeConnectionFactory' to type 'System.Data.Entity.Infrastructure.IDbConnectionFactory'

I suspect this could be resolved if I moved my configuration out of App.config but am new to entity framework and am unable to decipher how to achieve this. If this is the solution how do I go about implementing it.

Update: I did manage to move my DB setup into a DbConfiguration object but this has not solved the problem.

Hugoagogo
  • 1,465
  • 15
  • 30
  • Are the assemblies being loaded too late? The problem is described here: http://einaregilsson.com/module-initializers-in-csharp/ – Jannik Jul 12 '16 at 05:32

1 Answers1

1

For my project I have used Costura.Fody, but I am not sure if it fits for your purposes

Embedding DLLs in a compiled executable

Community
  • 1
  • 1
user4845680
  • 108
  • 1
  • 12
  • How have I not run across this before, add a single package to nuget and things just work, cheers :) – Hugoagogo Jul 12 '16 at 06:23
  • I have to comment back again now having used this for some time, compared to our previous method of generating a single executable this is working great and offers a huge amount of flexibility. – Hugoagogo Aug 31 '16 at 06:04