2011-09-14 17 views
2

我的應用程序了利用事件日誌中記錄異常和參考消息創建事件日誌事件來源,但作爲標準用戶誰擁有有限的訪問登錄時,我收到了異常:爲標準用戶

未找到源,但搜索到的部分或全部事件日誌不能爲 。無法訪問日誌:安全

據我所知,事件源不能我書面方式向(應用程序)的日誌中找到,並且應用程序試圖創建事件源,但它可以被註冊前的所有日誌需審查以確保事件源尚未使用。

我的問題是我應該如何去創建一個標準用戶可以使用的事件源?該應用程序將在公司網絡上運行,從而將所有用戶鎖定在最低要求的條件下。

我試圖通過創建一個新的VS2008類文件項目來解決此問題,該項目將作爲將註冊EventSource的管理員用戶運行,但是這並未解決該錯誤。以下是我的班級。

Imports System.Diagnostics 
Imports System.Configuration.Install 
Imports System.ComponentModel 

<RunInstaller(True)> _ 
Public Class InstallEventLog 
    Inherits Installer 
    Private myEventLogInstaller As EventLogInstaller 
    Public Const EventSource As String = "My Application Here" 

    Public Sub New() 
     myEventLogInstaller = New EventLogInstaller 
     myEventLogInstaller.Source = EventSource 
     myEventLogInstaller.Log = "Application" 
     Installers.Add(myEventLogInstaller) 
    End Sub 
End Class 

我然後加入到我的解決方案,其具有類項目的主輸出的設置項目,然而,安裝程序安裝運行我的應用程序時再次失敗與上述相同的錯誤消息。

+0

你可以看到註冊表項的事件日誌源之後,據說成功,但最終有問題的安裝? –

回答

0

根據「記錄下來」你的用戶是如何使用「應用程序」日誌是不可能的......你一定要嘗試創建你自己的日誌(不僅僅是LogSource!),看看它是否可行......

恕我直言,以解決這將是aske管理員通過組策略來爲你創建的EventSource的最佳途徑 - 這將確保正確的權限等

+0

謝謝Yahia,我會研究這種方法。 – Lima

0

我實際上添加一個特殊的「類型」系統。 Configuration.Install.Installer類到我的主要EXE項目這似乎是在應用程序安裝期間由.msi成功運行(請參閱裝飾..這是impo rtant)。現在,請注意,儘管此特殊安裝程序類自動成功註冊了事件日誌源,但如果最終用戶雙擊.msi執行安裝(在安裝過程中的某個時刻),屏幕會變暗並出現提示爲管理員憑證顯示..所以,提升的權限是必需的,無論。

這裏是我的類,再一次,只是另一種類坐在我的Windows窗體.exe項目:

Imports System.ComponentModel 
Imports System.Configuration.Install 

<RunInstaller(True)>  
Public Class CoolAppEventLogInstaller 
    Inherits System.Configuration.Install.Installer 

    Private myEventLogInstaller As EventLogInstaller 

    Public Sub New() 
    'This call is required by the Component Designer. 
    InitializeComponent() 

    'Add initialization code after the call to InitializeComponent 

    ' Create an instance of an EventLogInstaller. 
    myEventLogInstaller = New EventLogInstaller() 

    ' Set the source name of the event log. 
    myEventLogInstaller.Source = "MyCompany Cool App" 


    ' Add myEventLogInstaller to the Installer collection. 
    Installers.Add(myEventLogInstaller) 
    End Sub 'New 

    Public Shared Sub Main() 
    End Sub 'Main 


End Class 

對於它的價值,在上面的代碼工作結合,在我的應用程序的事件日誌片段.config

<sharedListeners> 
     <add name="EventLog" initializeData="MyCompany Cool App" type="System.Diagnostics.EventLogTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> 
    </sharedListeners>