Quantcast
Channel: patterns & practices – Enterprise Library
Viewing all 1928 articles
Browse latest View live

New Post: ObservableEventLister in Windows Server 2012

$
0
0
Hi,

Does anyone know if there have been any changes relating to ETW / ObservableEventLister in Windows Server 2012?

I have a service which uses an ObservableEventLister to listen to in-process events and write log file output (for legacy monitoring purposes). When deployed to Windows Server 2008R2, the logging works perfectly yet when deployed (with the exact same configuration) to Windows Server 2012 I do not see any logged output.

Both services run under the "Local System" account.

Thanks in advance,
Ian

Created Unassigned: Consider Apache license? [33836]

$
0
0
The Ms-Pl is incompatible with many free software licenses, as it imposes a unique restriction:

> (D) If you distribute any portion of the software in source code form, you may do so __only under this license__ by including a complete copy of this license with your distribution. [...]

Many OSI-approved copyleft licenses require that linking or interacting code must be licensed in a manner that does not further restrict user rights. This conflicts with the Ms-Pl, as it specifically prohibits the right to re-license.

There are many GPL, LGPL, and AGPL-licensed libraries - yet we are forced to choose between using them - and using this library. We are also prevented from using any copyleft license in consuming software.

Commented Unassigned: Consider Apache license? [33836]

$
0
0
The Ms-Pl is incompatible with many free software licenses, as it imposes a unique restriction:

> (D) If you distribute any portion of the software in source code form, you may do so __only under this license__ by including a complete copy of this license with your distribution. [...]

Many OSI-approved copyleft licenses require that linking or interacting code must be licensed in a manner that does not further restrict user rights. This conflicts with the Ms-Pl, as it specifically prohibits the right to re-license.

