|
hiii,
how can i get processes handles which work on file.
i mean, if a process opend a file and works with it; how can i know it's handle from the opend file.
thanx for your time.
marcoryos
|
|
|
|
|
Greetings,
Question: When one news an object (class) eg:
MyClass myClass = new MyClass();
Are only the fields (class level variables that aren't in any method) getting newly allocated memory to store them, or are all the methods (functions) getting memory allocated for them as well?
I understand that variables in the scope of methods do get allocated when the method is called then removed when the method returns but what about the code of the method... where does it live? And does it get replicated on each new?
Here is another way to ask it... If I have 1000 newed instances of MyClass in an array and inside of MyClass I have 25 methods that have a lot of code in them. Do I now have 1000 copies of those method's code in memory too?
I think what would help is if I knew where the code itself lives in memory... and, whether or not there is only one copy of it in memory even if you create multiple pointers to it with new.
Please set me straight... any help will be greatly appreciated.
EB
|
|
|
|
|
You need to differentiate between code and data. Code is loaded only once (per appdomain, if the assembly is not domain neutral) when the assembly containing the type is loaded into memory. That includes code for methods. Along with code, static data is also loaded only once. It makes sense because code is not going to change every time you create an object.
When you instantiate an object (assuming it is a reference type), memory is allocated for all member variables. If the member is a value type, then memory allocated is equal to the size of the type. If the member is a reference type, unless you've instantiated it in the constructor, memory is allocated only to hold a reference, ie, 4 bytes in 32 bit machines.
What you said about variables in scope of methods holds true only for value types (structs, enums..). For reference types, memory remains allocated till all references to it are lost.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Well, you've done it again Senthil. Many thanks!
I'm just not clear on what you mean by this:
For reference types, memory remains allocated till all references to it are lost.
What is ment by "all references to it are lost"? Do you mean till all references to it fall out of scope? Or does one have to explicitly set it to null?
EB
|
|
|
|
|
Hello everyone,
Does anyone know how to open and read the fields of an access database using csharp?If any one does know,please send me the couple of lines that will allow me to do so
Thank you
Gijoe Bijoe
|
|
|
|
|
Search for ADO.NET on MSDN or codeproject. You can talk to databases using the System.Data namespace. Create a connection, command, then execute it. Pretty straightforward.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: He has a funny face. And he's my son.
Judah Himango
|
|
|
|
|
GIven Below is sample code to access 'Employee' table from Access Database named Mydb1.mdb
OleDbDataAdapter da = new OleDbDataAdapter(@"Select * from employee",
@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\mydb1.mdb;User Id=admin ; Password=;");
DataSet ds = new DataSet();
da.Fill(ds);
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
Hope this helps
Ravindra Sadaphule
MCSD.NET
|
|
|
|
|
I have a very unusual problem:
I am using CSC.EXE to compile a small program with a background image on the main form.
CSC seems to compile the program successfully, but when I go to run the program, it gives me a Thread exception error. When I debug the application, this is what I get:
=================================================
An unhandled exception of type 'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll
Additional information: Could not find any resources appropriate for the specified culture (or the neutral culture) in the given assembly. Make sure "Form1.resources" was correctly embedded or linked into assembly "Pax".
baseName: Form1 locationInfo: Pax.Form1 resource file name: Form1.resources assembly: Pax, Version=1.0.1899.20704, Culture=neutral, PublicKeyToken=null
=================================================
Now.. If I remove the background image from the form, the program compiles, and runs fine.
Using:
VS.Net 2003 Enterprise
Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322
|
|
|
|
|
Hi Ray,
I tried to simulate the program and it works fine.
Can you please the send the code?
Cheers
Ravindra Sadaphule
MCSD.NET
|
|
|
|
|
Fixed:
What I had forgotten (Actually what I had "learned", since I am a C# newbie) is that I need to include the .Resource file in the RSP file used to build the executable:
/res:C:\Compiler\Source\Pax\Pax.Form1.resources
Once I added this line to the RSP file, it ran flawlessly.
Thanks for all of your consideration!
Ray
|
|
|
|
|
Hi,
Is there any way I can set the background of a listview to 'semi-transparent'? I have used
label1.BackColor = Color.FromArgb(40,40,0,0);
for the labels and want to create a similar effect for the listview.
Thanks very much
|
|
|
|
|
I was wondering what the majority of you all are using to store your apps configurations in. I come from a Linux background and would like to make use of flat text files with regards to holding my apps configurations.
Now I know that .NET makes good use of XML so can I assume that this is the direction to head in?
What do you all use?
|
|
|
|
|
2 different things to be discussed here: application configuration and user settings. app config file is somewhere where you'd store readonly database connection strings, defaults, and so on. User settings is somewhere where settings changed by the user (form size, preferences, etc) is stored in a read-write fashion.
App config is built in -- just create a file named <myexecutablename>.exe.config and place it in the same directory as your executable. The CLR will load it up for you automatically.
Msdn has some great articles on this, I suggest you search there.
|
|
|
|
|
I wonder when we use it 'n how to use it right. I've heard that thread can not be used in any cases 'n it really confuse to use it too.
I'm doing a project about virtual stock exchange (an web application), and i think that thread maybe help my web application work faster. Is it right? Can someone give me some advise about thread. I haven't learn about it yet, all i know is there is a class named Thread in VS
Thanks!
|
|
|
|
|
Blue_Skye wrote:
i think that thread maybe help my web application work faster. Is it right?
No, using threads on a single processor system will actually perform slower than using a single thread. That said, using threads to do heavy work, freeing up your GUI thread to let the user continue working gives the appearance of improved performance. If you want more information about threads, there are plenty of articles on codeproject and msdn.microsoft.com regarding threading, synchronization, locks, semaphores and so on.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: He has a funny face. And he's my son.
Judah Himango
|
|
|
|
|
Hi all,
I am new to C# GDI+ things. I try to add up the color occurence of the given jpg to array colorSumrySrc after comparing the pixel argb values of the incoming picture with the values in sysColors. The result would be there is no pixel color matched with sysColors and thus colorSumrySrc are all in zeros. The case is that the argb values for system Colors may not be exactly same as the color in input picture. So, I want to change the approach to just storing red, green, blue -> 3 major color categories in sysColors. But my concern here would be that the argb values for a color category is discreted, e.g. blue includes skyBlue, deepBlue... How can i specify the range of the color here for comparison? E.g. if a pixel color have argb value - 1111111, then if it falls to blue category that have range from -100000 to -200000, then my code will considered that pixel to be blue. Any one can help??
public string[] sysColors = new string[] {Color.AliceBlue.ToArgb().ToString()
...
,Color.AntiqueWhite.ToArgb().ToString()
} // array holds system color argb values for comparison
colorSumrySrc = new int[sysColors.Length]; // array holds corresponding color occurence of sysColor if given picture have pixel the same as sysColor, initialized as 0 for all entries
string sImgPath = @"c:\temp";
string sImgName = "a.jpg"; // given picture for pixel comparison
Bitmap bmp = null;
string rslt = null;
int bmpHeight = 0;
int bmpWidth = 0;
int totalPixel = 0;
string colorDesc = null;
try
{
bmp = new Bitmap(sImgPath + sImgName);
if (!bmp.Size.IsEmpty)
{
bmpHeight = bmp.Size.Height;
bmpWidth = bmp.Size.Width;
totalPixel = bmpHeight * bmpWidth;
}
for (int y=0; y<bmpheight; y++)="" {
="" for="" (int="" x="0;" x<bmpwidth;="" x++)="" color="" y);
="" colordesc="color.ToArgb().ToString();
" i="0;" i<syscolors.length;="" i++)="" if="" (colordesc.equals(syscolors[i]))="" this.colorsumrysrc[i]++;=""
="" break;
="" }="" match
="" check="" it="" is="" of="" its="" type
="" x
="" y
="" catch="" (exception="" e="" )="" rslt="e.Message" +="" "="">>>" + e.StackTrace;
}
Thanks much!!!
Rene Xavier
|
|
|
|
|
If you only want to catgorize into red, green and blue I have a proposal (although I dont know how good it works):
In a reddish color the R value should be higher than the others, in a blueish a blue one should...
This leads to a rather simple if statement:
private void WhatIsIt(Color color)
{
if (color.R > color.G)
{
if (color.B > color.R)
{
Console.WriteLine("Its blue.");
}
else
{
Console.WriteLine("Its red.");
}
}
else
{
if (color.G > color.B)
{
Console.WriteLine("Its green.");
}
else
{
Console.WriteLine("Its blue.");
}
}
}
|
|
|
|
|
Hihi,
Thanks you very much for the reply, but how if I want to classify the colors into Rainbow colors: Red, Orange, Yellow, Green, Olive, Blue, and Violet?
Thanks a ton,
Rene Xavier
|
|
|
|
|
Ok. Define a list with the colors you want.
Whenever you have to categorize a color do the following:
Sum up the differences of the R, G and B values for the color and each color in your list and sum them up.
When done take the color of your list where the difference is the smallest.
Dont know if it works, but you could try
|
|
|
|
|
Thanks much for your advice
I use another approach for specifying the argb ranges for each type of color finally.
Rene Xavier
|
|
|
|
|
Umm, i just start to write an n-tier application. I really need an standard n-tier application to check 'n base on it to develop my project. That application doesn't need to be too big, complicated or even a complete project. i just need an application that show clearly about n-tier (urr, maybe one control class for two design from ...).
I really need it. Can anybody help me ?
Thanks!
|
|
|
|
|
Hi,
he following link on MSDN gives very good examples of N-Tier Application with code samples.
It includes Fitch and Mather 7.0 and Duwamish 7.0
MSDN Enterprise Samples
Cheers
Ravindra Sadaphule
MCSD.NET
|
|
|
|
|
Hi
I want write a program that compute the time of connecting to internet .(like the dial_up connetcion notify icon in windows ) i want the connection property too like connection speed .
can anyone halp me ?
Regards' Amir jalaly
|
|
|
|
|
Use a simple API function InternetGetConnectedState, to return a boolean variable.
using System ;
using System.Runtime ;
using System.Runtime.InteropServices ;
public class InternetCS
{
//Creating the extern function...
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int Description, int ReservedValue ) ;
//Creating a function that uses the API function...
public static bool IsConnectedToInternet( )
{
int Desc ;
return InternetGetConnectedState( out Desc, 0 ) ;
}
}
blank
|
|
|
|
|
We are in a process to create a deployment process (deploy activex controls, com+ dlls, .net dlls). Because we have ~30 servers to install our code to. We are thinking of couple of approaches. I have tested an application that will register all these components on all the servers e.g. use comadmin to register the dlls in COM+ services (remotely), same with the registry files. But how to register activex controls and .net dll that go to COM+ services? Has anybody seen this issue?
Thanks,
sacred_warrior
|
|
|
|