|
0x80040154 is an HRESULT error that translates to "Class not registered."
Do you have MDAC[^] installed on the test machine?
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
MDAC installed fine when I installed the framework for .NET.
|
|
|
|
|
Then look for another object that is using COM. The HRESULT is very clear: the object you are looking for is not registered and therefore can not be created let alone call any function upon.
|
|
|
|
|
Hi all
i have a tab page form. One tab has a file dialog that searches for a file on a form, and the other tab has a treeview that is populated with icons. When the form closes and i try to relaunch the form the following code:
myImageList.Images.Add(new Icon(imageFolder + "button.ico"));
goes looking for the icons at the last location that the file dialog returned,.... Why?
confused
|
|
|
|
|
Is the RestoreDirectory property set to true?
From OpenFileDialog help:
Gets or sets a value indicating whether the dialog box restores the current directory before closing.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Your code should never assume that the current directory will never change. That's what happening after your file dialog closes. It's changed the current directory.
Let me guess, the value of imageFolder is just a directory name and not a full path?
You should be building a complete full path to any file that your application attempts to get. You could easily accomplish your posted task by creating a small method that returns the full path to the imageFolder directory:
public string GetImageFolderPath()
{
return Path.Combine(Application.StartupPath, imageFolder);
}
Even better, have your function build the complete path to the image file:
public string GetPathToImageFile(string filename)
{
return Path.Combine( Path.Combine(Application.StartupPath, imagefolder), filename);
}
Then all you have to do in your posted code is:
myImageList.Images.Add( new Icon( GetPathToImageFile("button.ico") ) );
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I would to create a key (not a directory) within "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" path
RegistryKey myKey = Registry.LocalMachine;
myKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
myKey.CreateSubKey("MyKey");
myKey.SetValue("MyKey", Application.ExecutablePath);
i get exceprion on 3° line of code, and nothing is created, why?
|
|
|
|
|
|
|
|
Why are you writing to LocalMachine?
Do you have the permissions nessessary for this?
Cant you write to CurrentUser?
Will
|
|
|
|
|
I have an array of bytes which i need to get bits from in 5-bit chunks.
e.g. lets say my byte array has 4 values
0 - 10101010
1 - 10101010
2 - 10101010
3 - 10101010
i would like an array of strings (or whatever, could be bytes with leading 0) that returns to me the values
0 - (000)10101 (first 5 bits of 0)
1 - (000)01010 (last 3 bits of 0 and first 2 bits of 1)
2 - (000)10101 (mid 5 bits of 1)
.
.
so on
How can I do this in C#?
Thanks
|
|
|
|
|
Since that's only 32 combinations, why not use a lookup table? Then all you need to do is some bit shifting and and'ing.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Thanks Marc, this seems to do the trick but if any1 has a suggestion to make this process faster and less complicated then go right ahead.
private byte[ ] EncodeArray( byte[ ] parentArray )
{
byte[ ] retArr = new byte[ parentArray.Length * 8 / 5 ];
int i = 0;
int pos = 0;
while ( i < parentArray.Length )
{
if ( i % 5 == 0 )
{
byte mask = 0xF8;
int result = parentArray[ i ] & mask ;
retArr[ pos++ ] = ( byte ) result;
mask = 0x7;
byte mask2 = 0xC0;
int result1 = parentArray[ i ] & mask ;
int result2;
if ( i + 1 < parentArray.Length )
{
result2 = parentArray[ i + 1 ] & mask2 ;
}
else
result2 = 0;
result = ( result1 << 2 ) + ( result2 >> 6);
retArr[ pos++ ] = ( byte ) result;
}
else if ( i % 5 == 1 )
{
byte mask = 0x3E;
int result = parentArray[ i ] & mask;
retArr[ pos++ ] = ( byte ) result;
mask = 0x1;
byte mask2 = 0xF0;
int result1 = parentArray[ i ] & mask;
int result2;
if ( i + 1 < parentArray.Length )
{
result2 = parentArray[ i + 1 ] & mask2 ;
}
else
result2 = 0;
result = ( result1 << 4 ) + ( result2 >> 4 );
retArr[ pos++ ] = ( byte ) result;
}
else if ( i % 5 == 2 )
{
byte mask = 0xF;
byte mask2 = 0x80;
int result1 = parentArray[ i ] & mask;
int result2;
if ( i + 1 < parentArray.Length )
{
result2 = parentArray[ i + 1] & mask2;
}
else
result2 = 0;
int result = ( result1 << 1 ) + ( result2 >> 7 );
retArr[ pos++ ] = ( byte ) result;
}
else if ( i % 5 == 3 )
{
byte mask = 0x7C;
int result = parentArray [ i ] & mask;
retArr[ pos++ ] = ( byte ) result;
mask = 0x3;
byte mask2 = 0xE0;
int result1 = parentArray[ i ] & mask;
int result2;
if ( i + 1 < parentArray.Length )
{
result2 = parentArray[ i + 1] & mask2;
}
else
result2 = 0;
result = ( result1 << 2 ) + ( result2 >> 5 );
retArr[ pos++ ] = ( byte ) result;
}
else if ( i % 5 == 3 )
{
byte mask = 0x1F;
int result = parentArray [ i ] & mask;
retArr[ pos++ ] = ( byte ) result;
}
i++;
}
return retArr;
}
|
|
|
|
|
This seems overly complex and there are some errors. It seems that the masks should go:
F8, 7C, 3E, 1F
Also, there's two tests for (i % 5) == 3
Instead of changing the mask, why not shift the byte under test and 'or' in the necessary bits from a look ahead byte (which is 0 if at the end of the array). It's a bit complicated (no pun intended) because you have to figure out when to get the next byte, but you should be able to do the whole thing in a loop.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Have a look at the BitArray class. You can feed it with a byte array and afterwards pick the bits one after the other:
BitArray ba = new BitArray(b);
int counter = 0;
string temp = "";
while (counter < ba.Length)
{
int mod = counter % 8;
temp += ba[counter - 2 * mod + 7] ? "1" : "0";
if (counter % 5 == 4)
{
Console.WriteLine(temp);
temp = "";
}
counter++;
}
if (temp.Length > 0)
Console.WriteLine("Left: " + temp);
The formula when accessing the BitArray indexer seems a bit complicated and results from the fact that the bits from each byte put into the constructor seem to be reversed.
|
|
|
|
|
Is it just me or does everyone feel cheated when you don't get a feedback wether a solution worked or not? Maybe I am just small...
|
|
|
|
|
Whats even worse is that you sometimes dont even get to know if your answer was read or if you have wasted your time because the answer wasnt even read by the questioner.
|
|
|
|
|
Exactly!!
|
|
|
|
|
niansah wrote:
Is it just me or does everyone feel cheated when you don't get a feedback wether a solution worked or not?
It is good to know. Especially given that some people's command of the language isn't so great and I wonder whether I interpreted their original question correctly in the first place.
niansah wrote:
Maybe I am just small...
No. Feedback is important in all areas. You cannot improve without feedback. Imagine a baby learning to walk. Without the feedback of the sensation of hitting the floor when they stumble they won't know what moves work and what don't.
Answering questions is great as a learning tool and to keep information going. It is amazing how much more information I can retain by helping others. Mainly because the problems they have may not be in the same area I am currently working on, so by thinking about the area they are asking about keeps the information fresh in my mind, so that if I move back to that area I can recall it much quicker.
Sometimes I feel that I can't be bothered answering questions here. If I feel really bad about not being appreciated or that I'm being used I just leave it a couple of days then come back.
So, don't feel discouraged about people not leaving feedback on your answers. There are many people here who genuinely appreciate the efforts made by those who share knowledge.
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Hi,
I am trying to get all the farm name attrbute from Xml files thorugh loop
I have to verify conditoion that when farm name is equal to dev1
It should exit from the loop
my code retrieves only one value from farm name dev2 my code does not search for farm name dev2
any body can help me giving me code
XmlDocument doc = new XmlDocument();
doc.Load("c:/farm-config.xml");
XmlNode farm=doc.SelectSingleNode("/root/farm-config/farm/@name");
MessageBox.Show(farm.InnerText);
xml file strucutyue is as given below
Hi,
I am trying to get all the farm name from Xml files.
This is my xml file structure
<?xml version="1.0" encoding="UTF-8"?>
<root>
<farm-config>
<farm name="dev2">
<connection address="localhost1" user="root1" selectedConnection="1" password="daask6">
<lastJob>Copy-All</lastJob>
<lastConnection startdate="2005-05-10" starttime="12:43:23" enddate="2005-05-10" endtime="12:58:32" />
<state>1</state>
</connection>
</farm>
<farm name="dev1">
<connection address="localhost1" user="root1" selectedConnection="1" password="daask2">
<lastJob>Copy-All</lastJob>
<lastConnection startdate="2005-05-10" starttime="12:43:23" enddate="2005-05-10" endtime="12:58:32" />
<state>1</state>
</connection>
</farm>
</farm-config>
</root>
regards
sanjeev
|
|
|
|
|
Well, given your query, InnerText would only return a result if:
<farm name="dev2">Some text</farm>
You may want InnerXml instead.
Marc
<a href="http://www.myxaml.com">MyXaml</a>
<a href="http://aut.tigris.org">Advanced Unit Testing</a>
<a href="http://wdevs.com/Default.aspx?tabid=80">YAPO</a>
|
|
|
|
|
hi!
Perhaps I've misunderstood you, but XmlNode.SelectSingleNode will always return a single node.
If you want several nodes you should use XmlNode.SelectNodes()...
mav
|
|
|
|
|
XmlDocument doc = new XmlDocument();<br />
doc.Load("c:/farm-config.xml");<br />
XmlNodeList farm=doc.SelectNodes("//farm");<br />
foreach(XmlNode n in farm)<br />
{<br />
if (n.Attributes.GetNamedItem("name").Value == "dev1")<br />
MessageBox.Show(n.Attributes.GetNamedItem("name").Value + " is a match!" );<br />
else<br />
MessageBox.Show(n.Attributes.GetNamedItem("name").Value + " is not a match!" );<br />
}<br />
|
|
|
|
|
I have the following situation:
Person A performs an application action that affects Person B. Management wants the application to automatically generate an e-mail to Person B, notifying them of the action. I can think of two solutions. 1) Query the Active Directory LDAP server for the e-mail address tied to Person B. 2) Get a dump of the e-mail addresses from the Exchange administrator and tie it into the application like another table.
I don't like #2 because it doesn't account for change very well and I don't want to implement ANOTHER import/reconcile process if I don't have to. However, I've never done LDAP work and don't know how to exactly go about "eating this elephant". The proverbial answer is "one bite at a time", but where to start?
BTW: The application is ASP. NET. The domain is Win Server 2000, Exchange 2000, and SQL Server 2000.
Suggestions, pointers, hints, and help are welcome.
Thanks in advance,
Darien
"I don't know. I haven't tried today." - Trumpet icon Maynard Ferguson's response when asked how high he could play.
|
|
|
|