0

我在我的应用程序中添加了全局错误处理以捕获所有未处理的异常。我现在刚刚添加了自动将错误添加到我的fogbugz 帐户的功能。现在这是我的问题。

我添加了对 dll 的引用,还必须添加库的导入声明。执行此操作后,代码不会显示任何错误。虽然一旦我去调试代码或构建它,我就会收到这个错误:

未声明“错误报告”。由于其保护级别,它可能无法访问。

我猜它与某种保护有关?这一切都在我的 applicationevents.vb 类中。

我在另一个项目中尝试过相同的代码,它可以正常工作,所以我知道它不是代码。我只是不知道它是什么?我是否必须更改我的应用程序设置中的某些内容?无论如何,这是代码。为了隐私,我用我的信息替换了字符串。

Imports FogBugz

Namespace My

' The following events are available for MyApplication:
' 
' Startup: Raised when the application starts, before the startup form is created.
' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
' UnhandledException: Raised if the application encounters an unhandled exception.
' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
Partial Friend Class MyApplication

    Private Sub MyApplication_UnhandledException(ByVal _
    sender As Object, ByVal e As  _
    Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) _
    Handles Me.UnhandledException

        'TO DO: SET THESE VALUES BEFORE CALLING THIS METHOD! 
        Dim url As String = "StackOverFlowDemoString"
        'example: http://localhost/fogbugz/scoutSubmit.asp
        Dim user As String = "StackOverFlowDemoString"
        'existing FogBugz User
        Dim project As String = "StackOverFlowDemoString"
        'existing FogBugz project 
        Dim area As String = "StackOverFlowDemoString"
        'existing FogBugz area
        Dim email As String = "StackOverFlowDemoString"
        'email address of the customer who reports the bug
        Dim defaultMessage As String = "Bug has been submitted. Every bug submitted helps us make this software that much better. We really do appreciate it."
        'the message to return to the user if no Scout Message is found for an existing duplicate bug
        Dim forceNewBug As Boolean = False
        'If set to true, this forces FogBugz to create a new case for this bug, even if a bug with the same description already exists.
        '************************************************************************************
        'send the bug we created:
        BugReport.Submit(url, user, project, area, email, forceNewBug, _
        defaultMessage, e.Exception, True, "{0}.{1}.{2}.{3}", True)


        ' If the user clicks No, then exit.
        e.ExitApplication = _
            MessageBox.Show(e.Exception.Message & _
                    vbCrLf & "Oops! It looks like we have encountered a bug. A bug report has been sent to the developers, so they can have it fixed in a jiffy. Continue?", "An Error has occured.", _
                    MessageBoxButtons.YesNo, _
                    MessageBoxIcon.Question) _
                    = DialogResult.No
    End Sub
End Class


End Namespace
4

1 回答 1

0

“保护级别”是指您的BugReport班级的访问修饰符。

如果将一个类声明为Friend(Internal在 C# 中),则同一程序集 (.dll) 中的其他类可以访问它。

当您尝试从另一个项目中引用该类时,它是不可访问的。

您需要更改FriendPublic.

于 2012-10-01T01:23:56.267 回答