473,662 Members | 2,760 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DirectoryServic es Cast Error?

Hello, and Thanks in advance!
Using: Vstudio 2005, XP, .NET 2.0

I'm getting the following error when running my code below. I'm
passing an object array which contains other variables. It happens
immediately when it hits the "For" loop:

Unable to cast COM object of type 'System.__ComOb ject' to interface
type 'IDirectorySear ch'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{109BA8EC-92F0-11D0-A790-00C04FD8D5A8}' failed due to the following
error: No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE) ).

I also have a problem where in my "New" method, it gives me a late
binding error with option strict on.

I'm basically creating multiple threads from this thread to go and do
some time consuming work, which doesn't require much processing power
or resources.

Option Strict Off
Imports System.Text.Reg ularExpressions
Public Class controlThreadCl ass
Dim svrInfo As serverInfo
Dim mtDict As Dictionary(Of Integer, String)
Dim svrResults As System.Director yServices.Searc hResultCollecti on
Dim threadList As System.Collecti ons.ArrayList
Dim objSrvr As System.Director yServices.Searc hResult

Public Sub New(ByVal obj As Object)
svrInfo = DirectCast(obj( 0), serverInfo)
mtDict = DirectCast(obj( 1), Dictionary(Of Integer, String))
svrResults = DirectCast(obj( 2),
System.Director yServices.Searc hResultCollecti on)
End Sub

Public Sub ControlThread()
'This thread keeps the UI responsive and manages the
serverThread threads
Dim i2 As Integer = 1

Dim sThread As System.Threadin g.Thread
Dim creds As New secCreds
Dim su As New SwitchUser
Dim serverThread As serverThreadCla ss
Dim serverThreadVal s As Object
Dim strVal As String

'Here's where my error occurs, as soon as you hit the "For" loop...
For Each objSrvr In svrResults

....other code here.....
End If
i2 += 1
Next

End Sub
End Class

Dec 21 '06 #1
6 2089
Your calling thread and thread it is on must match.

http://forums.microsoft.com/MSDN/Sho...51863&SiteID=1
"Bmack500" <br********@gma il.comwrote in message
news:11******** **************@ a3g2000cwd.goog legroups.com...
Hello, and Thanks in advance!
Using: Vstudio 2005, XP, .NET 2.0

I'm getting the following error when running my code below. I'm
passing an object array which contains other variables. It happens
immediately when it hits the "For" loop:

Unable to cast COM object of type 'System.__ComOb ject' to interface
type 'IDirectorySear ch'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{109BA8EC-92F0-11D0-A790-00C04FD8D5A8}' failed due to the following
error: No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE) ).

I also have a problem where in my "New" method, it gives me a late
binding error with option strict on.

I'm basically creating multiple threads from this thread to go and do
some time consuming work, which doesn't require much processing power
or resources.

Option Strict Off
Imports System.Text.Reg ularExpressions
Public Class controlThreadCl ass
Dim svrInfo As serverInfo
Dim mtDict As Dictionary(Of Integer, String)
Dim svrResults As System.Director yServices.Searc hResultCollecti on
Dim threadList As System.Collecti ons.ArrayList
Dim objSrvr As System.Director yServices.Searc hResult

Public Sub New(ByVal obj As Object)
svrInfo = DirectCast(obj( 0), serverInfo)
mtDict = DirectCast(obj( 1), Dictionary(Of Integer, String))
svrResults = DirectCast(obj( 2),
System.Director yServices.Searc hResultCollecti on)
End Sub

Public Sub ControlThread()
'This thread keeps the UI responsive and manages the
serverThread threads
Dim i2 As Integer = 1

Dim sThread As System.Threadin g.Thread
Dim creds As New secCreds
Dim su As New SwitchUser
Dim serverThread As serverThreadCla ss
Dim serverThreadVal s As Object
Dim strVal As String

'Here's where my error occurs, as soon as you hit the "For" loop...
For Each objSrvr In svrResults

....other code here.....
End If
i2 += 1
Next

End Sub
End Class

Dec 21 '06 #2
Could you elaborate? Match in what way? Sorry, I'm diving head first
into multithreading; waiting for some books to arrive!

