【问题标题】:Security exception in web apiWeb api 中的安全异常
【发布时间】:2015-09-02 14:48:10
【问题描述】:

我正在尝试为 sql 数据库中的表值函数创建一个 odata 端点。我认为我的代码很好,但一些设置问题导致我收到错误:

Server Error in '/' Application.

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 

Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  To create the source, you need permission to read all event logs to make sure that the new source name is unique.  Inaccessible logs: Security.

Source Error: 


Line 12:             {                
Line 13:                 eventLog.Source = source;
Line 14:                 eventLog.WriteEntry(
Line 15:                     message,
Line 16:                     type,

Source File: c:\Users\novak\Desktop\Latest\PAIntelODataService\Common\Logging\LogHelper.cs    Line: 14 

Stack Trace: 


[SecurityException: The source was not found, but some or all event logs could not be searched.  To create the source, you need permission to read all event logs to make sure that the new source name is unique.  Inaccessible logs: Security.]
   System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate) +657
   System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate) +104
   System.Diagnostics.EventLogInternal.VerifyAndCreateSource(String sourceName, String currentMachineName) +86
   System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) +201
   System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category) +25
   ODataService.Common.<WriteToEventLog>d__0.MoveNext() in c:\Users\novak\Desktop\Latest\PAIntelODataService\Common\Logging\LogHelper.cs:14
   System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__4(Object state) +50
   System.Web.<>c__DisplayClass7.<Post>b__6() +15
   System.Web.Util.SynchronizationHelper.SafeWrapCallback(Action action) +90

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248

我无法找出错误的来源。不同项目中的相同代码正在运行,并且之前也已经过测试。

【问题讨论】:

    标签: c# .net visual-studio asp.net-web-api odata


    【解决方案1】:

    使应用程序发布文件夹Sharedread\write 允许everyone

    这只是因为应用程序在没有适当权限的情况下尝试写入日志

    【讨论】:

    • 我没听懂你。我有一个解决方案和多个项目,其中一个项目不工作 - 上面的错误被抛出。 '
    • 尝试以管理员身份(或 Visual Studio 本身)运行您的应用程序
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-12
    • 1970-01-01
    • 1970-01-01
    • 2015-01-02
    • 2016-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多