As Eric allueded to, you've got to watch out when using objects from other assemblies. Unless you're using an interface or class type shared from the same .dll, you'll run into problems. In other words, the assembly creating the object and the assembly trying to downcast the object must both reference a separate assembly that describes the interface or class to which you are downcasting. (Does that make sense?)
I'm attempting to retrieve an Active Directory attribute that is stored as as type OctetString. I want to convert this value to a string, but the Convert class doesn't seem to be able to do this. Can someone help?
Marc Merritt wrote: is stored as as type OctetString
Hmmm, ok I had to do a little searching here but if you read MSDN's page on ADS_OCTET_STRING[^] you will see that it is a struct containing a byte array. To convert this you might want to look into the BitConverter.ToString(..) method as it may handle this. You may also need to refer to the Marshal class under System.Runtime.InteropServices. Hope this helps.
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
Myself and 4 other developers using .Net (C#) in the development of new
software applications have the same problem with .Net. We are all working
on different products seperately and have all seen the same bug.
The user develops user controls (UserControl) and stores them in a common project.
User adds this project to his main application project. User adds these
controls to his forms in his project. User goes a few weeks to months designing
his GUI. One day user opens his project to find controls and/or code
missing from his forms. The damn generated code just disappears along with
the controls on the form. This first happended to me 3 months ago and just
I am one of these users. I use Source Safe, other people have used StarTeam
with the same results. Retrieving previously saved versions from SourceSafe
doesn't help because the .Net IDE has a mind of it's own and removes these
controls once again.
If anyone has any idea of what can be causing this or have experienced the
same, please let me know. This is my first post here so if this has been a
common topic before please excuse me.
I am using fully qualified names for my controls. For example,
private [namespace name].ControlName m_Control
After I did this my code was actually stable for about 3
months and it just reappeared again last week. It reappeared
after the library failed to build. I fixed the library bug that
I introduced and now .Net has a mind of it's own. On my
simplest form I readded my controls, closed and saved them,
then reopened them to find the controls missing again.
.Net IDE even removed some event handling code.
The only way I know of is to override WndProc and handle the various commands related to WM_ACTIVATE and WM_ACTIVATEAPP. If you haven't done it before, a search here and on Google might help you find someone who has implemented it in .NET. (I know there is one, I just can't remember where.)
I keep getting a casting exception in the following section of code. I can't seem to convert from the object to int.
is there any way of getting the first element from queryCollection other than having to enmerate through it?
Thanks for yeer help,
ManagementObjectCollection queryCollection = query.Get();
foreach(ManagementObject mo in queryCollection)
Don't know if this is the problem, but you can't cast an int from an object unless the object is an int. I've no idea what Terminate returns, so it's impossible to say whether it is an int in these terms.
You might want to try tempint = Convert.ToInt32(obj); instead of direct casting.
Paul I think there're pieces of me you've never seen - Tori Amos, Tear in Your Hand