|
The exception is pretty obvious: the path you're requesting can't be found. When you want to load a file, you must use the physical path - not the URL. In ASP.NET, you can use MapPath (implemented on the Page and HttpServerUtility (the Server property that many classes expose)) to map a virtual path (i.e., URL) to a physical path on the same machine:
feedURL = MapPath("default url"); That'll get you the physical path to the file which you can load into your XmlDocument .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
Thanks for your feedback.
This section of the aggregator should initially display a blank page, and not anything else (including any other URL's). Do you know how I could go about rectifying that?
Thanks once again
|
|
|
|
|
1. Set all controls' Visible properties to false that you don't want displayed.
2. Override Render in your page and don't render anything initially.
3. Redirect to a blank page.
4. Transfer execution to a blank page.
5. ...
There's countless ways.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks Heath
|
|
|
|
|
Im having a lil problem with some code. I think it would be better to explain it then post it. Im using a thread timer to run a blaock of code that checks if the computer is online using try catch statements. It run good when online but when i go offline it runs some code (catch statement) but doesnt keep checking if online, as in the thread timer stops when the exemption is thrown. Is there a way to have the program keep checking if its back online, without forever loops (which didnt work out right, still learning C#)
Outline:
thread.Timer(timerCallBack( ON_TIMED_EVENT )) //every 60 sec
ON_TIMED_EVENT
{
try
{
check if online
IPHostEntry hostInfo = Dns.GetHostByNam
}
catch Exception
{
code when not online
}
}
I want it to keep checking instead of just stoping the
Thread Timer
Jason
modified 16-May-21 21:01pm.
|
|
|
|
|
Which Timer class are you using? There's three different ones and they all work a little differently.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
System.Threading.Timer
modified 16-May-21 21:01pm.
|
|
|
|
|
First question to ask is does the ON_TIMED_EVENT ever return?
Maybe there is something wrong with your code in the catch statement.
|
|
|
|
|
It doesnt return anything just checks to see is my computer is online by pinging a website. This is on a timer that repeats every 60 secs (testing it on every 5 secs). When i disconnect the catch block is ran but thats it, doesnt check anymore if online or offline, this is what im trying to fix, to keep checking even after the catch(Exception), im thinking about using "finally" since it always runs if a try or catch is ran, i just now thought of it.
modified 16-May-21 21:01pm.
|
|
|
|
|
"finally" didnt work, it looks like after the catch the Thread.Timer stops running, so the On_Timed_Event doesnt run anymore.
modified 16-May-21 21:01pm.
|
|
|
|
|
Then apartently your not catching exceptions in the right place or aren't catching the right exceptions. I know you put Exception in your sample code in the root message of this thread, but I've seen many times where people don't sample their code accurately.
The other problem is that all the timers (and pretty much everything in System.Threading ) encapsulate native APIs. If a thread throws an exception in the native API, the timer thread will most likely quit. In your catch block, restart the timer by instantiating a new Timer , assigning it to the previous field (if any) and using the same TimerCallback delegate.
Also, you should consider using System.Timers.Timer instead, which has higher resolution and is pretty well guarded against exceptions (it still throws them, but typically recovers the timer thread).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks, using System.Timers.Timer works.
modified 16-May-21 21:01pm.
|
|
|
|
|
I am trying to develop an custom listView that can be viewed in Windows XP and 2003 in GroupView ( Explorer-like ). This listView will have 2000+ items. The problem is that when it has 2000 items, it works very very slow. I've tried to set LVS_OWNERDATA and it increases the speed dramatically, BUT LVM_ENABLEGROUPVIEW is not supported with virtual listViews. The real question here is how you can make a listView very fast ( i mean not loading the items, fast when you browse through them ) , without setting LVS_OWNERDATA . My personal opinion is that this is a major bug in WindowsForms( the fact that it is so slow ) cause I tried the same thing in MFC and works fine. Please help me and possibly others who are dealing with this. Thanks in advance !
|
|
|
|
|
It's not a bug in Windows Forms (i.e., the .NET FCL) - it's just how the CLR passes messages around and encapsulates everything, since all those controls just encapsulate their Common Control equivalents. Even most of the painting is handled by the List-View common control itself. I'm assuming you're overriding WndProc in your derivative class (since that's about the only way to do it), so make sure you keep the code fast by using conditionals right away to determine if you even want to handle the message. If you still handle owner-drawing by creating Graphics objects, then you'll incur quite a performance penalty as managed objects are being created that encapsulate native handles. In this case, you'll probably be better off P/Invoking the GDI functions you need to do any painting.
Not that it really helps now, but the .NET Framework 2.0 will introduce both grouped views and virtual lists. I haven't tried grouping with thousands of items, but I'd assume its pretty fast since I know Microsoft is focusing on better performance in 2.0.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for your reply. Even if I don't override WndProc at all and just create a listView with 2000 items, it's still slow when you're browsing the last items in the list. I've tried text and/or image callbacks but still doesn't help. Any ideea ? ( besides using a ListBox ) . By the way, when will .NET Framework 2.0 will be released ?
|
|
|
|
|
I'm sorry, but without seeing your code its hard to know what to suggest. Unfortunately, I really don't have the time (really).
The .NET Framework 2.0 is supposed to be out early in 2005 (haven't heard which quarter yet, though, despite my connections - because they don't know either). It's delayed primarily because of SQL Server 2005 (formerly code name "Yukon"). They want to release them at the same time since they're basically companion products.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi new to programming. I have a program that is supposed to compare two dates however when I run the program it reads the date as a string. What is the best way to compare a date to another date?
|
|
|
|
|
Use DateTime.Parse to parse a string into a DateTime (be sure to catch exceptions) and use DateTime.Equals or == to compare it to another DateTime . If you only want to account for the date portion of a DateTime , then compare one DateTime.Date to another. Same goes for DateTime.TimeOfDay (which is actually a TimeSpan structure). See the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
:-Dusing System;
namespace ConsoleApplication3
{
class Class1
{
static void Main()
{
//this is two date and the dateTime.Compare
//method will return 0 if both data are equal
//otherwise it will return 1
DateTime dt=new DateTime(2004,06,05);
DateTime dt1=new DateTime(2004,03,05);
int a=DateTime.Compare(dt,dt1);
Console.WriteLine(a.ToString());
//please don't use any other data type to reprasent datatime data types.
}
}
}
hai, feel free to contact
Sreejith SS Nair
sreejith@neosoft-tec.com
|
|
|
|
|
|
See the BitConverter class in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
My class has a structure as such:
public class MyClass{
MyNestedClass Property1;
string Property2;
(... other members ...)
protected class MyNestedClass{
string PropertyA;
string PropertyB;
(... other members ...)
}
}
The reason behind encapsulating PropertyA and PropertyB is because I use the two properties more often than the other members in MyClass, even though PropertyA and PropertyB belong (describe) MyClass. That reason seems to be good when it comes to implementation.
However, somehow I don't think it is conceptually correct because I believe that a class should describe a complete entity.
I appreciate any comments.
|
|
|
|
|
Hi,
I am trying to create a login page.
Can someone point out to me how I may connect to a back-end Access database, and validate the entered username and password with the ones stored in the database?
Thanks for any help in advance
|
|
|
|
|
See my article, Role-based Security with Forms Authentication[^], for information on how to use a database to store and validate credentials using Forms Authentication, which provides many features over most home-brewed solutions (which are typically pretty insecure if you don't have a lot of experience with security).
The .NET Framework 2.0 will make this even easier with pluggable authentication back-ends to various front-ends (like Forms Authentication). For now, you're pretty much left with either extending what's available or implementing your own authentication modules.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Making my application i have suddently got and evil optimization question about "What are the internals of the array list" . Does any of you know if it is based on a linked list or on an array.
Also do you know where i can get my hand on a Simple Linked List or a Binary Tree.
Thank you for help.
|
|
|
|