enterprise-library

How to register multiple types that implement the same interface

大兔子大兔子 提交于 2019-12-06 03:34:27
I have a single interface and this is being used by 2 classes. I am using unity configuration to identify the instance based on the interface. Now I want to know how should i register these types so that i can call the appropriate implementation based on the single interface itself. This is how I do it: var container = new UnityContainer().RegisterType<IAmImplementedMoreThanOnce, Implementation1>("Implementation1") .RegisterType<IAmImplementedMoreThanOnce, Implementation2>("Implementation2") .RegisterType<IHaveDependencies1, WithDependenciesImplementation1>(new InjectionConstructor(new

Enterprise library caching parameters on stored procs?

浪子不回头ぞ 提交于 2019-12-05 20:28:01
I'm trying to standardise some data access code with my colleagues. One of the aforementioned colleagues asserts that the EntLib Data Access Block trys to cache parameters on stored proc calls. I've had a look in reflector and there is some evidence that it could be caching them. But I don't think it does in the following situation. public Dictionary<long, string> GetQueue(int maxItems) { var sq = new SqlDatabase(_connString.ConnectionString); var result = new Dictionary<long, string>(); using (var cmd = (SqlCommand)sq.GetStoredProcCommand("dbo.GetQueue")) { sq.AddInParameter(cmd, "maxItems",

entlib Invalid TraceListenerData type

狂风中的少年 提交于 2019-12-05 20:23:54
I've created a custom listener for Enterprise Library 5 Logging Block, which is recognized by the Configuration Editor, but throws a run-time configuration exception: Attempt to Use the Custom Logger static IUnityContainer _container; static LogWriter _writer; static IServiceLocator _locator; public static void Inf(string message) { if (_container == null) { // Create the container _container = new UnityContainer(); // Configurator will read Enterprise Library configuration // and set up the container var configurator = new UnityContainerConfigurator(_container); // Configuration source holds

BackgroundWorker exception handling

Deadly 提交于 2019-12-05 16:56:20
问题 I'm working with the following components: a Library (which throws an exception) a test-console to test my logging the enterprise library exception handling application blocks the enterprise library logging application blocks I'm invoking the library method by using a backgroundworker. The library throws the exception but the RunWorkerCompleted handler is never called. The only way to catch the exception is to surround my DoWork handler code with a try/catch block. Did is misunderstand the

Microsoft.Practices.EnterpriseLibrary.Data.DLL but was not handled in user code

风格不统一 提交于 2019-12-05 15:56:35
问题 Searched google and using Enterprise library data access to connect database. Installed only data access pack using https://www.nuget.org/packages/EnterpriseLibrary.Data/. After added to the project, I've set the configuration as follows, <configSections> <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

Enterprise library 4 dataconfiguration tag

半城伤御伤魂 提交于 2019-12-05 15:45:58
I am using Enterprise library for my data access. When I am running the application, at the CreateDatabase() statement I am getting this exception: Microsoft.Practices.ObjectBuilder2.BuildFailedException was unhandled by user code Message="The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, null]) failed: The value can not be null or an empty string. (Strategy type Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy, index 2)" Source="Microsoft.Practices.ObjectBuilder2" Now, I googled a bit and I

ASP.NET Dependency Injection HTTP Module (MS Enterprise Library)

时光毁灭记忆、已成空白 提交于 2019-12-05 15:21:20
I've been following the steps in the 'Microsoft Enterprise Library 5.0' documentation to create a HTTP module to inject a reference to the Enterprise Library container into the pages of ASP.NET web application. It contains the following code (which also appears online here ): using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using Microsoft.Practices.Unity; namespace Unity.Web { public class UnityHttpModule : IHttpModule { public void Init(HttpApplication context) { context.PreRequestHandlerExecute += OnPreRequestHandlerExecute; } public void Dispose() { }

Exception Handling Application Block Exception Handler running in ASP.NET cannot call Response.End()

自古美人都是妖i 提交于 2019-12-05 13:52:28
Using .NET 3.5, ASP.NET, Enterprise Library 4.1 Exception Handling and Logging blocks, I wrote a custom exception handler to display a standard error page, as follows: [ConfigurationElementType(typeof(CustomHandlerData))] public class PageExceptionHandler : IExceptionHandler { public PageExceptionHandler(NameValueCollection ignore) { } public Exception HandleException(Exception ex, Guid handlingInstanceID) { HttpResponse response = HttpContext.Current.Response; response.Clear(); response.ContentEncoding = Encoding.UTF8; response.ContentType = "text/html"; response.Write(BuildErrorPage(ex,

Entreprise Library Rolling flat file is not rolling

半腔热情 提交于 2019-12-05 09:18:20
I'm trying to rotate log files, one per day of week and this configuration file is not working. If I change it to rotate instead of midnight to minute it only records one single file with one minute duration. No new files are being generated. Are there any known bugs of the latest version of entreprise library that focus on rolling flat files not working? Is there any problem with my current configuration? Thank you! <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General" revertImpersonation="false"> <listeners> <add name="Rolling Flat File Trace Listener" type="Microsoft

EntLib5: Loggin application block not logging to Event Log (exception: type LogWriter cannot be constructed)- Can anyone help?

梦想的初衷 提交于 2019-12-05 06:42:10
HI there, I just setup the logging application block part of Enterprise Library 5. I think i have done it correct but its not logging to the event log it errors on the write method and gives me the following exception. The type LogWriter cannot be constructed. You must configure the container to supply this value. Can anyone do me a check or tell me what i am missing.. First of all i am running in windows 7 with a winforms application. Here is my method that creates the log and you see the write method. public class Logger : ILogger { public void SendTest(string test) { LogEntry log = new