0

It is my understanding that when you deploy a service library the app.config not required as the host does not acquire nor use this file and instead uses its own app.config file! Hence why you have to put the database connection string in the hosts config file.

However, what I don't understand is how do you provide configurations within service library?! I realise that question may not be clear so let me provide an example...

In my service library I make use of the entity framework - upon adding the ado.net (via the wizard) the following was added to the app.config file:

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>

So, I am not going to claim to know exactly how purposeful these tags/settings are, but as a quick test I removed them and ran the host and the service worked the same as ever... so this got me thinking! Firstly, I imagine removing these tags didn't affect the service as there are default settings in place which will have been implemented by the entity framework?! and secondly what IF I am required to add specific entity framework configurations at a later date? How would I do that when the config file within the service library is redundant?

Of course this may not be deemed the best example of the "problem" I am trying to portray, but I hope you can understand my confusion and I would greatly appreciate an explanation regarding this scenario!

Sam
  • 586
  • 1
  • 6
  • 25
  • How are you running/deploying the WCF service? Are you running it as an executable in a windows service, or as a stand alone .svc with IIS? Depending on which method, you could have a web.config instead of an app.config. If you're hosting the program behind IIS, it's a web.config you need to worry about, if as a windows service, then app.config. – Brian Aug 07 '13 at 12:36
  • @Brian - It is being deployed as a windows service, so yes using an app.config file... but does that apply to the WCF Service Library, as surely only the host's app.config file is invoked upon deployment? – Sam Aug 07 '13 at 13:08
  • Ok what do you mean by "provide configurations within your service library"? Are you asking how you'd pass values from the host application to the WCF libraries themselves - where the requests are caught and processed? – Brian Aug 07 '13 at 13:17
  • @Brian So my service library makes use of the entity framework, so normally if you wanted to configure EF you would use the app.config file right?? but if I put any configurations in the app.config file (within the service library) they would become redundant when library is hosted as the host's app.config file is used NOT the service libraries... But I couldn't put EF configurations in the host's app.config file could I? because they aren't relevant to that specific project!? Sorry if this is a bit confusing and I appreciate your input! – Sam Aug 07 '13 at 13:24
  • Sorry, Sam, I can't help you with this. I'm working on a WCF that's self hosted and doesn't use the EntityFramework at all for configuration ... – Brian Aug 07 '13 at 13:30
  • You should be able to put the EF framework configuratino data into the host's app.config file. I suggest you try it and see what happens, but I can't think of any reason off the top of my head why it wouldn't work. After all the `System.ServiceModel` isn't technically relevant to the Windows Service, right? It's relevant to the WCF service being hosted. – Tim Aug 07 '13 at 16:54
  • @Tim You are right! It "seems" to be fine putting he EF configuration data in the hosts app.config file, I did try that before - but to cut a long story short as to why it didn't work then, I simply missed something out... oops! Thanks for your help! – Sam Aug 08 '13 at 08:08

0 Answers0