vbnetdev wrote:
Your calling thread and thread it is on must match.

http://forums.microsoft.com/MSDN/Sho...51863&SiteID=1
"Bmack500" <br********@gma il.comwrote in message
news:11******** **************@ a3g2000cwd.goog legroups.com...
Hello, and Thanks in advance!
Using: Vstudio 2005, XP, .NET 2.0

I'm getting the following error when running my code below. I'm
passing an object array which contains other variables. It happens
immediately when it hits the "For" loop:

Unable to cast COM object of type 'System.__ComOb ject' to interface
type 'IDirectorySear ch'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{109BA8EC-92F0-11D0-A790-00C04FD8D5A8}' failed due to the following
error: No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE) ).

I also have a problem where in my "New" method, it gives me a late
binding error with option strict on.

I'm basically creating multiple threads from this thread to go and do
some time consuming work, which doesn't require much processing power
or resources.

Option Strict Off
Imports System.Text.Reg ularExpressions
Public Class controlThreadCl ass
Dim svrInfo As serverInfo
Dim mtDict As Dictionary(Of Integer, String)
Dim svrResults As System.Director yServices.Searc hResultCollecti on
Dim threadList As System.Collecti ons.ArrayList
Dim objSrvr As System.Director yServices.Searc hResult

Public Sub New(ByVal obj As Object)
svrInfo = DirectCast(obj( 0), serverInfo)
mtDict = DirectCast(obj( 1), Dictionary(Of Integer, String))
svrResults = DirectCast(obj( 2),
System.Director yServices.Searc hResultCollecti on)
End Sub

Public Sub ControlThread()
'This thread keeps the UI responsive and manages the
serverThread threads
Dim i2 As Integer = 1

Dim sThread As System.Threadin g.Thread
Dim creds As New secCreds
Dim su As New SwitchUser
Dim serverThread As serverThreadCla ss
Dim serverThreadVal s As Object
Dim strVal As String

'Here's where my error occurs, as soon as you hit the "For" loop...
For Each objSrvr In svrResults

....other code here.....
End If
i2 += 1
Next

End Sub
End Class
Dec 21 '06 #3
Make sure the declaration of the object and the actions that occur with the
object exist in the same thread.
"Bmack500" <br********@gma il.comwrote in message
news:11******** *************@a 3g2000cwd.googl egroups.com...
Could you elaborate? Match in what way? Sorry, I'm diving head first
into multithreading; waiting for some books to arrive!

vbnetdev wrote:
>Your calling thread and thread it is on must match.

http://forums.microsoft.com/MSDN/Sho...51863&SiteID=1
"Bmack500" <br********@gma il.comwrote in message
news:11******* *************** @a3g2000cwd.goo glegroups.com.. .
Hello, and Thanks in advance!
Using: Vstudio 2005, XP, .NET 2.0

I'm getting the following error when running my code below. I'm
passing an object array which contains other variables. It happens
immediately when it hits the "For" loop:

Unable to cast COM object of type 'System.__ComOb ject' to interface
type 'IDirectorySear ch'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{109BA8EC-92F0-11D0-A790-00C04FD8D5A8}' failed due to the following
error: No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE) ).

I also have a problem where in my "New" method, it gives me a late
binding error with option strict on.

I'm basically creating multiple threads from this thread to go and do
some time consuming work, which doesn't require much processing power
or resources.

Option Strict Off
Imports System.Text.Reg ularExpressions
Public Class controlThreadCl ass
Dim svrInfo As serverInfo
Dim mtDict As Dictionary(Of Integer, String)
Dim svrResults As System.Director yServices.Searc hResultCollecti on
Dim threadList As System.Collecti ons.ArrayList
Dim objSrvr As System.Director yServices.Searc hResult

Public Sub New(ByVal obj As Object)
svrInfo = DirectCast(obj( 0), serverInfo)
mtDict = DirectCast(obj( 1), Dictionary(Of Integer, String))
svrResults = DirectCast(obj( 2),
System.Director yServices.Searc hResultCollecti on)
End Sub

Public Sub ControlThread()
'This thread keeps the UI responsive and manages the
serverThread threads
Dim i2 As Integer = 1

