标签: enterprise-library

Microsoft.Practices.EnterpriseLibrary.Data.DLL但未在用户代码中处理

搜索谷歌并使用企业库数据访问来连接数据库.

使用https://www.nuget.org/packages/EnterpriseLibrary.Data/仅安装数据访问包.

添加到项目后,我已将配置设置如下,

     <configSections>
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
    </configSections>
  <dataConfiguration defaultDatabase="dProvider" />
    <connectionStrings>
        <add name="dProvider" connectionString="server=local;Initial Catalog=n;uid=sa;pwd=pwd"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
Run Code Online (Sandbox Code Playgroud)

通过以下应用程序调用,

Database db;
            string sqlCommand;
            DbCommand dbCommand;

            db = DatabaseFactory.CreateDatabase("dProvider"); or DatabaseFactory.CreateDatabase();
Run Code Online (Sandbox Code Playgroud)

运行应用程序后,我得到以下异常,

{"Database provider factory not set for the static DatabaseFactory. Set a provider factory invoking the DatabaseFactory.SetProviderFactory method or by specifying custom mappings by calling the DatabaseFactory.SetDatabases method."}
Run Code Online (Sandbox Code Playgroud)

我犯了什么错误?如何解决这个问题?

enterprise-library

13
推荐指数
1
解决办法
2万
查看次数

如何使用Enterprise Library Logging将消息写入调试输出?

我想用EntLib Logging实现日志记录,并为类"调试"连接两个TraceListeners.一个会将这些消息写入文件,其他人将它们以与Debug.Write相同的方式输出到系统跟踪输出(这样我就可以用Sysinternals DbgView监视它们),但是我找不到如何用格式化程序设置这个第二个监听器我需要.我真正需要的只是消息,但它输出了大量的东西,比如EventId,Priority等.我如何剪掉所有这些东西?

logging enterprise-library

12
推荐指数
1
解决办法
8914
查看次数

企业库日志记录未从ASP.NET登录到事件日志

我花了一天时间尝试使Ent Lib Logging工作并将任何内容记录到数据库或事件日志中.我有一个具有相同Ent Lib配置的Web应用程序和控制台应用程序,但只有控制台应用程序能够登录到事件日志.我尝试了所有权限,但我不知道我在做什么 - 哪些服务应该有什么.这是行不通的!

我读过这样的文章 http://imar.spaanjaars.com/275/logging-errors-to-the-event-log-in-aspnet-applications ,我想尝试给ASPNET帐户这些权限.我使用Windows 7,我找不到ASPNET用户帐户.那它在哪里?

这是从Ent Lib实用程序自动生成的配置文件,它仅适用于App.config,而不适用于web.config

<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true"
    revertImpersonation="false">
    <listeners>
      <add source="Logger" formatter="Text Formatter" log="Application"
        machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Formatted EventLog TraceListener" />
    </listeners>
    <formatters>
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Text Formatter" />
    </formatters>
    <categorySources>
      <add …
Run Code Online (Sandbox Code Playgroud)

.net asp.net logging enterprise-library

12
推荐指数
1
解决办法
2万
查看次数

Silverlight是否有log4net版本?

是否有针对Silverlight的log4net版本?

如果不这样,有人可以建议在Silverlight中使用替代日志框架吗?

.net silverlight logging log4net enterprise-library

11
推荐指数
1
解决办法
6106
查看次数

尝试获取数据库类型的实例时出现激活错误,键""< - 空白

我正在尝试使用Enterprise Library 5.0并在我的BL上进行一些单元测试,我是否需要在DL或Test项目上安装app.config?

注意:我的web项目上的web.config上已经有配置设置.

我如何使用DAAB:

private static Database db = DatabaseFactory.CreateDatabase();

db.ExecuteNonQuery("spInsertSalesman", salesman.Fullname);
Run Code Online (Sandbox Code Playgroud)

我在DL上的app.config:

<configuration>
    <configSections>
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
    </configSections>
    <dataConfiguration defaultDatabase="DBTEST" />
    <connectionStrings>
        <add name="DBTEST" connectionString="Data Source=[dbsource];Initial Catalog=[dbname];User Id=sa;Password=password;"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
</configuration>
Run Code Online (Sandbox Code Playgroud)

c# unit-testing enterprise-library

11
推荐指数
1
解决办法
5万
查看次数

如何通过EF调用MVC中的存储过程

在哪里可以获得有关MVC框架中存储过程的实体框架的优秀教程?

在这种情况下,当我几乎所有内容都写在存储过程中时,使用Enterprise库是否更好.

注意:我使用的是存储过程,因为它们非常复杂,其中一些超过1000行.

entity-framework enterprise-library asp.net-mvc-3

11
推荐指数
1
解决办法
4万
查看次数

尝试获取LogWriter类型的实例时出现激活错误,键""?

