Title: Referenced DLL not declared?
Tags: c#;vb.net;visual-studio-2010;dll;components
Question: I have added global error handling into my application to catch-all unhandled exceptions. I now just added the functionality to add the bug automatically to my fogbugz account. Now here is my issue.
I added a reference to the dll and also had to add the import declaration for the library. After doing this the code shows no errors. Although as soon as I go to debug the code or build it I get this error:
'BugReport' is not declared. It may be inaccessible due to its protection level.
I am geussing it has to do with some kind of protection?  This catch all is in my applicationevents.vb class.
I have tried the same code in another project and it works without error so I know it is not the code. I just don't know what it is? Do I have to change something in my application settings? Here is the code anyways. I replaced the strings with my information for privacy.
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 &amp; _
vbCrLf &amp; "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
Comment: Is this a console application? Does your project depend on other libraries?

Comment: Change the .NET Framework Target version of your project from Client to full and try again.

Comment: Why do you have both C# and vb.net tags?

Comment: Hans you were right. I did this before I came back here to see you posted this. It was the solution. I was using the client profile.


Here is another answer: The "protection level" refers to the access modifier on your BugReport class.
If you declare a class as Friend (Internal in C#), it is accessible to other classes in the same assembly (.dll).
When you attempt to reference that class from another project, it is not accessible.
You need to change Friend to Public.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2012:00:09/30/12', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<c#><vb.net><visual-studio-2010><dll><components>', 'Title': 'Referenced DLL not declared?', 'ViewCount': 1299, 'id': 12666136, 'user_AboutMe': '', 'user_AccountId': 1791825.0, 'user_DisplayName': 'user1632018', 'user_Reputation': 2445.0, 'user_Views': 304.0, 'user_id': 1632018.0}}