473,799 Members | 3,866 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DisconnectedCon text was detected

I am trying to match users from one database with users in AD to get
an e-mail address. The program works but right before it exits I get
the following message.

DisconnectedCon text was detected
Message: Context 0x1a04b0' is disconnected. Releasing the interfaces
from the current context (context 0x1a0340).This may cause corruption
or data loss. To avoid this problem, please ensure that all contexts/
apartments stay alive until the application is completely done with
the RuntimeCallable Wrappers that represent COM components that
liveinside them.

I have read Microsoft's description of what this error means (http://
msdn2.microsoft .com/en-us/library/2c1czate.aspx) but I am not an
experienced programmer and have no clue what "transition into a
disconnected apartment" means.

It definitely has to do with the function as I have striped everything
out and just run this in main:
For x As Integer = 1 To 200
Email = GetUserInfo("Te st User", "mail")
Console.WriteLi ne(x)
Next

Anything less then ~180 and I don't get the message. The Function was
copied (shame on me) from google. I added the Finally clause to see
if disposing would help. The directory path has been changed to
protect the innocent.
Public Function GetUserInfo(ByV al inSAM As String, ByVal inType As
String) As String

Dim sPath As String = "LDAP://xxx/DC=xxx,DC=com"
Dim SamAccount As String = Right(inSAM, Len(inSAM) -
InStr(inSAM, "\"))
Dim myDirectory As New DirectoryEntry( sPath)
Dim mySearcher As New DirectorySearch er(myDirectory)
Dim mySearchResultC oll As SearchResultCol lection
Dim mySearchResult As SearchResult
Dim myResultPropCol l As ResultPropertyC ollection
Dim myResultPropVal ueColl As ResultPropertyV alueCollection

Try
'Build LDAP query
mySearcher.Filt er = ("(&(objectClas s=user)(name=" &
SamAccount & "))")
mySearchResultC oll = mySearcher.Find All()
'I expect only one user from search result
Select Case mySearchResultC oll.Count
Case 0
Return "Not Found"
Exit Function
Case Is 1
Return "Multiple"
Exit Function
End Select

'Get the search result from the collection
mySearchResult = mySearchResultC oll.Item(0)

'Get the Properites, they contain the usefull info
myResultPropCol l = mySearchResult. Properties

'displayname, mail
'Retrieve from the properties collection the display name
and email of the user
myResultPropVal ueColl = myResultPropCol l.Item(inType)
Return CStr(myResultPr opValueColl.Ite m(0))

Catch ex As System.Exceptio n
Return "Null"
'do some error return here.

Finally
mySearcher.Disp ose()
myDirectory.Dis pose()
End Try

End Function

What am I doing wrong here?

Feb 19 '07 #1
2 4851
No one has any suggestions on this?

Feb 26 '07 #2
Oh come on...there is not one person out there that has a suggestion
on what could be causing this?
Mar 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
28072
by: Chandika | last post by:
Hi all, One of my database was suspected, So I try to recover database then it gives this error Err. 823 Torn Page Detected 823, ... 24, spid51 i/o error Torn Page (Detected) during read at offset 0x0000000040e0000 in file .........
3
43231
by: Tim Reynolds | last post by:
I support a .Net application running on a SERVER accessing MF Db2 data. Occasionally, we have some type of connection problem that we have been unable to debug up to this point. We typically receive one of these IBM.Data.DB2.DB2Exception messages: ERROR SQL30081N A communication error has been detected. Communication protocol being used: ‘TCP/IP'. Communication API being used: ‘SOCKETS'. Location where the error was detected:...
3
7044
by: Laura | last post by:
I've just installed the DB2 Run-time client in a Solaris machine. Then I finnish the installation configuring the connection: 1. machine catalog was OK: ========================== $ db2 catalog tcpip node atlas remote dsroracle server 8100 DB20000I The CATALOG TCPIP NODE command completed successfully. DB21056W Directory changes may not be effective until the directory cache is refreshed. 2. database catalog was OK:
4
36170
by: Ralf Gross | last post by:
Hi, I installed DB2 V8.1 with fixpak 10, created a new database and can connect to the database. $ db2 connect to mkstest Database Connection Information Database server = DB2/LINUX 8.2.3
32
5952
by: Clunixchit | last post by:
How can i read lines of a file and place each line read in an array? for exemple; array=line1 array=line2 ...
0
1107
by: sam.s.kong | last post by:
Hi! When I create or modify an asp file, obvious systax errors are not detected. For example: Sub MySub Response.Write "Hello" End
0
1312
by: Dean Hinson | last post by:
Hello, I have received this message when I exit a program I am working on... DisconnectedContext was detected Message: Context 0x18fbd0' is disconnected. Releasing the interfaces from the current context (context 0x18fa80).This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the application is completely done with the RuntimeCallableWrappers that represent COM...
6
7533
by: Zytan | last post by:
Make a WebBrowser control, and make a bunch of timers / threads that continually call WebBrowser.Document.Write. Eventually, this happens: DisconnectedContext was detected Message: Context 0x1a1530' is disconnected. Releasing the interfaces from the current context (context 0x1a13c0).This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/ apartments stay alive until the applicationis completely...
0
1433
by: Kim Briggs | last post by:
I am developing an BHO/Explorer Bar using Addin Express for Internet Explorer (a framework to get MSHTML/COM Interop newbies like myself off the ground). Target browser is IE7. Occasionally, I get this message (not reliably reproducible but seems to happen with >1 tabs open -- so >1 BHO instances -- and around tab open/close events): DisconnectedContext was detected
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9543
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.