|
Environment.GetLogicalDrives()
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
I have just read Jeffrey Richter's article: "Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework",I have a question about finalize.It says "A finalizable object can refer to other(finalizable and nonfinalizable) objects, prolonging their lifetime unnecessarily.".It also says "The runtime doesn't make any guarantees as to the order in which Finalize methods are called. For example, let's say there is an object that contains a pointer to an inner object. The garbage collector has detected that both objects are garbage.Furthermore, say that the inner object's Finalize method gets called first." I am confused the outer object's finalize method doesn't get called,so the inner object is reference by the outer object.Why does the garbage collector think that the inner ojbect is garbage.I notice the former uses refer and the latter used a pointer.Is this reason,otherwise why?
|
|
|
|
|
It's a two-pass process, first establishing what is garbage, then secondly collecting it.
When garbage collection kicks in, the CLR determines what is and what is not garbage by following object references from initial 'live' roots to one object to the next. All objects are considered garbage unless they are marked otherwise by this process. If the inner object is only referenced by the outer object, and the outer object never gets marked as 'live', then both objects are considered garbage.
The GC will then go on to collect them and you can't make any assumptions about in which order (I believe its in the order they are in memory).
Are you assuming that objects are deleted in Finalize in a similar manner to the general practice in a C++ destructor? This is not the case. My understanding is that Finalize is provided more to free up CLR resources than referenced objects.
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote: Are you assuming that objects are deleted in Finalize in a similar manner to the general practice in a C++ destructor? This is not the case. My understanding is that Finalize is provided more to free up CLR resources than referenced objects.
You've got this part backwards. Finalize() is to cleanup non managed (and generally scarce) resources (ie handles, files) that the GC can't. If you've implemented a finalizer you should also should implement IDisposable, and dispose the object as soon as you're done (put the cleanup code in both) to free the nonmanaged resources immediately rather than waiting for the GC. The reason for doing the cleanup in both places is cya in case you or annother developer forget to dispose the object.
|
|
|
|
|
Hey
I'm looking for a list with all the "\" signals for strings.
I do know that \n is start another line, and \t is for tabbing,
but what \r is doing, and what other signs exist.
thanks!
|
|
|
|
|
Copied from MSDN Library:
Escaped character Description
\a
Matches a bell (alarm) \u0007.
\b
Matches a backspace \u0008
\t
Matches a tab \u0009.
\r
Matches a carriage return \u000D.
\v
Matches a vertical tab \u000B.
\f
Matches a form feed \u000C.
\n
Matches a new line \u000A.
\e
Matches an escape \u001B.
\040
Matches an ASCII character as octal (up to three digits); numbers with no leading zero are backreferences if they have only one digit or if they correspond to a capturing group number. (For more information, see Backreferences.) For example, the character \040 represents a space.
\x20
Matches an ASCII character using hexadecimal representation (exactly two digits).
\cC
Matches an ASCII control character; for example, \cC is control-C.
\u0020
Matches a Unicode character using hexadecimal representation (exactly four digits).
modified 12-Sep-18 21:01pm.
|
|
|
|
|
This seems to be copied from the documentation about regular expressions, not the C# documentation.
The escapes are quite similar, though.
|
|
|
|
|
You're right, that's the first one I found. But as you said they're pretty much the same.
I just removed some of the regex-specific stuff from my original posting to not to confuse him.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Hi:
What is involved in setting up a serial port (RS232) under .NET and specifically, using C#?
Does C# offer anything that supports this or do I have to drag some Win32 DLL into it?
There is an example on this site but it uses a SerialPort class that is supposed to be part of the "System.IO" name space. I'm using Visual Studio 2003. I can't find that in any of my documentation.
I specifically need to set up asynchronous communication so I need a background thread to service incoming characters.
Thanks in advance to anybody who responds.
Cheers,
Mark
|
|
|
|
|
This link might shed some light on the matter -
http://msdn.microsoft.com/msdnmag/issues/02/10/NETSerialComm/default.aspx
|
|
|
|
|
Thanks Gavin. This looks exactly like what I am looking for.
Cheers,
Mark
|
|
|
|
|
in crypting what does need cryptic.IV.
Have to be the same of the crypting key?
|
|
|
|
|
The IV is needed for all ciphermodes but ECB. The can be anything and/or can be generated by GenerateIV(). The IV needs to be shared with the receiver of the encrypted data as well the decryption key.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
There are several great articles on these things on Code Project. Do a search for cryptography and you should find them. A few even have nice little assemblies you can use to encrypt your data very easily if you don't mind using open-source encryption
-------------------------------------
Do not do what has already been done.
|
|
|
|
|
Hi folks,
I am trying to change the display name of Windows Service using DisplayName property of Service Controller class. But the change is not reflected, don't know why? Is it a bug or am I doing something wrong.
Reply soon.
Thanks in advance
Rajeev
|
|
|
|
|
rajeevr@interrait.com wrote: I am trying to change the display name of Windows Service using DisplayName property of Service Controller class. But the change is not reflected, don't know why? Is it a bug or am I doing something wrong.
From what I can see it is not possible to do what you want from the ServiceController class.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
Hi leppie,
Thanks for your prompt reply. Why its not possible to change display name using ServiceController class and do you know any other approach to do this.
Regards
Rajeev
|
|
|
|
|
rajeevr@interrait.com wrote: Why its not possible to change display name using ServiceController class
I dont know why.
rajeevr@interrait.com wrote: do you know any other approach to do this.
Perhaps the registry, but you will need admin rights to do so.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
Hi tried with registry. It changes the display name in Property Window of Service only but not in cosole menu. And also in the object of Service Controller when reading property of the service after making change, DisplayName change doesn't reflect. But I were successgul in changing description.
I am adding my code here
private void button2_Click(object sender, System.EventArgs e)
{
ServiceController obj = new ServiceController("Telephony");
Microsoft.Win32.RegistryKey objReg;
string str = obj.DisplayName;
try
{
ServiceControllerEx objSercEx =new ServiceControllerEx("Telephony");
string strDes = objSercEx.Description;
objReg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Services\tapisrv",true);
objReg.SetValue("DisplayName","Telephony5678");
objReg.SetValue("Description", "DEscription");
objReg.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
|
|
|
|
|
Create the ServiceController instance AFTER you change the value.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
Hi
I would like to know how can I detect the sql server on a machine?
Thanks
|
|
|
|
|
_Hacker wrote: I would like to know how can I detect the sql server on a machine?
- Look in registry
- Look in file system
- Try establish connection
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
Hi,
Can anyone please tell me how to get the scroll position of a control. I have a tree view control and I would like to get the scroll position of the control when I scroll it using a scrollbar.
Thanks!
|
|
|
|
|
Hi ,
I am working in c# with crystal report XI.
I read an example about dynamic image location ..
1) In that we have a xml xchema file with two fields n amed country--datatype is string, img--datatype is base64Binary. using this as the datasource,i have designed the crytal report. And a parameter is set asking for the name.
2) I have designed teh form by adding a crystal report viewer and
now the coding part is as follows
// Prcocedure: AddImageRow
// reads an image file and adds this image to a dataset table
//
// [in] tbl DataTable
// country name of a country
// filename name of an image file
//
void AddImageRow(DataTable tbl, string name, string filename)
{
FileStream fs = new FileStream(filename, FileMode.Open);
// create a file stream
BinaryReader br = new BinaryReader(fs);
// create binary reader
DataRow row;
// create a new datarow
row = tbl.NewRow();
// set country field and image field
row[0] = name;
row[1] = br.ReadBytes((int)br.BaseStream.Length);
// add this row to the table
tbl.Rows.Add(row);
// clean up
br = null;
fs = null;
}
// Function: CreateData
// Creates a dataset that has 1 table with two fields: Country (string), and img (blob/byte[])
// Adds four records to this table
//
DataSet CreateData()
{
DataSet data = new DataSet();
// add a table 'Images' to the dataset
data.Tables.Add("Images");
// add two fields
data.Tables[0].Columns.Add("Country", System.Type.GetType("System.String"));
data.Tables[0].Columns.Add("img", System.Type.GetType("System.Byte[]"));
// add rows
AddImageRow(data.Tables[0], "argentina", Directory.GetCurrentDirectory() + "\\argentina.jpg");
AddImageRow(data.Tables[0], "canada", Directory.GetCurrentDirectory() + "\\canada.jpg");
return (data);
}
// Procedure: CreateReport
// Creates a report and passes the dataset
//
void CreateReport()
{
// create a report
CrystalReport1 cr = new CrystalReport1();
cr.SetDataSource(CreateData());
// pass a reportdocument to the viewer
crystalReportViewer1.ReportSource = cr;
}
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
CreateReport();
}
This is the coding part..ie,when the program is run the image which is existing in the directory (say argentina.jpg and canada.jpg). it will ask for country name...so if we type canada..then canada.jpg wil be displyed in the report.
This is wht the program does..
No I have to modify such that .. I have to add a buttn on the form say load..so when the load button is clicked, we should be able to load any image from the disk(any location) and that image should be displayed in the crystal report..How to do this..
please if any one change the coding part above and sent it .
|
|
|
|
|