WCF Service Library app.config file - wcf

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!

Related

ELMAH for ASP .NET MVC Windows Application

I need to log errors for an asp.net mvc windows application which also uses entity framework and for doing this i thought of using ELMAH.
My App.config file contains the appsettings for providing folderpath and other file related details.
Now when I try to add the configuration (elmah...../elmah) for ELMAH after installing it in my project it throws an exception "Configuration system failed to initialize".
But when I remove that code then it works fine.
Please provide me the solution to log errors for MVC windows application.
And the final question is ELMAH.mvc free to use or not?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="folderpath" value="~PA\FileImport"/
<add key="XMLFolderPath" value="~\FileImport\XML"/>
</appSettings>
<connectionStrings>
<add name="####" connectionString="############"
providerName="System.Data.EntityClient" />
</connectionStrings>
<elmah>
..........
</elmah>
</configuration>
It sounds like there's a problem with your ELMAH configuration, since ELMAH and EntityFramework normally doesn't interfere with each other. I would recommend you to follow a tutorial like this: ELMAH Tutorial. There's a ton of tutorials for ELMAH outthere, why a simple google search will find a lot of resources.
If following a tutorial doesn't work, you should probably add some additional information and web.config code in this thread, since figuring out your problem from the amount of information, is almost impossible.

Unable to find the requested .Net Framework Data Provider.

I've seen several posts about this, but none of the answers seem to work.
I'm trying to set up simplemembership and I keep getting this error when WebSecurity.InitializeDatabaseConnection(...) is called
Here is the ConnectionsStrings entry:
<add name="JBarterMain" connectionString="Data Source=winsrv01;Initial Catalog=ProvausioJBarter;Persist Security Info=True;User ID=xxx;Password=xxx" providerName="System.Data.SqlClient"/>
I tried adding the following to my machine config in the .net 4.0 x64 folder:
<add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
I'm getting absolutely nowhere. This seems incredibly odd to me that this wouldn't work out of the box. I had another project a few months ago (broken currently so I can't verify that it still works) that was working just fine and I didn't have to do any additional configuration.
Any ideas?
I wrote a tutorial on how to set up simple membership Here. Also I prefer to ditch the filters and initialize it directly on application start

Enable WPFApplication access to existing WCF RIA Services

I have a big (too big for me, about 50k line) Silverlight application, written by an ex-colleague. It is written really (really really) badly so I'm not going to change/touch almost nothing.
I'd like to easily enable access to his WCF RIA Services from a WFC command line app. There's almost 30 domain service class in the web part of SL app.
I installed the SL and WCF-RIA toolkits.
I've added those lines in the web.config but the compiler doesn't recognize the <domainServices>.
<domainServices>
<endpoints>
<add name="OData" type="System.ServiceModel.DomainServices.Hosting.ODataEndpointFactory, System.ServiceModel.DomainServices.Hosting.OData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="Soap" type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</endpoints>
</domainServices>
From the new command line app I can't see any services in my solution.
Any Idea of what I'm missing? Thanks
Maybe the problem rely on the way you try to add the service reference: auto discover don't work and you don't have an .svc file. You should use something like http://[hostname]/[namespacename]-[classname].svc but I recommend to have a look at these articles: http://blogs.msdn.com/b/saurabh/archive/2009/11/23/understanding-the-wcf-in-wcf-ria-services.aspx and
http://blogs.msdn.com/b/brada/archive/2009/11/22/ria-services-a-domainservice-is-a-wcf-service-add-service-reference.aspx
that give a detailed insghts

WCF logging not working, trying to get ANY information on why services don't work

I have deployed a few WCF services to a server via a web setup project
they are being hosted in an IIS Application, which appears to be running fine.
However when i try to navigate to the wsdl, nothing is found.
I am trying to set up diagnostics logging, to get some information.
I have followed the advice from here: wcf trying to set up tracing to debug, not writing to log file
Also, I have tried what is in the referenced MSDN documentation: under "Recommended Settings for Deployment or Debugging" .. my web.config has that identical configuration. But no log file is being created.
Nothing useful in the event viewer.
Any ideas?
Could be a permissions issue; IIRC those don't always turn up in the event log. Ensure the user IIS runs under has write permissions to the log file path.
This is typically the diagnostic config I use. Seems to work for me.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
...
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel"
switchValue="Verbose">
<listeners>
<add name="sdt"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="D:\wcfLog.svcLog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
If you are not getting any output it may be because your service is not starting correctly. The ServiceHost must be up for diagnostics to output anything. With IIS even though your site is running it does not mean that the ServiceHost started correctly. It's usually a config issue. I'm not a web guy but doesn't IIS write to EventViewer if there is an unhandled exception in the website?
Also, you could try creating a custom ServiceHostFactory. That way your code controls the ServiceHost creation and you can trap any exceptions and log them on your own.
Creating a custom ServiceHost in IIS -> LINK
This is an old question but for the benefit of anyone who might stumble upon the issue:
Make sure you have configured both the system.diagnostics and the System.serviceModel/diagnostics sections configured.
Make sure you have them configured in the correct App.config/Web.config file. The thing to note is that multiple config files may exist in a project, and the one used depends on the Build Configuration.
Personally I had the very same symptom until I noticed that I put the sections
under app.config (in my case, client side tracing), instead of
app.DebugLocal.config. The later was used as my build configuration was set to DebugLocal.

Getting Configuration value from web.config file using VB and .Net 1.1

I have the following web config file. I am having some difficulty in retrieving the value from the "AppName.DataAccess.ConnectionString" key. I know I could move it to the AppSetting block and get it realtively easily but I do not wnat to duplicate the key (and thereby clutter my already cluttered web.config file). Another DLL (one to which I have no source code) uses this block and since it already exists, why not use it.
I am a C# developer (using .Net 3.5) and this is VB code (using .Net 1.1 no less) so I am already in a strange place (where is my saftey semicolon?). Thanks for your help!!
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="AppNameConfiguration" type="AppName.SystemBase.AppNameConfiguration, SystemBase"/>
</configSections>
<AppNameConfiguration>
<add key="AppName.DataAccess.ConnectionString" value="(Deleted to protect guilty)" />
</AppNameConfiguration>
<appSettings>
...other key info deleted for brevity...
</appSettings>
<system.web>
...
</system.web>
</configuration>
<section name="AppNameConfiguration"
type="AppName.SystemBase.AppNameConfiguration, SystemBase"/>
The custom section is supposed to have a class that defines how the various configuration data can be managed, (This is in the Type section). Is this class not available for you to examine?
MSDN has a decent explanation of how to create custom configuration sections in VB that may be helpful to you:
http://msdn.microsoft.com/en-us/library/2tw134k3.aspx