-
Dec 20th, 2023, 08:21 AM
#1
Thread Starter
New Member
VS2022 Errors - BC40056 - System.DirectoryServices doesn't contain a public member
HI VB Experts,
My web application is working, however, when I open it in Visual Studio 2022, I get the error
Warning BC40056 Namespace or type specified in the Imports 'System.DirectoryServices' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
I have checked references and this is installed.
I looked at my header in the vb file and Imports System.DirectoryServices is listed but grayed out saying the import is not necessary.
Use of this looks like this:
Code:
Public Sub PopAD(ByVal UsrName As String)
Dim oroot As DirectoryServices.DirectoryEntry = New DirectoryServices.DirectoryEntry("LDAP://x.com")
Dim osearcher As DirectoryServices.DirectorySearcher = New DirectoryServices.DirectorySearcher(oroot)
Dim oresult As DirectoryServices.SearchResultCollection
Dim result As DirectoryServices.SearchResult = Nothing
Also, I posted a few pictures, which may help solve the issue?
1. What does it mean when an aspx is "not available"
2. Why do my files show as a name with a prefix 2_ or 3_ (different each time I load VB) rather than the PROJECT name like Helpdesk? This is in the errors window.
I've done a Build, Rebuild, and Clean to no avail. No errors when performing any of these, and again, the web app works, just spewing all of these errors in Studio.
-
Dec 20th, 2023, 08:29 AM
#2
Re: VS2022 Errors - BC40056 - System.DirectoryServices doesn't contain a public membe
If you import the namespace, it's not necessary to use the namespace in the types....
So this
Code:
Dim oroot As DirectoryServices.DirectoryEntry
Should be
Code:
Dim oroot As DirectoryEntry
Or... you simply import System... which feels excessive. Or don't use an import and use the fully qualified name as you currently are (but may have to add System. to the front of it.)
-tg
-
Dec 20th, 2023, 09:37 AM
#3
Thread Starter
New Member
Re: VS2022 Errors - BC40056 - System.DirectoryServices doesn't contain a public membe
Hi TG,
I removed the namespace from types so:
Code:
Public Sub PopAD(ByVal UsrName As String)
Dim oroot As DirectoryEntry = New DirectoryEntry("LDAP://x.com")
Dim osearcher As DirectorySearcher = New DirectorySearcher(oroot)
Dim oresult As SearchResultCollection
Dim result As SearchResult = Nothing
but the error persists after rebuild/clean and closing VS and re-opening the project.
Any other ideas?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|