|
The best way of learning what you're doing wrong, is by monitoring HTTP, with a tool like Fiddler[^].
Do the same thing with a browser and your program and pay attention to headers and connections: probably you'll see what you're doing different from the browser and you'll be able to do the same thing with WebRequest and WebResponse.
Yes, even I am blogging now!
|
|
|
|
|
Hi
Thanks for your reply.. I'll try this
|
|
|
|
|
Hi,
imagine a Folder object, that contains a list of File objects. Each File object has a Folder parent. So we have a cyclic dependency here. When I try to return such structure with a web service, I get the following error:
System.Web.Services.Protocols.SoapException: Server was unable to process request. --> There was an error generating the XML document. --> A circular reference was detected while serializing an object of type Folder.
I've read that XmlSerializer can't handle cyclic dependencies. Does this mean that I cannot use web services to return such a structure, or is it a bug and will it be possible in 2.0 for example? Is there some kind of workaround for now?
Thanks in advance!
|
|
|
|
|
I've never tried this on a WebService, but some time ago I needed to serialize a circular reference with the XmlSerializer and it didn't work, but the SoapFormatter could. Since web services use soap, it should work, but I'm only guessing here...
Yes, even I am blogging now!
|
|
|
|
|
Hello,
how I am able to filter directories and copy real files only ?
C:\Temp\Subfolder\
C:\Temp\readme.txt
(Copy only readme.txt, not the Subfolder)
I am using
foreach(string Element in Files)
for getting all elements in a directory.
|
|
|
|
|
|
Use the Directory.GetFiles method to obtain the names of files in a specific directory and afterwards copy the files by using an overload of the File.Copy method.
www.troschuetz.de
|
|
|
|
|
i want write a codeEditor, so i want to know, can you help me?
i know it will uses the RegularExpressions , but i only konw this, i do not know what should i do next.
|
|
|
|
|
I am not sure that you mean, but if I understand you correctly, you need to color some text lines or words in a you application. Allmost all form components have two properties, called FORECOLOR and BACKCOLOR. They can easly be changed a follows:
MyTextBox.ForeColor = Color.Blue;
MyTextBox.BackColor = Color.White;
You can find Color in the namespace "System.Drawing".
Remember to add the line "using System.Drawing;" to top of your file.
|
|
|
|
|
Try SharpDevelop[^].
It's available as free, open source, have a separate syntax coloring editor control, and it's damn well documented - they even wrote a book, available in paper and as a free e-book download.
The control is stable, fast (as fast as this can be done in C#), and flexible.
Yes, even I am blogging now!
|
|
|
|
|
|
hi
i am a computr science studnt i have encountered the following problems in running your codes that i downloaded from your site
1- when i try to run these projects a message occurs that this project should be converted to the current visual studio version format and when i click ok to convert it another message occurs that it cannot be converted because it is a read only file and you must change the permissions on the file what should i do?
2- how do i add refernces in a c sharp project?
|
|
|
|
|
1 - Obviously you downloaded a solution that was created with Visual Studio.NET 2002 and tried to open it with the 2003 version, so the solution has to be converted. This fails because of the write protection of the files, so simply change this with the Windows Explorer. As a computer science student you should know how to do that.
2 - Go to the solution explorer, right-click on the Reference branch of your project, select add reference and then specify the assembly you want to reference to in the opening dialog.
www.troschuetz.de
|
|
|
|
|
how do i print a picture box in c#? include code sample. i am an ex c pgmr teaching myself c# i run visual studio.net on w2000 pro, not xp.
ez
|
|
|
|
|
If u still need some code, shout, i have it somewhere on my drive, printing of images in C#, as well as multipaged Tiff images
WARNING: Running on cold coffee.
|
|
|
|
|
Any body please tell whats the difference between keyword and reserved word
and also tell that if,else,while are keywords or reserved words
Please reply thanx
ihtesham
|
|
|
|
|
All keywords are reserved words in C# . This means u cannot use them as identifiers in your code .
if, else, while are keywords
|
|
|
|
|
Hi,
Since the reader may not be able to read all the data in 1 time. there's a need to read the data from the WebResponse for several times.
I've read some samples that uses a fixed buffer size, say 4096 bytes. Keep reading until all the data are read.
What is the advantage of using a fixed buffer size?
Why not just reading like the following code segment?
WebResponse response = request.GetResponse();
Stream responseStream = response.GetResponseStream();
BinaryReader reader = new BinaryReader (responseStream);
int bytesRead = 0;
byte[] result = new byte[response.ContentLength];
while(bytesRead < result.Length)
{
int bytesToRead = result.Length - bytesRead;
bytesRead += reader.Read(result, bytesRead, bytesToRead);
}
thanks
|
|
|
|
|
khchan wrote:
What is the advantage of using a fixed buffer size?
Why not just reading like the following code segment?
Because not always you'll have the Content-Length header, so you won't know how much to read. Did you ever try a download that IE couldn't show the '% complete'? That's why: in the .NET world, response.ContentLenght can return -1.
One advantage of the read 4k at a time approach is if are scanning through a page looking for some information (e.g., with a XmlReader constructed on top of the ResponseStream), and you may not need to read everything in an array.
And, at last, if you're building something with the ResponseStream (e.g., a string) and won't keep the byte[]. If you allocate arrays bigger than 85k, the GC will send them to a special area were they're not moved when collected, and if you have lots of huge (85k) temporary objects this can lead to bad GC performance.
Besides that, it's just habit and people code things without really asking "hey, why should I do this way?".
Yes, even I am blogging now!
|
|
|
|
|
I am trying to get an understanding about making classes thread-safe.
Since the constructor is called just once for each instance of a class, does it follow that no other consideration needs to be given to ensure the constructor is thread-safe?
Thanks for any help
|
|
|
|
|
Shayne Husson wrote:
I am trying to get an understanding about making classes thread-safe.
Since the constructor is called just once for each instance of a class, does it follow that no other consideration needs to be given to ensure the constructor is thread-safe?
No. However the new Operator[^] is not the problem as it (as you already mentioned) just creates an object, invokes the constructor and returns a reference to the newly created object. This will be thread-safe as long as the constructor does not access any outside object (public MyClass() {} for example is no problem at all). But let's assume you have something like this:
public MyClass(object someObject)
{
}
If you use this constructor in a multithreaded scenario you might end up having concurrent access of someObject . Now if you don't have a synchronization mechanism one thread might end up accessing someObject in an inconsistent state. So ultimately the need for synchronization in the constructor really depends on if and what you're trying to do with any objects which are known outside the constructor.
Best regards
Dennis
|
|
|
|
|
Just a little hint I forgot to mention in my previous post: when you dynamically create instances of anything derived from Control[^] be very careful in which thread you create them (see Multithreaded Windows Forms Control Sample[^] for details).
Best regards
Dennis
|
|
|
|
|
Cheers that makes things clearer for me.
|
|
|
|
|
Hey,
I am not sure if this is the correct place to put this, but I am currently localizing an active project that is using .resx files. While the developers are making simple changes, it seems to randomly re-order the files. So I was wondering if anyone knew of a good file difference program (like Beyond Compare or Win Diff) that can handle .resx files that keep switching order but not neccessarily data.
Thanks,
Brian
If you start a fire for a man, he will be warm for a day. If you start that same man on fire, he will be warm for the rest of his life.
|
|
|
|
|
Just came to the realization when creating an image list and pointing it to an icon file .ico that contains 16X16, 24X24, 32X32 size images that you can't specify which one to use.
I thought this was just a limitation of the visual studio property page, but then I started digging and I see no reference anywhere in .net to indexed icon files. Every icon related function seems to work with the 0th image by default.
For example when you use ImageList.Add(pathtoiconfile) you get no option to specify which image in the icon file to use.
Am I missing something here or are icon files with more than one image in them just not supported?
|
|
|
|