|
If any of your code is in the call stack when the exception is thrown, you can handle the exception at the call site which eventually triggers the exception to be thrown. If your code is not in the call stack, then you should get the component developers to fix the bug asap.
If you are working in WinForms, perhaps hooking the Application.ThreadException event could be useful for you as well. That event fires when an exception on the UI thread is not handled and is about to crash the app.
Josh
|
|
|
|
|
I have a regular expression that I use to find html tags in a string, the expression is similar to the following:
<(?<TagName>[a-zA-Z\d]{1,})(\s[a-zA-Z\d]{1,}="[\s\w]{0,}"){0,}(\s/>|\s?>.*?</\k<TagName>>)
It's designed to detect html tags such as the following:
<strong /> OR <strong>Text</strong> OR <strong ID="supertext">Text</strong>
What I'd like to do is use this expression to split a file into an array of strings but I get odd results when I use the Regex.Split() method.
Lets say I want to split the following line of text:
The <em>quick</em> brown fox jumps over the <strong>lazy</strong> dog.<br />
Regex.Split() produces the following array:
1 - The
2 - <em>quick</em>
3 - >quick</em>
4 - em
5 - brown fox jumps over the
6 - <strong>lazy</strong>
7 - >lazy</strong>
8 - strong
9 - dog.
10 - <br />
11 - />
12 - br
It's obviously splitting on the sub groups as well as the entire tag.
Is there any way I can tell the regex engine to only split 1 group, not them all?
As you can see the solution isn't as simple as just removing the extra groupings because they are needed so that I can detect the close of an open tag, and allow more than one property to be in each html tag.
Thanks in advance for any help
|
|
|
|
|
If you need a non-catching group, use (?:
---
b { font-weight: normal; }
|
|
|
|
|
Thank you for the answer, that helped a LOT.
I've ALMOST eliminated all of the excess data, except for one thing:
The only other drama that I am facing now is that I can't apply the non matching group to the named capture group called "TagName" which I unfortunatley need to recognise the closing tag.
Is there any way that I can use a named capture group ONLY inside the regular expression, just for the purposes of matching the closing tag?
|
|
|
|
|
I think that a "Balancing group definition" could do that. I haven't looked into it enough to grasp how it's used, but I think that it could be worth a look.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I've recently built a smart client which uses 'click once deployment'. The program also uses the Enterprise Library for logging (among other things). Any errors that are encountered get logged to a database through a web service. If the communication with the web service or database fails a second logging policy is used which logs errors to a txt file.
I recently encountered such an error that caused the program to use the second policy, but I don't know where it put the log file... Click once deployment creates a program group in the start menu for the smart client which hold the executable, not a shortcut, but the actual executable. Any idea where it installs the associated DLL's, app.config file, or potential log files?
When I run the program on my development machine (not a click once deployed version) it simply creates the log file in the same directory as the executable.
Thanks in Advance.
|
|
|
|
|
ClickOnce creates a folder for each app in your local settings folder. Mine is here:
C:\Documents and Settings\<myusername>\Local Settings\Apps\2.0\WCMKYTQ4.LLO\WNRQ70YJ.7OX\
Each app gets a funky folder name under there, like:
\app..tion_a3097e953761587e_07d6.0003_47249f0b94b273b7\
Your exe and log files will most likely be under there.
JR
|
|
|
|
|
I'm having the same issue as the original poster and the log files are not there.
I even searched the entire drive including hidden and system folders, it is not on the drive anywhere. I think there may be a compatibility problem between the enterprise library text logging and clickonce. I finally resorted to doing a custom enterprise library handler and writing it out to a file myself.
|
|
|
|
|
New to dot Net.
i have been trying to learn how to use the new datagridview in 2005.
i would like to learn how to remove a row in the dataviewgrid control.
could someone please help me with this. the MS documentation showed no examples.
how do i get the correct row objects to do a row delete.
DataGridViewRowCollection rows = this.dataGridView1.Rows;
foreach (DataGridViewRowCollection Row in rows)
{
//
// Row.remove (?) something go here or are i the wrong track
}
many thanks
Steve
steve
|
|
|
|
|
Hi,
The DataGridView is a visual representation of the data to which it's bound, so the best way to remove a row is to remove it from said bound data source.
Also, be weary of code such as:
foreach (DataGridViewRowCollection Row in rows)
{
//
// Row.remove (?)
}
As you are removing something from a collection you're currently searching through.. that can get messy.
|
|
|
|
|
Simply...
DataGridViewRow row=dataGridView1.Rows[23];
dataGridView1.Rows.Remove(row)
Or
int index=23;
dataGridView1.Rows.RemoveAt(index)
This will physically remove the row, rather than marking it for deletion.
Graham
-- modified at 21:12 Tuesday 25th April, 2006
|
|
|
|
|
i will reframe from messing with the collection
and will just remove the row item number as an int
many thanks guys
steve
|
|
|
|
|
I tested this on a MS example for songs in list box "data grid"
well it told me that i couldnt delete the row
i then tried with a for loop in csharp and was told it could remove an uncommitted row
couldnt find anything on MS on line to help me
any suggestions.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
private void SetUpDataGridView()
{
this.Controls.Add(dataGridView1);
dataGridView1.ColumnCount = 5;
DataGridViewCellStyle style =
dataGridView1.ColumnHeadersDefaultCellStyle;
style.BackColor = Color.Navy;
style.ForeColor = Color.White;
style.Font = new Font(dataGridView1.Font, FontStyle.Bold);
dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter;
dataGridView1.Name = "dataGridView1";
dataGridView1.AutoSizeRowsMode =
DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
dataGridView1.ColumnHeadersBorderStyle =
DataGridViewHeaderBorderStyle.Raised;
dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.Single;
dataGridView1.GridColor = SystemColors.ActiveBorder;
dataGridView1.RowHeadersVisible = false;
dataGridView1.Columns[0].Name = "Release Date";
dataGridView1.Columns[1].Name = "Track";
dataGridView1.Columns[1].DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns[2].Name = "Title";
dataGridView1.Columns[3].Name = "Artist";
dataGridView1.Columns[4].Name = "Album";
// Make the font italic for row four.
dataGridView1.Columns[4].DefaultCellStyle.Font = new Font(DataGridView.DefaultFont, FontStyle.Italic);
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.MultiSelect = false;
dataGridView1.BackgroundColor = Color.Honeydew;
// dataGridView1.Dock = DockStyle.Fill;
// dataGridView1.CellFormatting += new DataGridViewCellFormattingEventHandler(dataGridView1_CellFormatting);
// dataGridView1.CellParsing += new DataGridViewCellParsingEventHandler(dataGridView1_CellParsing);
this.addNewRowButton.Click += new EventHandler(addNewRowButton_Click);
this.deleteRowButton.Click += new EventHandler(deleteRowButton_Click);
this.ledgerStyleButton.Click += new EventHandler(ledgerStyleButton_Click);
//dataGridView1.CellValidating += new DataGridViewCellValidatingEventHandler(dataGridView1_CellValidating);
}
private void PopulateDataGridView()
{
// Create the string array for each row of data.
string[] row0 = { "11/22/1968", "29", "Revolution 9", "Beatles", "The Beatles [White Album]" };
string[] row1 = { "4/4/1960", "6", "Fools Rush In", "Frank Sinatra", "Nice 'N' Easy" };
string[] row2 = { "11/11/1971", "1", "One of These Days", "Pink Floyd", "Meddle" };
string[] row3 = { "4/4/1988", "7", "Where Is My Mind?", "Pixies", "Surfer Rosa" };
string[] row4 = { "5/1981", "9", "Can't Find My Mind", "Cramps", "Psychedelic Jungle" };
string[] row5 = { "6/10/2003", "13", "Scatterbrain. (As Dead As Leaves.)", "Radiohead", "Hail to the Thief" };
string[] row6 = { "6/30/1992", "3", "Dress", "P J Harvey", "Dry" };
string[] row7 = { "6/30/2006", "5", "Expert Rules", "S J Ryan", "Cambridge" };
// Add a row for each string array.
{
DataGridViewRowCollection rows = this.dataGridView1.Rows;
rows.Add(row0);
rows.Add(row1);
rows.Add(row2);
rows.Add(row3);
rows.Add(row4);
rows.Add(row5);
rows.Add(row6);
rows.Add(row7);
}
// Change the order the columns are displayed.
{
DataGridViewColumnCollection columns = this.dataGridView1.Columns;
columns[0].DisplayIndex = 3;
columns[1].DisplayIndex = 4;
columns[2].DisplayIndex = 0;
columns[3].DisplayIndex = 1;
columns[4].DisplayIndex = 2;
}
}
public Form1()
{
InitializeComponent();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void ledgerStyleButton_Click(object sender, System.EventArgs e)
{
// Create a new cell style.
DataGridViewCellStyle style = new DataGridViewCellStyle();
{
style.BackColor = Color.Beige;
style.ForeColor = Color.Brown;
style.Font = new Font("Verdana", 8);
}
// Apply the style as the default cell style.
dataGridView1.AlternatingRowsDefaultCellStyle = style;
ledgerStyleButton.Enabled = false;
}
private void addNewRowButton_Click(object sender, EventArgs e)
{
this.PopulateDataGridView();
}
private void deleteRowButton_Click(object sender, EventArgs e)
{
MessageBox.Show("click");
int index = this.dataGridView1.Rows.Count - 1;
bool r;
MessageBox.Show(index.ToString());
for (int i = index; i > 0; i--)
{
this.dataGridView1.Rows.RemoveAt(i);
MessageBox.Show(i.ToString());
// index = this.dataGridView1ows.Count;
}
}
private void ledgerStyleButton_Click_1(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
this.SetUpDataGridView();
this.PopulateDataGridView();
}
}
}
|
|
|
|
|
I have created Setup MSI installer with VS2005 for my app.
With standard executable files and dll-s I have added some documentation files(txt, pdf) to setup.
After succesful install I have deleted some of original documentation files.
But now when I start my app Installer will automaticati activate and restore deleted files from original setup MSI.
If I delete the orginal Setup MSI than process complains it can not find it.
How do I stop setup from bringing back original files?
p.s. adding new doc files or modifing existing ones is allowed (setup will not intervein)
thx
|
|
|
|
|
Hi,
I have a strange problem. Hopefully someone can help me here.
I have a Form (lets call it FormA) where I execute the following code:
FormB f = new FormB();
f.ShowInTaskbar = false;
f.Owner = this;
f.Show();
Now I have a form (the standard Sizable one) which always hangs over FormA. I can resize, minimize and maximize it normally. But when FormB is maximized and then minimize and restore FormA then Form B isn't maximized anymore. It also gets restored to a normal size which I don't want to happen. Any ideas?
|
|
|
|
|
Likely you may actually be creating a new copy of FormB rather then restoring the original copy. You could verify this by removing or commenting out the f.ShowInTaskbar entry.
Later
|
|
|
|
|
Let me clarify this. I'm not restoring anything...
The situation is that FormA is maximized on on monitor. Then FormB is created and maximized on the other monitor (by the user). If the user clicks on the minimize button of FormA than both forms are minimized. So far so good. If the user reactivates FormA then FormA gets restored to full size but not FormB.
|
|
|
|
|
Surely you can't reference yourself in f.Owner. Form.Owner sets a reference to another Form which owns it. Top-level forms can't have an owner, which is what I'm assume you are doing by referencing yourself.
I'm could be wrong though!
Graham.
-- modified at 19:31 Tuesday 25th April, 2006
On further research, when a parent form is minimized or maximized is also minimizes or maximizes it's owned forms. This would account for your code hanging as it's getting into an infinite loop due to f.Owner.
|
|
|
|
|
Have a closer look at my code. It resides in FormA (which is this ) and sets itself to a brand new instance of FormB. So no self referencing and also no hanging or infinite loop.
|
|
|
|
|
Opps...
Misread your code!
|
|
|
|
|
|
Are you asking how do you connection to an SQL Server without using that control?
string myConnectionString = "Initial Catalog=databaseName;Data Source=sqlServerName or localhost;";
SqlConnection myConnection = new SqlConnection(myConnectionString);
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 12:34 Wednesday 26th April, 2006
|
|
|
|
|
I'm trying to find a way of getting a list of files which are locked by other processes. I'm sure this can be done in .net without resorting to win32 api calls, but without spending days drilling into MSDN I'm hoping that someone already has an answer for vb.net 2.0 if poss.
http://www.ViSYNERGY.com
End of Line.
|
|
|
|
|
Arkett wrote: I'm sure this can be done in .net without resorting to win32 api calls
No, it can't. There is no support built into the .NET BCL to do anything close to this. You MUST start calling into Win32. I take it you've already found an example and didn't like what you saw?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Please don't reply to this thread telling me what I can't do if you're not going to follow it up by telling me what I can do. It's just a waste of your time and mine.
http://www.ViSYNERGY.com
End of Line.
|
|
|
|