引用的DLL没有声明?

时间:2012-09-30 23:50:20

标签: c# vb.net visual-studio-2010 dll components

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

我添加了对dll的引用,还必须添加库的import声明。执行此操作后,代码显示没有错误。虽然我一旦调试代码或构建代码,我就会收到此错误:

'BugReport'未声明。由于其保护级别,它可能无法访问。

我觉得它与某种保护有关吗?这一切都在我的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

1 个答案:

答案 0 :(得分:0)

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

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

当您尝试从另一个项目引用该类时,它无法访问。

您需要将Friend更改为Public