There are many GPL, LGPL, and AGPL-licensed libraries - yet we are forced to choose between using them - and using this library. We are also prevented from using any copyleft license in consuming software.
Comments: Each application block has been moved to a separate repository, published on NuGet as a separate package and is licensed under the Apache 2.0 license. For example, the [Semantic Logging Application Block](http://slab.codeplex.com/license). Also see: [Microsoft Enterprise Library - Open Development Model](http://blogs.msdn.com/b/agile/archive/2013/11/21/microsoft-enterprise-library-open-development-model.aspx)

New Post: Using Oracle db with Entlib

Commented Unassigned: Consider Apache license? [33836]

$
0
0
The Ms-Pl is incompatible with many free software licenses, as it imposes a unique restriction:

> (D) If you distribute any portion of the software in source code form, you may do so __only under this license__ by including a complete copy of this license with your distribution. [...]

Many OSI-approved copyleft licenses require that linking or interacting code must be licensed in a manner that does not further restrict user rights. This conflicts with the Ms-Pl, as it specifically prohibits the right to re-license.

There are many GPL, LGPL, and AGPL-licensed libraries - yet we are forced to choose between using them - and using this library. We are also prevented from using any copyleft license in consuming software.
Comments: Thanks! I completely missed this change; I was looking at an outdated copy. Sorry for wasting your time!

New Post: Reason for emphasizing programmatic configuration for library components

$
0
0
Hi !,

I understand why EntLib team would add new configuration approaches. But I am curious towards why would you emphasize the programmatic approach towards configuration?
With Declarative (XML) based configuration we could edit file and get he library component behave accordingly.
Now with programmatic approach such a change would mean changing the version numbers (increment)?

Please guide my thoughts..

New Post: Using Oracle db with Entlib

$
0
0
Hi Randy,
Thanks for helping!

I downloaded Enterprise Library 5.0 - Data Access Application Block, EntLibContrib 5.0 - Oracle ODP.NET Data and did settings in Web.config(after some online research). I was able to get output from the Oracle stored procedure.

I created one procedure in Oracle db 10g as :
procedure "USP_GETPROPOSALDATABYPRDID"
(prd_id IN NUMBER,
prdData OUT SYS_REFCURSOR )
is
begin

begin
open prdData for
select * 
from PROPOSAL_TABLE
where PRODUCTID=prd_id;
end;

end;
and below is the code in CS file
 DatabaseProviderFactory dbFactory = new DatabaseProviderFactory();
 Database db=dbFactory.Create("ConnectionString");

 DbCommand dbcmd=null;
 dbcmd = db.GetStoredProcCommand("USP_GETPROPOSALDATABYPRDID"); 
 db.AddInParameter(dbcmd, "prd_id", DbType.Int32,1);

 using (var reader = db.ExecuteReader(dbcmd))
             {
                 while (reader.Read())
                 {
                     ar.Add(reader[2]);//randomly adding 2nd col only.
                 }
             }
            gdvData2.DataSource= db.ExecuteDataSet(dbcmd);

            gdvData.DataSource = ar;//ar is ArrayList.
            gdvData.DataBind();
            gdvData2.DataBind();

lblInfo.Text = db.GetType().ToString();//To know the type of Database object created.
As you mentioned previously that parameter has to be named as "cur_OUT", however in this case parameter is named as "prdData" in stored procedure and it is still working. i did some debugging and observe that inside classs OracleDatabase.cs a call to method QueryProcedureNeedsCursorParameter(DbCommand) is made to check if parameter is needed or not and if yes it add a oracle parameter of RefCursor type and name it cur_OUT.

So does it mean name of parameter in stored proc dosen't make any difference??
I wonder how it handle two refcursor parameter.(Currently working on same).

Just wanted your opinion on same.
Once again thank you very much!!!

New Post: Receiving below error when using enterprise Library 5.0 validation block

$
0
0
Hi,

I am receiving below error and while code looks fine to me.

[Possible error could be due to some other DLL reference is required or Source Code also need to be there when referring to DLL] (Also here ValidationResult Count show 0, which doesn't appear to be correct)

But I am not sure, Can anyone identify and tell me the issue, thanks a lot

No Source Available Microsoft.Practices.EnterpriseLibrary.Validation.DLL!Microsoft.Practices.EnterpriseLibrary.Validation.ValidationResults.System.Collections.Generic.IEnumerable<Microsoft.Practices.EnterpriseLibrary.Validation.ValidationResult>

Locating source for 'e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\ValidationResults.cs'. Checksum: MD5 {6d 37 9a 66 f0 9 f 39 a0 16 be 8f 9c 22 5f 12}
The file 'e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\ValidationResults.cs' does not exist.
Looking in script documents for 'e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\ValidationResults.cs'...
Looking in the projects for 'e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\ValidationResults.cs'.
The file was not found in a project.
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\ValidationResults.cs.
The debugger could not locate the source file 'e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\ValidationResults.cs'.

While code looks fine to me. Below is my code. [Possible error due to some other DLL reference is required or Source Code also need to be there when referring to DLL]

using MyLibrary;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Validation.Integration.AspNet;

private Validator<SV> MyLibrary;
protected void Page_Load(object sender, EventArgs e)
{
 }

protected void btnShow_Click(object sender, EventArgs e)
{
    SV objRule = new SV();

    objRule.FirstName = txtFirstName.Text;
    objRule.LastName = txtLastName.Text;
    objRule.Email = txtEmail.Text;
    objRule.AccountNumber = txtAccountNumber.Text;

    ValidatorFactory valFactory = EnterpriseLibraryContainer.Current.GetInstance<ValidatorFactory>();

    Validator<SV> myValidator = valFactory.CreateValidator<SV>("Validation Ruleset");

    ValidationResults valResults = myValidator.Validate(objRule);    // on quickwatch of valResults, Count show null

    //ValidationResults results = Validation.Validate(objRule);

    //if (!valResults.IsValid)
    //{
        foreach (ValidationResult objResult in valResults)
        {
            Response.Write(objResult.Message);
        }
    //}
// part of web.config

<configuration>
<configSections>
<section name="validation" type="Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.ValidationSettings, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
      <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
      <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
      <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    </sectionGroup>
  </sectionGroup>
</sectionGroup>
</configSections>
<validation>
<type name="SV" defaultRuleset="Validation Ruleset" assemblyName="QuantumLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
  <ruleset name="Validation Ruleset">
    <add type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.DateTimeRangeValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      lowerBound="1900-01-01" upperBound="2039-12-31" lowerBoundType="Inclusive"
      messageTemplate="Date should be valid." messageTemplateResourceType=""
      name="Date Range Validator" />
    <add type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.NotNullValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      messageTemplate="Null is not allowed." name="Not Null Validator" />
    <add type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RegexValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      pattern="^\ *([A-Z]{1,2}[0-9][0-9A-Z]?[ ]?[0-9][A-Z]{2})\ *$"
      options="IgnoreCase, IgnorePatternWhitespace" messageTemplate="Valid Post Code is required."
      name="Regular Expression Post Code Validator" />
    <add type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.AndCompositeValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      name="And Composite Validator" />
    <add type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RegexValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      pattern="^[0-9a-zA-Z''-'\s]$" options="IgnoreCase, IgnorePatternWhitespace, CultureInvariant"
      messageTemplate="Only Alpha Numeric Characters are allowed"
      name="Regular Expression AlphaNumeric Allowed" />
    <add type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RegexValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      pattern="^[a-zA-Z''-'\s]$" options="IgnoreCase, IgnorePatternWhitespace, CultureInvariant"
      name="Regular Expression AlphabetsOnly Validator" />
    <add type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.StringLengthValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      upperBound="20" name="String Length TwentyCharsAllowed" />
    <properties>
      <property name="LastName" />
      <property name="Email" />
      <property name="PhoneNumber" />
      <property name="Property To Validate" />
      <property name="FirstName" />
      <property name="AccountNumber" />
    </properties>
  </ruleset>
</type>
</validation>

New Post: Reason for emphasizing programmatic configuration for library components

$
0
0
The preferred configuration approach is a programmatic based approach. However, the declarative XML based approach is still supported and, if you find that suits your needs better, feel free to use it.

You mention the main use case for declarative XML configuration: you can change the behavior at runtime by editing a configuration file. This is definitely flexible but is it really good thing? For non-functional behavior I can definitely see this as being valuable. The classic example is logging -- e.g. you want to increase the minimum severity to gather more information in response to a production-issue. However, for "functional behavior" it can be dangerous to expose the "application logic" via configuration.

Do we really want to change our exception handling policies "on the fly"? Swallowing exceptions (instead of throwing) would most likely break the application (or result in strange behavior and executing code paths that have not been tested).

Or do we want to change our validation rules at runtime? Maybe we do but, once again, it would be prudent to test these changes using a similar release process to a change to compiled code.

In my own experience, I have seen many instances of production applications being "broken" due to XML misconfiguration.

Back to logging for a minute: the current programmatic approach does support reconfiguration at runtime so the logging block does address this use case.

The declarative approach also involves XML configuration that can be arcane and hard to author. So much so that an external tool was developed just to facilitate generation and editing of the XML configuration.

Other things to consider are unit testing; it is usually easier to have all of the test logic contained in code as opposed to depending on managing and deploying external files.

In terms of versioning, if you follow Semantic Versioning then a change to functionality would result in a different version number (depending on the type of change).

Of course, there are no silver bullets or one size fits all solutions. For example, an off the shelf application or hosted application that requires/allows custom configuration by the end user/IT Professional might be a good candidate for externalized declarative XML configuration (of course there are other designs and approaches to support those requirements as well).

If declarative XML configuration is a good fit for you then use it. :)

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to

New Post: Validation Application Block 5.0 not reading configuration (rule set)

$
0
0
ValidatorFactory valFactory = EnterpriseLibraryContainer.Current.GetInstance<ValidatorFactory>();
    Validator<QuantumSV> quantumValidator = valFactory.CreateValidator<SV>("Validation Ruleset");

    SV objRule = new SV();

    objRule.FirstName = txtFirstName.Text;
    objRule.LastName = txtLastName.Text;
    objRule.Email = txtEmail.Text;
    objRule.AccountNumber = txtAccountNumber.Text;
    objRule.CaseID =0;

    objRule.CaseType = string.Empty;
    ValidationResults valResults = quantumValidator.Validate(objRule);

New Post: Database Logging

$
0
0
Hi There,

I'm testing the Semantic Logging and trying to setup a database log in a console application with the following command:
var cs = ConfigurationManager.ConnectionStrings["Traces"];
var listener = SqlDatabaseLog.CreateListener( "GEOVIXEL", cs.ConnectionString,
  bufferingInterval: TimeSpan.FromSeconds( 3 ), bufferingCount:10 );
listener.EnableEvents( GvxEventSource.Log, EventLevel.Verbose, Keywords.All );
(Yes the database exists and yest the table and stored procedure are created.)

The connection string is coming from the app.config as follow:
<connectionStrings>
  <add name="Traces" connectionString="Data Source=(localDB)\v11.0;Initial Catalog=TestLog; Integrated Security=True" providerName="System.Data.SqlClient" />
 </connectionStrings>
I also setup a console and flat file logs that works well.

I'm not getting any error whit the setup but the table is empty. (Yes I dispose and even wait 10 seconds before exit to make sure).

The funny part is that it works fine in the out-of-process logging with the following configuration:
<!-- Database Events -->
<sqlDatabaseSink
    name             ="GEOVIXEL-SQL"
    instanceName     ="GEOVIXEL"
    connectionString ="Data Source=(localDB)\v11.0;Initial Catalog=TestLog;Integrated Security=True">
    <sources>
        <eventSource
            name  ="GEOVIXEL"
            level ="Verbose"
            />
    </sources>
</sqlDatabaseSink>
What am I doing wrong? It's one line of code configuration!!! Using the same connection string!

UPDATE: Adding the FLushAsync before exit I can see now that there's an exception that is thrown: "Trying to pass a table-valued parameter with 16 column(s) where the corresponding user-defined table type requires 12 column(s)."

The table does have 12 columns. Why the logger's trying to write 16? Do I have the correct script to create the table?
CREATE TABLE [dbo].[Traces](
    [id] [bigint] IDENTITY(1,1) NOT NULL,
    [InstanceName] [nvarchar](1000) NOT NULL,
    [ProviderId] [uniqueidentifier] NOT NULL,
    [ProviderName] [nvarchar](500) NOT NULL,
    [EventId] [int] NOT NULL,
    [EventKeywords] [bigint] NOT NULL,
    [Level] [int] NOT NULL,
    [Opcode] [int] NOT NULL,
    [Task] [int] NOT NULL,
    [Timestamp] [datetimeoffset](7) NOT NULL,
    [Version] [int] NOT NULL,
    [FormattedMessage] [nvarchar](4000) NULL,
    [Payload] [nvarchar](4000) NULL,
 CONSTRAINT [PK_Traces] PRIMARY KEY CLUSTERED 
(
    [id] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF)
)

New Post: Database Logging

$
0
0
Reply to myself!

Yes there is an issue with the schema of the database.

The scripts in: EnterpriseLibrary6-binaries.nuget\packages\EnterpriseLibrary.SemanticLogging.Database.1.0.1304.0\scripts with the source code is a 13 columns table while the script WITH the nuget package has the 17 columns schema.

Please update the source code package with the most recent script!

ML

New Post: Database Logging

$
0
0
If the OOP Service is working then the EventSource should be setup properly.

There are two methods of inserting to the Traces table: Stored Procedure and SqlBulkCopy. So it is possible for some scenarios to work and others to fail depending on the number of messages buffered. However, for a simple test the Stored Procedure would be used.

It sounds like there is some issue in connecting to the database. I would guess it's probably the credentials used. To check you can use the following code to enable the SemanticLoggingEventSource provider:
var cs = ConfigurationManager.ConnectionStrings["Traces"];
var listener = SqlDatabaseLog.CreateListener("GEOVIXEL", cs.ConnectionString,
    bufferingInterval: TimeSpan.FromSeconds(3), bufferingCount: 10);

listener.EnableEvents(GvxEventSource.Log, EventLevel.Verbose, Keywords.All);

// Output any sink errors to the consolevar consoleListener = ConsoleLog.CreateListener();
consoleListener.EnableEvents(Microsoft.Practices.EnterpriseLibrary.SemanticLogging.SemanticLoggingEventSource.Log, 
    EventLevel.LogAlways,
    Microsoft.Practices.EnterpriseLibrary.SemanticLogging.SemanticLoggingEventSource.Keywords.Sink);
            
// Or whatever events you have defined
GvxEventSource.Log.Started();

listener.Dispose();
You should see some error messages published by the sink.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to

New Post: Database Logging

$
0
0
Now I get it!

Since the out-of-process logging doesn't have the information from etw for the columns ActivityId, RelatedActivityId, ProcessId, and ThreadId, it uses a 13 columns table instead instead of the 17 columns for in-process logging. I would have used nullable columns to keep the schema consistent between in and out process so we can by configuration switch from one to the other but hey, that's just me.

Hopes my journey help someone else!

ML

New Post: Database Logging

$
0
0
It sounds to me like you may be mixing different versions of the Semantic Logging Application Block.

The actual sink implementation used in-process and out-of-process is the same so they both should be using the same column definitions provided that the same assembly versions are being used in-process as out-of-process. Usually, I would think that the OOP Service would be installed in a separate directory as the source application so it would have a separate copy of the Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Database.dll assembly. So, if a new version of SLAB was being used (e.g. from NuGet) then you would want to make sure that you upgrade any OOP services to use the new version. This is only really an issue for sinks that interface with a "service"/backing store.

All the SLAB 1.1 (e.g. ActivityId) columns are nullable.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to

New Post: Database Logging

$
0
0
Hi Randy,

It is a mix up of version indeed.

Somehow when I downloaded Enterprise Library 6 I got the following files:

EnterpriseLibrary6-aExpenseRI-source.exe
EnterpriseLibrary6-binaries.exe
EnterpriseLibrary6-QuickStarts-source.exe
EnterpriseLibrary6-source.exe
Microsoft.Practices.EnterpriseLibrary.ConfigConsoleV6.vsix
SemanticLogging-service.exe

The SemanticLogging-service.exe package included in the group is version 1.0.1304 while the current version is 2.0.1406.

The version 2.0 works perfectly.

Thanks.

New Post: Database Logging

Reviewed: Enterprise Library 5.0 - April 2010 (十二月 01, 2014)

$
0
0
Rated 5 Stars (out of 5) - 我在项目开发中很实用

Reviewed: Enterprise Library 6 - April 2013 (十二月 01, 2014)

$
0
0
Rated 3 Stars (out of 5) - 很好,我下载下来学习一下。

New Post: Asynchronous Logging in .NET Application

$
0
0
I am looking for information on Asynchronous logging using Enterprise Libraries 6
Want to know implemenatation details and challenges. Please share if anyone has implemented this

Key asks are:

1.Logging to be done asynchronously to files. - This can be done using Enterprise Libraries 6.0

AsynchronousTraceListenerWrapper Class
Logging Asynchronously section in
http://msdn.microsoft.com/en-us/library/dn440731(v=pandp.60).aspx
However, the risk with writing log messages asynchronously is that if the internal buffer overflows or the application shuts down before all the entries are flushed, you will lose some log messages. It is possible to adjust the size of the buffer to your requirements.
  1. Set Thread pool for logging and trigger a mail to support team after the thread pool is crossed??
Please share any relavent info
Viewing all 1928 articles
Browse latest View live