相关疑难解决方法(0)

尝试获取LogWriter类型的实例时发生激活错误

我正在尝试使用Enterprise Library 5.0的Logging Application块将简单消息记录到Win XP SP3系统上的Windows事件日志中,使用:

Logger.Write(msg);
Run Code Online (Sandbox Code Playgroud)

尝试记录时,我收到"尝试获取LogWriter类型的实例时出现激活错误"错误消息.

下面显示的是MS Enterprise库使用的配置文件

<?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="" tracingEnabled="true" defaultCategory="General">
    <listeners>
        <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            source="Enterprise Library Logging" formatter="Text Formatter"
            log="Application" machineName="." traceOutputOptions="None" />
    </listeners>
    <formatters>
        <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} …
Run Code Online (Sandbox Code Playgroud)

c# enterprise

16
推荐指数
2
解决办法
4万
查看次数

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

我正在尝试使用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万
查看次数

标签 统计

c# ×2

enterprise ×1

enterprise-library ×1

unit-testing ×1