Friday, May 27, 2011 9:53 PM
Thanks in advance for the help. Here we go. The issue is my application can't access appSettings in my web.config file when running from the wcf service. I have put the appSettings in both web.config and separate appSettings.config. If I hard code the value in it works fine. I am at a complete loss on this. I have included some of my code. Please advise.
<?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <services> <service name="AtlasMessaging.Library.Service.AtlasMessaging" behaviorConfiguration="AtlasMessagingBehavior"> <endpoint address="http://localhost:6457/AtlasMessaging.svc" contract="AtlasMessaging.Library.Service.IAtlasMessaging" binding="basicHttpBinding" ></endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint> </service> </services> <behaviors> <serviceBehaviors> <behavior name="AtlasMessagingBehavior"> <serviceDebug includeExceptionDetailInFaults="true"/> <serviceMetadata httpGetEnabled="true"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> <appSettings configSource="appSettings.config"> </appSettings> </configuration>
<?xml version="1.0"?> <appSettings> <add value="Main.ConnectionString" key="Data Source=zachvm2\sql1;Initial Catalog=AtlasMessaging;Integrated Security=True"/> </appSettings>
I am using fluent nHibernate in a separate project in the same solution. It works fine with unit tests and every where else. The WCF service won't read the appSettings.
Monday, May 30, 2011 6:03 AM
This is really weird issue. I had tried to replicate the issue but it simply works as expected.
Could you right click on appSettings.Config file and set "Copy to output directory" to 'Always'...
Otherwise try to attach a debugger/trace to your service and step into it, to findout what sort of error it is throwing.
Tanvir Huda Application Architect/Consultant
- Marked As Answer by Yi-Lun LuoModerator Friday, June 03, 2011 9:39 AM
Friday, March 09, 2012 3:16 AM
The issue could be related about the WCF hosting in IIS and the ASP. Net compatibility. These posts could be helpful: