2011-11-11 6 views
0

私はエンタープライズライブラリ4.1ロギングを使用しています。私は 'EnterpriseLibraryContainer'でコンパイルエラーが発生しています。 EnterpriseLibraryContainerは4.1バージョンでは機能しませんか?エンタープライズライブラリ4.1ロギングエラー?

public LogWriter defaultWriter; 

public Logging() 
{ 
    // Resolve the default LogWriter object from the container. 
    // The actual concrete type is determined by the configuration settings. 
    defaultWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>(); 
} 

[Description("Logging to EverViewer and RollingFile with Write method of a LogWriter")] 
public void LogWriter(string message, string title, EventLogEntryType eventType) 
{ 
    // Check if logging is enabled before creating log entries. 
    if (defaultWriter.IsLoggingEnabled()) 
    { 
     // Create a string array (or List<>) containing the categories. 
     string[] logCategories = new string[] { "General" }; 

     LogEntry logEntry = new LogEntry(); 
     logEntry.Message = message; 
     logEntry.Categories = logCategories; 
     logEntry.Priority = 10; 
     logEntry.EventId = 9005; 
     logEntry.Severity = ConvertEventType(eventType); 
     logEntry.Title = title; 
     defaultWriter.Write(logEntry); 
    } 
} 
+0

5.0にアップグレードすることはできません:

は、デフォルトのライターが取得するために、以下にそのコードを交換してみてください? – Amy

答えて

0

EnterpriseLibraryContainerはEnterprise Library 5で導入されたため、Enterprise Library 4.1では利用できません。

public Logging() 
{ 
    // Resolve the default LogWriter object from the container. 
    // The actual concrete type is determined by the configuration settings. 
    defaultWriter = new LogWriterFactory().Create(); 
} 
0

.NET 4の代わりに.NET 4クライアントプロファイルを使用していますか?

関連する問題