Dim sThread As System.Threadin g.Thread
Dim creds As New secCreds
Dim su As New SwitchUser
Dim serverThread As serverThreadCla ss
Dim serverThreadVal s As Object
Dim strVal As String

'Here's where my error occurs, as soon as you hit the "For" loop...
For Each objSrvr In svrResults

....other code here.....
End If
i2 += 1
Next

End Sub
End Class

Dec 21 '06 #4
Any chance you could provide a quick example? Sorry, I hate to
impose....

vbnetdev wrote:
Make sure the declaration of the object and the actions that occur with the
object exist in the same thread.
"Bmack500" <br********@gma il.comwrote in message
news:11******** *************@a 3g2000cwd.googl egroups.com...
Could you elaborate? Match in what way? Sorry, I'm diving head first
into multithreading; waiting for some books to arrive!

vbnetdev wrote:
Your calling thread and thread it is on must match.

http://forums.microsoft.com/MSDN/Sho...51863&SiteID=1
"Bmack500" <br********@gma il.comwrote in message
news:11******** **************@ a3g2000cwd.goog legroups.com...
Hello, and Thanks in advance!
Using: Vstudio 2005, XP, .NET 2.0

I'm getting the following error when running my code below. I'm
passing an object array which contains other variables. It happens
immediately when it hits the "For" loop:

Unable to cast COM object of type 'System.__ComOb ject' to interface
type 'IDirectorySear ch'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{109BA8EC-92F0-11D0-A790-00C04FD8D5A8}' failed due to the following
error: No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE) ).

I also have a problem where in my "New" method, it gives me a late
binding error with option strict on.

I'm basically creating multiple threads from this thread to go and do
some time consuming work, which doesn't require much processing power
or resources.

Option Strict Off
Imports System.Text.Reg ularExpressions
Public Class controlThreadCl ass
Dim svrInfo As serverInfo
Dim mtDict As Dictionary(Of Integer, String)
Dim svrResults As System.Director yServices.Searc hResultCollecti on
Dim threadList As System.Collecti ons.ArrayList
Dim objSrvr As System.Director yServices.Searc hResult

Public Sub New(ByVal obj As Object)
svrInfo = DirectCast(obj( 0), serverInfo)
mtDict = DirectCast(obj( 1), Dictionary(Of Integer, String))
svrResults = DirectCast(obj( 2),
System.Director yServices.Searc hResultCollecti on)
End Sub

Public Sub ControlThread()
'This thread keeps the UI responsive and manages the
serverThread threads
Dim i2 As Integer = 1

Dim sThread As System.Threadin g.Thread
Dim creds As New secCreds
Dim su As New SwitchUser
Dim serverThread As serverThreadCla ss
Dim serverThreadVal s As Object
Dim strVal As String

'Here's where my error occurs, as soon as you hit the "For" loop...
For Each objSrvr In svrResults

....other code here.....
End If
i2 += 1
Next

End Sub
End Class
Dec 22 '06 #5
Zip and send me your project and I will see what I can do.
"Bmack500" <br********@gma il.comwrote in message
news:11******** **************@ 48g2000cwx.goog legroups.com...
Any chance you could provide a quick example? Sorry, I hate to
impose....

vbnetdev wrote:
>Make sure the declaration of the object and the actions that occur with
the
object exist in the same thread.
"Bmack500" <br********@gma il.comwrote in message
news:11******* **************@ a3g2000cwd.goog legroups.com...
Could you elaborate? Match in what way? Sorry, I'm diving head first
into multithreading; waiting for some books to arrive!

vbnetdev wrote:
Your calling thread and thread it is on must match.

http://forums.microsoft.com/MSDN/Sho...51863&SiteID=1
"Bmack500" <br********@gma il.comwrote in message
news:11******* *************** @a3g2000cwd.goo glegroups.com.. .
Hello, and Thanks in advance!
Using: Vstudio 2005, XP, .NET 2.0

I'm getting the following error when running my code below. I'm
passing an object array which contains other variables. It happens
immediately when it hits the "For" loop:

