|
I have a class which descends from Control and features a Bitmap property. It is my impression that it is my control's responsibility to call Dispose() on the example f_BitmapField in the commented out call of the following snippet. If I deploy this call (remove the comment instructions), there is no resource issue at run time destruction, but if this control is placed on a parent control, then when I delete the parent control at design time (without first deleting my child control) I get an ambiguous error stating only that a parameter is invalid. A later dialog is sometimes raised which refers to the property, not the field — suggesting that an invalid reference to the property exists. No Finalize method is deployed, and no further dispose processes refer to the field or resources which can be associated with it at disposal.
Can anybody explain this behavior? Is it not theoretically the control's responsibility to call Dispose() on the bitmap field as in the commented lines here?
I am beginning to wonder if the IDE isn't mishandling the proper implementation — forcing me to write the wrong code (omit dispose) so that I get acceptable design time behavior. Run time behavior doesn't seem to be affected. I don't feel comfortable about the required implementation. Maybe someone knows there is a different, explicit pattern to follow here?
protected override void Dispose( bool disposing )
{
if ( disposing )
{
}
base.Dispose( disposing );
}
|
|
|
|
|
I'm new to learning C# and I don't know what all the error messages mean. Yet. Can somebody give me a clue as to what the following means. And maybe what I need to do to fix it. Thanks in advance for any information.
"An object reference is required for the nonstatic field, method, or property"
|
|
|
|
|
This message means that u r tying to initialize any method or property of a class
with out creating its object u r trying to access it directly through that class
but that class is non static.It is only possible for static class to access its
public methods and property directly with out creating any object.
rahul
|
|
|
|
|
Hey,
I have to compresse 70MB of data in a C# application and I have to mail them automaticaly back to our server. So I have to compresse them in 7 files of 10MB. Is there any way I can do this in c#? I looked everywhere but it's always 1 .zip file you can make
I thank you for your time!
olivier
|
|
|
|
|
|
Hi, .net lets you make as many zips as you want:
http://msdn.microsoft.com/msdnmag/issues/03/06/ZipCompression/default.aspx
|
|
|
|
|
HI,
In C# how do you compare 2 struct's?
Thanks,
Liam
|
|
|
|
|
firstStruct.Equals(secondStruct)
|
|
|
|
|
I guess that depends on how you're going to use them and if the structs are the same type. The IComparer interface is what you'd want to use if you didn't have control of the structs and you were trying to sort them in a list (for example). You could also implement the IComparable interface on the struct if you have control over them.
|
|
|
|
|
You should not use Equals if you want to compare for true equality, because Equals only checks if the compared values refer to the same instance. To determine true equality of value you have to compare the fields. See Richter for further information. The base implementation actually compares for identity, not equality.
|
|
|
|
|
Hi,
I have a table displayed in a datagrid.
If I select a cell, that row has to be populated in the text boxes that I have.
I am unable to refer to the individual fields in the row, of the cell that I clicked.
For EG: If i select any cell in row 10 all the columns in row 10 has to be populated in the text boxes that I have.
Can you please tell me how to refer to the cells in the row that I have selected.
An example code will be very very helpful.
Thanks,Arun
|
|
|
|
|
Try something like this:
DataGridCell dgCell = dataGrid.CurrentCell;
textBox.Text = dataGrid[dgCell.RowNumber, dgCell.ColumnNumber].ToString();
|
|
|
|
|
Hi,
I am trying to find out if there is some function to validate whether a user entered an integer. All suggestions welcome. Thanks.
|
|
|
|
|
Entered an integer into what? A web for then I would suggest javascript validation isNumber (or is it isNumeric I really don't remember) or even the regular expressions.
If it is server side just TryParse.Int32. Also, various styles of input text boxes exist which can automagically restrict input.
File Not Found
|
|
|
|
|
Here are a couple of ideas:
1. You could mask the input and only allow digits:
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
if (char.IsDigit(e.KeyChar) == false)
{
MessageBox.Show("Invalid Input...");
}
...
}
Of course you would also have to handle the user entering text without pressing a key (a paste operation for example).
2. You can attempt to convert the value when the user is finished:
protected override void OnLostFocus(EventArgs e)
{
base.OnLostFocus(e);
int number;
bool isNumber = int32.TryParse(textbox1.Text, out number);
if(isNumber == true)
// Do something
else
MessageBox.Show("Invalid Input...");
...
}
}
Ian
|
|
|
|
|
When testing one of my programs i got a Loader Lock Message from VIsual Studio 2005:
LoaderLock was detected
Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
I did some testing and it occurs whenever I press a key on a program i am testing, even if there is only a form and nothing else. How should I fix this problem? I need this fixed to test my program. Thanks.
|
|
|
|
|
The loader lock detection isn't an actual exception; it's a Visual Studio "debugging assistant" that helps you track down bad practices, leaks, and other workin's of the devil.
First of all, make sure this is valid: are you doing any unmanaged interop during initialization? If so, this error may be valid and you should fix it.
If this isn't a valid error, fortunately for this scenario, you can disable this debugging assistant: Debug->Exceptions->Managed Debugging Assistants->Loader Lock. Uncheck the "thrown" box, and you won't see this error any more.
|
|
|
|
|
Thanks.
I'm definately not doing any unmanaged interop, I'm using the code the designer made for me, and it has an error with its own code. So I will turn it off.
|
|
|
|
|
HI
I wanted an anti-virus software to which i can provide files and get resuts programatically.
Any AV software that give SDKs or some sort of API's
Thank you!
|
|
|
|
|
Is open source.
File Not Found
|
|
|
|
|
A lot of them provide this, but you usually have to purchase it. I'm not sure if there are any open source av scanners, and, if there are, what their effectiveness is.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I have a text file that I want to reference in my code via a relative file path versus an absolute one. How would I go about doing this?
For instance: A text file named "address01.txt".
Also, is this the best way to reference a text file during runtime (or installed on a machine) or should I make it an embedded reference?
Thank you.
|
|
|
|
|
Relative file paths are relative to the exe. Unfortunately, you should not have write access to that directory. Instead you should copy a location on the first run to either System.Windows.Forms.Application.CommonAppDataPath or System.Windows.Forms.Application.LocalUserAppDataPath.
Put it in as an embedded resource and then copy to the above mentioned paths if you need to write to it.
File Not Found
|
|
|
|
|
Hello,
I am extremely new to Visual Studio 2005 and I'm trying to utilize report viewer to display a report of data accessed at runtime. I'm finding it difficult in getting the data to display in the report viewer.
Does anyone have any advice or suggestions? The article at http://www.codeproject.com/useritems/reportdisplay.asp?df=100&forumid=285487&fr=26 I have tried and unfortunately I cannot get my report to display anything.
I'm trying to run a stored procedure server side based on parameters entered in the program which would then return a dataset to display in a report but I seem to have trouble being able to do this.
Is there a better tutorial on the net that can assist me?
Thanks in advance.
|
|
|
|
|
Hi,
I am creating a Shell Extension to appear in "My Computer" which is all working OK apart from when I click on an item (Handled by the OS, not me own IShellView) I get the following message:
"This page has an unspecified potential security flaw. Would you like to continue?"
Does anyone know what causes this error?
Thanks,
Dan
|
|
|
|