我有asp.net网站.我添加Microsoft.Practices.EnterpriseLibrary.Logging.dll了对该网站的引用 .

在web.cofig文件中,我定义如下.

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
        fileName="C:\Temp\RollingFlatFile.log" footer="----------------------------------------"
        formatter="Text Formatter" header="----------------------------------------"
        rollFileExistsBehavior="Increment" rollInterval="None" rollSizeKB="20"
        timeStampPattern="yyyy-MM-dd" maxArchivedFiles="3" traceOutputOptions="None"
        filter="All" />
      </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
        template="Timestamp: {timestamp(local)}{tab}Message: {message}{tab}Category: {category}{tab}Priority: {priority}{tab}EventId: {eventid}{tab}ActivityId: {property(ActivityId)}{tab}Severity: {severity}{tab}Title:{title}{tab}"
        name="Brief Format Text" />
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
        template="Timestamp: {timestamp}{tab}Message: {message}{tab}Category: {category}{tab}Priority: {priority}{tab}EventId: {eventid}{tab}Severity: {severity}{tab}Title: {title}{tab}Activity …
Run Code Online (Sandbox Code Playgroud)

c# vb.net asp.net enterprise-library

11
推荐指数
2
解决办法
5万
查看次数

Enterprise Library 4.1记录时间戳如何显示毫秒

以下是配置文件.

 <formatters>
      <add template="{timestamp} {severity} {category} {message}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="SingleLineFormatter" />
 </formatters>
Run Code Online (Sandbox Code Playgroud)

哪个显示

31/05/2011 11:43:24信息......

但是没有毫秒显示哪些对于穿孔仪器有用,谁知道如何显示?谢谢.

logging enterprise-library app-config

10
推荐指数
1
解决办法
8709
查看次数

BackgroundWorker异常处理

我正在使用以下组件:

  • 图书馆(抛出异常)
  • 测试我的日志记录的测试控制台
  • 企业库异常处理应用程序块
  • 企业库日志记录应用程序块

我正在使用backgroundworker调用库方法.库会抛出异常,但永远不会调用RunWorkerCompleted处理程序.

捕获异常的唯一方法是使用try/catch块包围我的DoWork处理程序代码.

是否误解了RunWorkerCompletedEventArgs.Error属性?是不是因为获得了BackgroundWorker捕获的异常?

Codesample:

static BackgroundWorker w = new BackgroundWorker();

w.DoWork += new DoWorkEventHandler(w_DoWork);
w.RunWorkerCompleted += 
   new RunWorkerCompletedEventHandler(w_RunWorkerCompleted);
w.RunWorkerAsync();



static void w_DoWork(object sender, DoWorkEventArgs e)
{
   MyClass m  = new MyClass();
   w.result = m.Compute();
}

static void w_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
   if (e.Error != null)
   {
      HandleException(e.Error);
   }

   /* result related code */

}


static void HandleException(Exception e)
{
   ExceptionPolicy.HandleException(e, "MyPolicy");
}
Run Code Online (Sandbox Code Playgroud)

上面的示例导致我的控制台应用程序终止.vs2010输出绝对没有写入(只有默认输出).

那么问题出在哪里?

//编辑:此代码段用于捕获库的异常.

static void w_DoWork(object sender, DoWorkEventArgs e)
{
   try
   { …
Run Code Online (Sandbox Code Playgroud)

c# multithreading enterprise-library exception backgroundworker

10
推荐指数
1
解决办法
2万
查看次数

VSIXInstaller.NoApplicableSKUsException:此扩展程序无法安装在任何当前安装的产品上

我最近尝试在visual studio 2015中安装企业库6.0,但安装程序抛出错误'VSIXInstaller.NoApplicableSKUsException:此扩展不能安装在任何当前安装的产品上'.我无法解决它.

19-Dec-16 9:59:48 AM - Microsoft VSIX Installer
19-Dec-16 9:59:48 AM - -------------------------------------------
19-Dec-16 9:59:48 AM - Initializing Install...
19-Dec-16 9:59:48 AM - Extension Details...
19-Dec-16 9:59:48 AM -  Identifier         : A42E118F-C41F-47A2-ADB5-04CDEBF8EB90
19-Dec-16 9:59:48 AM -  Name               : EnterpriseLibrary.Config.v6
19-Dec-16 9:59:48 AM -  Author             : Microsoft
19-Dec-16 9:59:48 AM -  Version            : 6.0.1304.1
19-Dec-16 9:59:48 AM -  Description        : Launches the Microsoft Enterprise Library v6 Configuration Console
19-Dec-16 9:59:48 AM -  Locale             : en-US
19-Dec-16 9:59:48 AM - …
Run Code Online (Sandbox Code Playgroud)

installation enterprise-library visual-studio vsix visual-studio-2015

9
推荐指数
3
解决办法
3万
查看次数