Unable to cast COM object of type 'System.__ComOb ject' to interface
type 'IDirectorySear ch'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{109BA8EC-92F0-11D0-A790-00C04FD8D5A8}' failed due to the following
error: No such interface supported (Exception from HRESULT:
0x80004002
(E_NOINTERFACE) ).

I also have a problem where in my "New" method, it gives me a late
binding error with option strict on.

I'm basically creating multiple threads from this thread to go and
do
some time consuming work, which doesn't require much processing
power
or resources.

Option Strict Off
Imports System.Text.Reg ularExpressions
Public Class controlThreadCl ass
Dim svrInfo As serverInfo
Dim mtDict As Dictionary(Of Integer, String)
Dim svrResults As System.Director yServices.Searc hResultCollecti on
Dim threadList As System.Collecti ons.ArrayList
Dim objSrvr As System.Director yServices.Searc hResult

Public Sub New(ByVal obj As Object)
svrInfo = DirectCast(obj( 0), serverInfo)
mtDict = DirectCast(obj( 1), Dictionary(Of Integer, String))
svrResults = DirectCast(obj( 2),
System.Director yServices.Searc hResultCollecti on)
End Sub

Public Sub ControlThread()
'This thread keeps the UI responsive and manages the
serverThread threads
Dim i2 As Integer = 1

Dim sThread As System.Threadin g.Thread
Dim creds As New secCreds
Dim su As New SwitchUser
Dim serverThread As serverThreadCla ss
Dim serverThreadVal s As Object
Dim strVal As String

'Here's where my error occurs, as soon as you hit the "For" loop...
For Each objSrvr In svrResults

....other code here.....
End If
i2 += 1
Next

End Sub
End Class


Dec 22 '06 #6
Bmack,
Any chance you could provide a quick example? Sorry, I hate to
impose....
We too, you are passing an object. First of all, try to avoid that secondly
we have not any idea what it can be, as far as I can see is it a Type that
holds all kinds of different Types.

That makes it in my idea almost impossible to answer your question.

Cor

"Bmack500" <br********@gma il.comschreef in bericht
news:11******** **************@ 48g2000cwx.goog legroups.com...
Any chance you could provide a quick example? Sorry, I hate to
impose....

vbnetdev wrote:
>Make sure the declaration of the object and the actions that occur with
the
object exist in the same thread.
"Bmack500" <br********@gma il.comwrote in message
news:11******* **************@ a3g2000cwd.goog legroups.com...
Could you elaborate? Match in what way? Sorry, I'm diving head first
into multithreading; waiting for some books to arrive!

vbnetdev wrote:
Your calling thread and thread it is on must match.

http://forums.microsoft.com/MSDN/Sho...51863&SiteID=1
"Bmack500" <br********@gma il.comwrote in message
news:11******* *************** @a3g2000cwd.goo glegroups.com.. .
Hello, and Thanks in advance!
Using: Vstudio 2005, XP, .NET 2.0

I'm getting the following error when running my code below. I'm
passing an object array which contains other variables. It happens
immediately when it hits the "For" loop:

Unable to cast COM object of type 'System.__ComOb ject' to interface
type 'IDirectorySear ch'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{109BA8EC-92F0-11D0-A790-00C04FD8D5A8}' failed due to the following
error: No such interface supported (Exception from HRESULT:
0x80004002
(E_NOINTERFACE) ).

I also have a problem where in my "New" method, it gives me a late
binding error with option strict on.

I'm basically creating multiple threads from this thread to go and
do
some time consuming work, which doesn't require much processing
power
or resources.

Option Strict Off
Imports System.Text.Reg ularExpressions
Public Class controlThreadCl ass
Dim svrInfo As serverInfo
Dim mtDict As Dictionary(Of Integer, String)
Dim svrResults As System.Director yServices.Searc hResultCollecti on
Dim threadList As System.Collecti ons.ArrayList
Dim objSrvr As System.Director yServices.Searc hResult

Public Sub New(ByVal obj As Object)
svrInfo = DirectCast(obj( 0), serverInfo)
mtDict = DirectCast(obj( 1), Dictionary(Of Integer, String))
svrResults = DirectCast(obj( 2),
System.Director yServices.Searc hResultCollecti on)
End Sub

