473,473 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Conversion from type '_ComObject' to type 'String' is not valid

3 New Member
Hi guys i got following error while i am running my program
here is the code scratch where i got an exception :

Try
Dim de As New DirectoryEntry("LDAP://xxx/dc=xxx,dc=com", "aaa", "secret")
Dim MyAttributes As PropertyCollection
Dim MyAttributeName As String
Dim myValue As String
Dim MyAttributeValues As PropertyValueCollection
MyAttributes = de.Properties


For Each MyAttributeName In MyAttributes.PropertyNames
MyAttributeValues = MyAttributes(MyAttributeName)
Console.WriteLine("------------------------------")
For Each myValue In MyAttributeValues
Console.WriteLine(CType(MyAttributeName, String) & " : " & CType(myValue, String))
Next
Next
Catch ex As Exception
Console.WriteLine("ex: " + ex.Message)
End Try

Where is the wrong section ?
please help me guys
any help would be totally appreciated ....
Jan 7 '09 #1
6 5846
r035198x
13,262 MVP
@dodol135
Use e.StackTrace instead of e.Message to get the exact line number.
Jan 7 '09 #2
dodol135
3 New Member
OK i'm sorry
here is the line where i got exception :

For Each myValue In MyAttributeValues
Jan 7 '09 #3
r035198x
13,262 MVP
myValue is a String and the runtime has just told you that the values in MyAttributeValues are _ComObjects type(whatever that is).
Better declare Dim myValue As Object instead.
Jan 7 '09 #4
dodol135
3 New Member
OK, but the main problem is what should i do to manage this error
changing myValue with object is doesnt solve the problem either
because __Comtype is not convertible to string,
and i need to convert to string for listing all field that exist in particular active directory ....
any suggestion ?
Jan 7 '09 #5
r035198x
13,262 MVP
The object class has a ToString method. If those objects implemented it correctly then you should get what you want from the ToString.
Jan 7 '09 #6
jg007
283 Contributor
If I recall correctly had a pretty similar error when accessing AD from VB and it was because I was accessing a collection of objects ( Memberof ) and I just had to ammend it to do a 'For each' on member of.
Jan 8 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Varun Singal | last post by:
Hi I am calling .NET components from my Classical ASPs. For this I strong named my assemblies, then registered them in the resistry ( using RegAsm), and put them in GAC (using GacUtil) ....
30
by: Tim Johansson | last post by:
I'm new to C++, and tried to start making a script that will shuffle an array. Can someone please tell me what's wrong? #include <iostream.h> #include <string.h> int main () {...
2
by: Sankar Nemani | last post by:
Why does the following code throw an exception? object o = new object{"sankar", "sankar2"}; string s; s =(string)o; The C# language spec says something different on MSDN: For any two...
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
4
by: rz0 | last post by:
Hi all, This is a question about both C89 and C99 and is based on my partial reading of the standard drafts (one from before C89 but mainly N1124). If appropriate, please give a...
2
by: Chris | last post by:
Hi again, I want to read all the records of a table with 2 fields. The problem is that some records have null value in the second field. This code below works when all records have both fields...
4
by: mark.olszowka | last post by:
I am writing a generic property table as part of my application property_name property_type property_value All information is stored in the database as strings. In my application that...
3
by: Ady1 | last post by:
Hi, I'm getting this error intermitantly in a custom configuration section in my ASP.NET website. From what I can see 0.175 is a valid string to be converted to a decimal! And most of the time...
10
by: =?Utf-8?B?TWlrZQ==?= | last post by:
I have a string variable containing a date formatted as YYYYMMDD For example - Dim x as string = "20070314" If I try to perform a type conversion as follows I get an error: Dim y as Date =...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.