|
There is a major bug in the ICSharpCode.Core sample:
public static string GetFileFilter(string addInTreePath)
{
StringBuilder b = new StringBuilder();
b.Append("All known file types|");
foreach (string filter in AddInTree.BuildItems<string>(addInTreePath, null, true)) {
b.Append(filter.Substring(filter.IndexOf('|') + 1));
b.Append(';');
}
foreach (string filter in AddInTree.BuildItems<string>(addInTreePath, null, true)) {
b.Append('|');
b.Append(filter);
}
b.Append("|All files|*.*");
return b.ToString();
}
This code will throw an InvalidCastException as the type FileFilterDescriptor (the type of object the addInTreePath refers to) cannot be converted to a string .
The following code is the fix for this:
public static string GetFileFilter(string addInTreePath)
{
StringBuilder b = new StringBuilder();
b.Append("All known file types|");
foreach (FileFilterDescriptor filter in AddInTree.BuildItems<FileFilterDescriptor>(addInTreePath, null, true)) {
b.Append(filter.ToString().Substring(filter.ToString().IndexOf('|') + 1));
b.Append(';');
}
foreach (FileFilterDescriptor filter in AddInTree.BuildItems<FileFilterDescriptor>(addInTreePath, null, true)) {
b.Append('|');
b.Append(filter.ToString());
}
b.Append("|All files|*.*");
return b.ToString();
}
I spent about an hour trying to figure out what caused the crash!
I hate samples that have critical bugs like this!
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
Zac Greve wrote:
I hate samples that have critical bugs like this!
Yes, that is annoying big time. Did you contact them about the fix?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I posted a message on the article for the sample.
At first I thought it was just VB with Option Strict On, but the sample itself gave the same error when I ran it.
A number of the samples that ship with #D have bugs.
This is not the worst I have found, though. One program I was looking at was buggier than a termite mound, and it seemed only Chuck Norris could get rid of those bugs. And no, this was NOT PHP! PHP looked good in comparison!
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
I have found more that a few in the SQL Server examples. Many are due to not updating the code between versions. But it is frustrating.
|
|
|
|
|
Hi Zac,
Why not post this as a Tip/Trick here on CP, or, on the C# general forum ? imho, this is purely a technical post, primarily code, related to ICSharpCode. CP has no forum for Mono, ICSharpCode, etc., and there are only a total of 15 items in the categories, Articles, Tips/Tricks, Technical Blogs for the search term "ICSharpCode."
This type of post, here, just gets "submerged" in the vast flow of the Lounge. My saying this, does not mean I don't appreciate your technical skill in fixing bad code !
yrs, Bill
~
"access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." The future as envisioned by Eric Schmidt, CEO, Google, in an interview with USA Today.
|
|
|
|