1

I am writing a wpf application (EF, dot net 4, wix 3.6). It compiles fine. I can debug the app and everything works. I can run the produced executable and everything works. I try to package it up with Wix which successfully produces an .msi file, which copies the executable to the right place. When I run the msi-deployed .exe I get the error above.

I've checked out the questions here: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid, and here: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. The second link isn't the solution as that deals with web.config and I'm in a windows desktop environment.

The first solution talks about multiple projects and the EF project's config needing duplication in the other projects. In my case the only two projects are the Main Application (which includes the EF stuff) and the Wix installer project.

In any event, I copied the App.config to the Wix project, but that didn't make any difference. I had a lot of trouble getting the wix stuff going, but I think it's right now, however that might be a pointer to the solution.

Can anyone help?

Community
  • 1
  • 1
mcalex
  • 6,628
  • 5
  • 50
  • 80
  • 1
    Does the installed application folder contain the right config file? Like `MyApplication.exe.config`? If so, what does the connection string look like? – Gert Arnold Dec 07 '12 at 09:23
  • @Gert Make that an answer and you get a tick. I had just managed to come to the same (correct) conclusion myself as I noticed the _brand new_ config file in the build dir, but not the deploy dir – mcalex Dec 07 '12 at 09:47
  • I wouldn't mind if you would answer your own question and provide some information of caveats when using Wix and deploying config files. Maybe you could tell what to do to make sure that the file deploys correctly. Far more useful than my comment that's really only a question. – Gert Arnold Dec 07 '12 at 09:57

1 Answers1

2

OK, as Gert Arnold correctly pointed out, the config file had not been copied to the application directory, so the connection strings couldn't be found. The config file created is named MyAppName.exe.config, and contains stuff from the App.config file created in VS and other bits (like EF config details).

(Something must be different between the settings for the VS2010 installer and the Wix installer as the .msi deployment has never involved a .config file before.)

In any event, adding the .exe.config file to the Product.wxs file as a component contained within the main application feature solved the problem.

Newb notes:

  • If you copy and paste the component tag, remember to set KeyPath="no".

  • The path to the files being deployed is relative to the location of the .wxs file

mcalex
  • 6,628
  • 5
  • 50
  • 80