2012-09-30 76 views
0

我已將全局錯誤處理添加到我的應用程序中,以處理全部未處理的異常。我現在剛剛添加了將bug自動添加到我的fogbugz帳戶的功能。現在這是我的問題。未聲明引用的DLL?

我添加了對dll的引用,還必須添加庫的導入聲明。這樣做後,代碼顯示沒有錯誤。雖然只要我去調試代碼或建立它,我得到這個錯誤:

'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 
+0

這是一個控制檯應用程序?你的項目是否依賴於其他庫? – codingbiz

+0

爲什麼你有C#和vb.net標籤? –

+1

將客戶端的.NET Framework目標版本從客戶端更改爲完整,然後重試。 –

回答

0

「保護等級」是指您的BugReport類中的訪問修飾符。

如果您在C#中聲明類爲FriendInternal),則其他類在相同程序集(.dll)中可以訪問它。

當您嘗試從另一個項目中引用該類時,它無法訪問。您需要將Friend更改爲Public