we are going to learn on how to use the Log4Net library for creating logs. Create a new windows form application in VS. Install Log4Net library Add to AssemblyInfo.cs Configure in App.config Use in code Install Log4Net library Then install the Log4Net library from the Nuget Package library. log4net by The Apache software foundation 2.0.8 (i installed the latest). Add to AssemblyInfo.cs After installing this package, open up AssemblyInfo .cs file under the Properties folder and add the log4net assembly information into it (under the other assembly information.). [assembly: log4net.Config.XmlConfigurator(Watch= true )] Configure in App.config Now, open the App.config file and enter required details for LogNet to work. <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net, Version=1.2....
While calling SaveChanges on my DbContext , I get the following exception: System.Data.Entity.Validation.DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details. This is all fine and dandy, but I don't want to attach a debugger every time this exception occurs. More over, in production environments I cannot easily attach a debugger so I have to go to great lengths to reproduce these errors. How can I see the details hidden within the DbEntityValidationException ? Answer : The easiest solution is to override SaveChanges on your entities class. You can catch the DbEntityValidationException, unwrap the actual errors and create a new DbEntityValidationException with the improved message. Create a partial class next to your SomethingSomething.Context.cs file. Use the code at the bottom of this post. That's it. Your implementation will automatically use the overriden Save...
While working with the service, we often face the error : "meta data not accessible in the web service or Failure to invoke the service due meta data inaccessiblity" . Add the below code in web.config : <services> <service name="SyncFalconService.SyncFalcon" behaviorConfiguration="metadataBehavior"> <endpoint address="" binding="wsHttpBinding" contract="SyncFalconService.ISyncFalcon"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> </services>
Comments
Post a Comment