Public Sub ControlThread()
'This thread keeps the UI responsive and manages the
serverThread threads
Dim i2 As Integer = 1

Dim sThread As System.Threadin g.Thread
Dim creds As New secCreds
Dim su As New SwitchUser
Dim serverThread As serverThreadCla ss
Dim serverThreadVal s As Object
Dim strVal As String

'Here's where my error occurs, as soon as you hit the "For" loop...
For Each objSrvr In svrResults

....other code here.....
End If
i2 += 1
Next

End Sub
End Class


Dec 22 '06 #7

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

Similar topics

0
2165
by: kovac | last post by:
The System.directoryservices.dll has an error, and this error was described in http://support.microsoft.com/default.aspx?scid=kb;en-us;839424 At the moment we have Framework version v1.0.3705 and I have remove System.directoryservices.dll from current Framework version v1.0.3705. In state of old version I load die new System.directoryservices.dll from the Framework version v1.1.4322. I work with the following function of Joe Kaplan...
1
7373
by: Jason Gleason | last post by:
I am using the following method in a web service that utilizes the system.directoryservices namespace: public ArrayList GetAllAppPools(){ System.DirectoryServices.DirectoryEntry apppools = new DirectoryEntry("IIS://webserver/W3SVC/AppPools"); ArrayList appPoolNames = new ArrayList(); foreach(DirectoryEntry de in apppools.Children) { appPoolNames.Add(de.Name);
1
16200
by: Gaab | last post by:
Hi Folks, After the weekend I wanted to start working on my c#/asp.net project, but when I tried to open it on my machine i got the following error: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
1
1719
by: Enosh Chang | last post by:
Hi all, I encounter some problem in DirectoryServices, could someone help me? private void InitLoginUser() { DirectoryEntry objEntry = new DirectoryEntry(); DirectorySearcher objSearcher = new DirectorySearcher(); SearchResult objResult;
2
5449
by: Kelvin | last post by:
Hello I am using web matrix develop a login page through Active Directory but I cannot figure out why it is giving me an error when importing system.directoryServices. Any help will do! thank Compiler Error Message: BC30466: Namespace or type 'DirectoryServices' for the Imports 'System.DirectoryServices' cannot be found Line 2: Imports System.Tex Line 3: Imports System.Collection Line 4: Imports System.DirectoryService Line 5:
6
4080
by: Mark Rae | last post by:
Hi, I'm in the process of updating an ASP.NET v1.1 web app to v2. The app uses ActiveDirectory a great deal, and I'm trying to use the new System.Collections.Generic namespace where possible, having been advised by several luminaries that that is a "good thing to do"... :-) However, I'm experiencing a problem with the IEnumerable interface. (N.B. I understand fully that I should be using the LDAP provider instead of the WinNT provider...
6
5460
by: bugnthecode | last post by:
Hi, I'm building a small desktop app in VS Std 2005 with C# and .net 2.0. I've managed to get the code together to query the ldap my company has, but every time I attempt to access a specific property a COM Exception gets thrown, and I can't figure out why. This is a desktop app. example("ldap.example.com", "ou=People,dc=example,dc=com"); public void example(string server, string ou) { searcher = new DirectorySearcher(new...
4
4969
by: =?Utf-8?B?RGF2aWQgSmVua2lucyBUb3BwYW4=?= | last post by:
I'm really having a hard time using DirectoryServices.AccountManagement. I seem to be able to get it to work fine in Visual Web Developer 2008 but when I deploy to a IIS Server I get cast issues. I have a screenshot here: http://forums.asp.net/p/1210311/2131427.aspx#2131427 Unable to cast object of type 'System.DirectoryServices.AccountManagement.GroupPrincipal' to type 'System.DirectoryServices.AccountManagement.UserPrincipal'.
7
16317
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am using this code to get groups for a user and getting a error (5) on the GetAuthorizationGroups() function . There are two domains. This function works on the local domain but does not work on the other domain. Other functions work on the other domain like get all the users and get all the groups and I can validate users on the other domain so I think I am communciating with the other domain OK just not with the...
0
8435
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
8857
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8768
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8547
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
8633
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...
0
7368
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.