|
hi
i need urhent response
Is there any other way to get HTTP Headers in C# by not using HttpWebRequest and Response Calssess i mean through xml or sockets
if yes
please tell me with code or refrence to code
Thanks
in Advacne
TaRiQ
|
|
|
|
|
What's wrong with a WebRequest?
---
b { font-weight: normal; }
|
|
|
|
|
i m preparing a Request using WebRequest but cant find proper response
thats why i want to use another way to get the response
please tell me in deatail
Thanks
Tariq
TaRiQ
|
|
|
|
|
Hi all !
I have built a .dll in VC++. Now I continute develope it in C#. So I reused dll in C#. But when I using Thread that used this dll, I allway meet a problem : Only Thread using dll in a time. How to using dll for all Thread. Pls help me!
Thank alots !
|
|
|
|
|
Hi,
Lots of code around for capturing a window. But they all suffer from one deficiency.
If another window overlaps the one being captured it becomes part of the capture.
Is there a way to capture a window without bringing to the front of the desktop first (i.e. not using BringWindowToTop)?
Thank you, Jesper
|
|
|
|
|
Create a bitmap or metafile DC and send a WM_PRINT message to the window.
This way, you're not capturing the screen image, you're telling the window to draw itself on your bitmap.
The problem with this approach is that not all windows honor the WM_PRINT message. The .NET framework have a few controls that simply don't draw themselves when you send a WM_PRINT.
I see dead pixels
Yes, even I am blogging now!
|
|
|
|
|
string sInsert = "insert into temp11 values ('This is my test data's ')";<br />
SqlConnection sqlcon = new SqlConnection(ConfigurationSettings.AppSettings["DBConnection"]);<br />
sqlcon.Open();<br />
SqlCommand objcmd = new SqlCommand(sInsert,sqlcon);<br />
objcmd.ExecuteNonQuery();
IT failed becuase there is an "'" inside the text.
I tried to used
sInsert = sInsert.Replace("'","''"); but still failed.
|
|
|
|
|
Try
string sInsert = "insert into temp11 values ('This is my test data''s ')";
|
|
|
|
|
You should use parameterized queries to do this.
They are far less prone to SQL injection attacks and don't have problems with special characters inside your query strings, too.
Regards,
mav
|
|
|
|
|
Hi,
I know vertical length,horizontal length and sweep angle. with these inputs i am calculating radius,height and chordlength. But i am not able to fix Rectangle co-ordinates (assuming x=100, y=250).
My calculation is this:
p1 = x- (r+length/2);
p2= y - (r + length/2
p3 = r * 2;
p4= r * 2;
But this is not working
Can any one help me.
Regards,
-- modified at 5:52 Monday 12th September, 2005
|
|
|
|
|
Standard question #1:
What do you mean by "not working"?
---
b { font-weight: normal; }
|
|
|
|
|
my rectangle co-ordinates are wrong. my arc is not coming properly. this is the code.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace FreeHand
{
///
/// Summary description for FillPolygon.
///
public class FillPolygon : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox lengthBox;
private System.Windows.Forms.TextBox angleBox;
private System.Windows.Forms.Button button1;
public Graphics m_GraphicsToDrawOn;
protected Pen m_PenToDrawWith;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox Vertical;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public FillPolygon()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
InitializeGraphics(this);
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
[STAThread]
static void Main()
{
Application.Run(new FillPolygon());
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.lengthBox = new System.Windows.Forms.TextBox();
this.angleBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.Vertical = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// lengthBox
//
this.lengthBox.Location = new System.Drawing.Point(776, 104);
this.lengthBox.Name = "lengthBox";
this.lengthBox.TabIndex = 0;
this.lengthBox.Text = "30";
//
// angleBox
//
this.angleBox.Location = new System.Drawing.Point(776, 136);
this.angleBox.Name = "angleBox";
this.angleBox.TabIndex = 1;
this.angleBox.Text = "270";
//
// label1
//
this.label1.Location = new System.Drawing.Point(648, 104);
this.label1.Name = "label1";
this.label1.TabIndex = 2;
this.label1.Text = "Horizontal";
//
// label2
//
this.label2.Location = new System.Drawing.Point(648, 136);
this.label2.Name = "label2";
this.label2.TabIndex = 3;
this.label2.Text = "Angle";
//
// button1
//
this.button1.Location = new System.Drawing.Point(792, 192);
this.button1.Name = "button1";
this.button1.TabIndex = 4;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(776, 64);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 5;
this.textBox1.Text = "0";
//
// label3
//
this.label3.Location = new System.Drawing.Point(648, 64);
this.label3.Name = "label3";
this.label3.TabIndex = 6;
this.label3.Text = "Rotate At";
//
// Vertical
//
this.Vertical.Location = new System.Drawing.Point(376, 72);
this.Vertical.Name = "Vertical";
this.Vertical.Size = new System.Drawing.Size(152, 20);
this.Vertical.TabIndex = 8;
this.Vertical.Text = "20";
//
// label4
//
this.label4.Location = new System.Drawing.Point(240, 72);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(72, 24);
this.label4.TabIndex = 9;
this.label4.Text = "Vertical";
this.label4.Click += new System.EventHandler(this.label4_Click);
//
// FillPolygon
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(936, 389);
this.Controls.Add(this.label4);
this.Controls.Add(this.Vertical);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.angleBox);
this.Controls.Add(this.lengthBox);
this.Name = "FillPolygon";
this.Text = "FillPolygon";
this.Load += new System.EventHandler(this.FillPolygon_Load);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.FillPolygon_Paint);
this.ResumeLayout(false);
}
#endregion
protected void InitializeGraphics(Form canvas)
{
IntPtr formHdc = canvas.Handle;
m_GraphicsToDrawOn =Graphics.FromHwnd(formHdc);
m_PenToDrawWith = new Pen(Color.Red);
}
int horilength=0 ;
int verticallength=0;
int length = 0;
float angleDeg ;
float angleRad;
int x=100;
int y=150;
int x1=300;
int y1=250;
int r=0;
int h=0;
private double ang = 45.0f;
private void button1_Click(object sender, System.EventArgs e)
{
horilength = int.Parse(lengthBox.Text);
verticallength = int.Parse(Vertical.Text);
length =(int) (Math.Sqrt(Math.Pow(horilength,2)+(Math.Pow(verticallength,2))));
//angleDeg = Math.Max(0.0f, Math.Min(90.0f, float.Parse(angleBox.Text)));
angleDeg = float.Parse(angleBox.Text)/2;
angleRad = angleDeg * (float)(Math.PI / 180);
ang= (float)Convert.ToDouble(textBox1.Text);
//ang = Math.Tanh((verticallength/horilength)*3.14/180);
//Graphics g = this.CreateGraphics();
//Pen pen = new Pen(Color.Red, 1);
// get circle radius
r = (int) (((double) length / 2) / Math.Sin(angleRad));
//
h = (int) (Math.Cos(angleRad) * r);
// draw arc
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
int p1=0;
int p2=0;
int p3=0;
int p4=0;
float st=0;
float sp=0;
this.textBox1.Text = Convert.ToString(ang);
Point rotatePoint;
if(r!= 0)
{
// p1 = x - (r + length /2);//(r + length/2);//+int.Parse(ang.ToString());
// p2= y - (r + length /2);//(r + length/2);
p1 = x - (r - length /2);
p2= y - ( r - h);
p3 = r * 2;
p4= r * 2;//(int)Math.Sqrt(Math.Pow(length,2)-Math.Pow( r,2)) ;
st= -45 + angleDeg;
sp= -2 * angleDeg;
//e.Graphics.DrawLine(m_PenToDrawWith, x, y, x-length, y-length);
e.Graphics.DrawLine(Pens.Blue,50,y,x,y);
e.Graphics.DrawLine(m_PenToDrawWith, x, y, x+horilength, y);
e.Graphics.DrawLine(m_PenToDrawWith, x+horilength, y, x+horilength, y+verticallength);
e.Graphics.DrawLine(m_PenToDrawWith, x, y, x+horilength, y+verticallength);
//e.Graphics.DrawLine(Pens.Green,50,250,100,250);
//e.Graphics.DrawLine(Pens.Green,50,250,100,325);
rotatePoint = new Point(x,y);
//e.Graphics.DrawRectangle(Pens.Black,p1,p2,p3,p4);
Matrix myMatrix = new Matrix();
myMatrix.RotateAt((float)ang, rotatePoint, MatrixOrder.Append);
// myMatrix.Rotate(ang, MatrixOrder.Append);
e.Graphics.Transform = myMatrix;
// e.Graphics.DrawRectangle(Pens.Black,p1,p2,p3,p4);
Rectangle rect= new Rectangle(p1,p2,p3,p4);
//e.Graphics.DrawRectangle(Pens.Red,rect);
//upper side
e.Graphics.DrawArc(Pens.BlueViolet ,rect ,st ,sp);
//
// if(angleDeg *2 <180)
// {
//
// angleDeg=180-(angleDeg *2 );
// rect= new Rectangle(p1,p2-Convert.ToInt32(angleDeg),p3,p4);
//
// }
//e.Graphics.DrawArc(Pens.Black ,rect ,st ,sp);
//Second Arc
//
// e.Graphics.DrawLine(Pens.Green,x1-50,y1,x1,y1);
// p1 = x1 - (r - length / 2);//+int.Parse(ang.ToString());
// p2= y1 - (r - h) ;
//
// if(angleDeg *2 < 180)
// {
// p2=p2-(180- Convert.ToInt32(angleDeg)*2);
// rect= new Rectangle(p1,p2,p3,p4);
// }
// e.Graphics.DrawRectangle(Pens.Red,rect);
// e.Graphics.DrawArc(Pens.Black ,rect ,-st ,-sp);
// Create pen.
//Pen blackPen= new Pen(Color.Black, 2);
// Create coordinates of rectangle to bound ellipse.
// float y1 = 0.0F;
//float width = r*2;
//float height = r*2;
// Create start and sweep angles on ellipse.
// Draw arc to screen.
//e.Graphics.DrawArc(blackPen, x1, y1, width, height, startAngle, sweepAngle);
}
//m_PenToDrawWith.Dispose();
//m_GraphicsToDrawOn.Dispose();
}
private void FillPolygon_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
}
private void FillPolygon_Load(object sender, System.EventArgs e)
{
}
private void label4_Click(object sender, System.EventArgs e)
{
}
}
}
|
|
|
|
|
Hello everybody,
I've got a form with multiple usercontrols which contain some textboxes. Is it
possible to adjust the tabindexes so it can hop from the textbox in the one control
to another and back. I tried something like this.
this.usercontrol1.textbox1.tabindex = 1
this.usercontrol2.textbox1.tabindex = 2
this.usercontrol1.textbox2.tabindex = 3
but this doesn't work. Can anyone tell me whether it is possible to do something like
this and how to achieve that.
With kind regards
Joris
|
|
|
|
|
This code works if u write it in the gotfocus event of the form. Does not work when written in the load event
|
|
|
|
|
I have a project by SampleApp with 4 usercontrol.cs files with it.
3 of them with same namespace Sample1.Other usercontrol by "SampleApp" with namespace Sample2.The 3 user controls are used in the SampleApp.I have built the project.
I have a TestApp of outputtype Windowsapplication where i wanted to place the SampleApp.dll by adding it in to the tool box.when i place the .dll on to the form,i am getting an exception as
Sample2.SampleApp error 'Specified cast is not valid'
Can anyone please let me know why i am getting this error.
Thanks & Regards
Lakshmieie
|
|
|
|
|
I'm trying to understand how the .NET framework manages memory and I've been using various profiling tools but there are still a few things that don't add up that maybe someone here can help me with. I've been using primarily devPartner studio with a sample project just to test a few things out.
Let's start with the simplest of examples. If I create a loop that calls a dummy function that does nothing, something just to occupy memory, after the garbage collector runs a small amount of memory remains occupied. Granted it's only 324 bytes, but it should be 0 bytes and I need to figure out why. DevPartner Studio tells me I have 7 unreachable objects for a total of 208 bytes. My question is that if the garbage collector just ran, why are there any unreachable objects left? The rest of the memory (116 bytes) is occupied by an object array named "String Table" that I presume .NET was using to keep track of the strings I was allocating to consume memory. Seems the string array is no longer needed it would make sense if it were garbage collected, but if .NET wants to keep it around it really not a problem. At least that behavior is explainable. The 208 bytes of unreachable objects is a bigger problem.
The problem becomes much more significant when I create an instance of a System.Data.SqlClient.SqlConnection and open it. After opening the connection, closing it, and garbage collection, I'm left with about 185K of memory that couldn't be cleaned up, about 150K of which is unreachable objects.
I haven't yet tested the impact of opening multiple connections or repeatedly opening and closing the same connection.
Any ideas will be greatly appreciated.
Thanks, Jason
|
|
|
|
|
one of the possible reasons is objects that need explicit finalization (have defined finalizers). when they are not reachable anymore and GC runs, memory for these object is not reclaimed immediately. instead, objects are moved to the so called 'FReachable' queue and their finalizers ar run. the memory is reclaimed in the next GC round.
you can find more details here[^] or here[^]
|
|
|
|
|
When you close a database connection, the connection itself is not destroyed, but kept in the connection pool. This greatly improves the speed of each following connection to the same database.
---
b { font-weight: normal; }
|
|
|
|
|
First off, how did you make the GC run? GC.Collect ? That's not enough. You need to do
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
Jason Pease wrote:
If I create a loop that calls a dummy function that does nothing
That's because the JIT compiler generates native code the first time a function is called and that code obviously takes up some space. If you'd noticed it carefully, you'd have seen that memory consumption doesn't keep rising, it just stays at that point. Nothing short of shutting down the process will reclaim that memory for you.
Jason Pease wrote:
The problem becomes much more significant when I create an instance of a System.Data.SqlClient.SqlConnection and open it. After opening the connection, closing it,
IIRC, the underlying connection is not closed and the managed SqlConnection object is simply pooled, so obviously it can't be garbage collected.
Jason Pease wrote:
I'm left with about 185K of memory
How did you measure? Task Manager? You should be using Perfmon with "#Bytes in All Heaps" counter to get an accurate picture of the size of the GC heap.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
S. Senthil Kumar wrote:
IIRC, the underlying connection is not closed and the managed SqlConnection
Maybe it's because my profiler (devPartner Studio) doesn't allow me to see it, but this space only shows up as "Unreachable Objects"; it doesn't show me the type of object. I would have expected to see a pooled connection with some type of indicative name, not Unreachable Objects.
This brings up the question though of where a pooled connection is kept. Seems I can utilize the same pooled connection from two different applications (right?), I would have expected it to not be included in the memory of my application space, but instead somewhere else. Maybe I need to study this more thoroughly.
S. Senthil Kumar wrote:
How did you measure? Task Manager?
DevPartner tells me how much memory it is profiling. I've verified this number with the .NET counters and it seems to be reliable.
Thanks for your help, Jason.
|
|
|
|
|
Jason Pease wrote:
Seems I can utilize the same pooled connection from two different applications (right?)
Really? I may be wrong, but I don't think that's possible. At best, they might be shared across all AppDomains in the same CLR instance.
This[^] is a very good (and free) profiler that shows the actual objects in the GC heap.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi,
how do I copy directories?
There is the Directory class, but it has no Copy method in it, and the File.Copy method won't let me specify a directory in its parameters.
|
|
|
|
|
you have to make your own function for it .you can travel a directory in breadth first search manner and then u can copy each file individually.In C# there is nothing for copying directories may be u can find anything in win32 api.although i am not sure.
|
|
|
|
|
Hi All,
I want to watch all fixed drives on a computer.Is there any reliable way to do that.I am watching for create , delete , change , rename events for all files and folders.I am using filesystemwatcher but its not very reliable at all especially for high trafiic activity.I am using empty string for the filter property.I have changed internalbuffersize to 32 KB.I don't want to miss any event , if any event fires two or three times that is not a problem.I in the notifyfilters i have set that property to NotifyFilters.Size|NotifyFilters.LastAccess|NotifyFilters.LastWrite|NotifyFilters.FileName|NotifyFilters.DirectoryName|NotifyFilters.CreationTime|NotifyFilters.Attributes even after that i am having troubles with word documents especially when i write into a word document and save it sometimes it fires changed event and sometimes i am not able to get the event .it is not showing the internal buferoverflow exception on that time either.and when i am copying a large directory say having around 13000 files then internal buffer overflow exception occurs.on msdn site they have given that with a 4 KB buffer size we can watch change for around 80 files so may be i have to use very large buffer size.Is there any other Class or Win32 API available which can do the task so that I must be able to watch all the events and don't miss any event.Thanks in Advance.
|
|
|
|
|
Without writing your monitoring code as an NTFS extension, no there is no reliable method to capture changes acrossed an entire volume. FileMon, from SysInternals, uses this technique. It requires a black belt in NTFS internals and Interop to implement though.
The FileSystemWatcher relys on the NT Kernel function ReadDirectoryChangesW . This function is known to have more than a few problems, especially when monitoring remote directories. The problems just get worse, the bigger the directory tree you're monitoring.
For more information, search for ReadDirectoryChangesW on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|