I m parsing a file that has MalFormed data from time to time.
and it s throwing an exception,
i d like to recover from the exception and ignore the bad formatted data.
What s the best way to do this?
try{
// parse file
}catch(Exception){
//eat it.
}
*EDIT:*I think, my question wasnt understood well. i d like to recover from the exc...
I am new to TDD and DDD and I have one simple question regarding static methods in general. Most of the gurus of TDD says in one word that static methods are bad (and that we should forget about creating tons of static utilities that we (um or I) used to make before as they are not testable. I can see why they are not testable ( a great ...
I'm using C# / .NET 4. I have a form with a WebBrowser component on it. I have loaded an external web page to the WebBrowser component.
I have an event handler attached to the Navigating event. This works for most things. however, one part of the web site I'm loading executes a window.open(url) javascript command. This has the effect o...
I'm looking to upgrade my ASP.NET web app to the .NET 4 framework. Would I see performance improvements right away?
...
Based on my research, I have learned the following:
TaskScheduler.UnobservedTaskException must wait for the task to be garbage collected before that task's unobserved exception will bubble up to the UnobservedTaskException event.
If you're using Task.Wait(), it'll never get called anyway, because you're blocking on an impending result ...
I keep track of the original size of the files that I'm compressing using .Net's GZipStream class, and it seems like the file that I thought I was compressing has increased in size. Is that possible?
This is how I'm doing the compression:
Byte[] bytes = GetFileBytes(file);
using (FileStream fileStream = new FileStream("Zipped.gz", Fil...
If you came across some C# code like this with nested using statements/resources:
using (var response = (HttpWebResponse)request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
using (var reader = new BinaryReader(responseStream))
{
// do something with reader
}
...
Is there an easy way to match all punctuation except period and underscore, in a C# regex? Hoping to do it without enumerating every single punctuation mark.
...
Hi,
Is it possible to change the value of a public property (type string) of a class within a given .NET AppDomain from another separate .NET AppDomain assuming both AppDomain's are running in the same process. The other important assumption is that the code running in the AppDomain that contains the property can not be modified .. ie ...
I have a class which accepts a stream as input (in the constructor). It surfaces content from this stream through various methods.
However, I don't want my object to be responsible for closing the stream -- that should be the responsibility of the caller. I therefore need to close my StreamReader inside my class, but I can't close the u...
Does the following generic function exist anywhere in the .NET 4.0 framework? I would like to reuse it if it does rather than writing it myself:
public static class Lambda
{
public static U Wrap<U>(Func<U> f)
{
return f();
}
}
It allows for the following construct (i.e., lambda expressions embedded in the select claus...
I'm using the .Net GZipStream class to compress and decompress files. After I do the decompression, the data seems fine, but then turns to nothing but zeros after a certain, seemingly arbitrary, point. For example, after decompressing a file, it is the proper 19KB in size, but bytes 10,588 and on are all zeros.
I'm not sure what I'm doi...
Is the following possible, after many hours of searching I cannot find a straight answer anywhere.
From an external website, which users login to using their Facebook Login, we wish to allow users to upload photos to a Facebook Page of which we are the administrators.
The photos should go to a specific album which we will create.
Photos...
My application reads an Access database file that can be updated at runtime by downloading a replacement MDB file (with the same schema) and overwriting the existing file. This is all well and good during development, but it breaks during deployment.
The main problem is that the connection string for the data adapters is
"Provider=Mic...
foreach (var node in root.Find("a[href]"))
{
var href = node.Attributes["href"].Value;
Uri uri;
try
{
uri = new Uri(item.Value.Uri, href);
}
catch(UriFormatException)
{
continue;
}
// *snip*
try
{
if (_imageHosts.IsMatch(uri.Host)) // <--- problematic line
pr...
I can't seem to find a simple, concrete explanation of how to bind controls in a WinForms app to nested objects using data binding. For example:
class MyObject : INotifyPropertyChanged
{
private string _Name;
public string Name { get { return _Name; } set { _Name = value; OnPropertyChanged("Name"); } }
private MyInner _Inn...
This really isn't an important question. I just wanted to know which method is more popular and whether there's some sort of a de facto standard.
This,
function foobar
{
int retVal = 0;
try
{
retVal+=100;
}
catch
{
//error handling code
}
return retVal;
}
Or this?
function foobar
{
...
I am looking for a proven approach for management of configuration file (app.config and web.config) and its contents for .NET applications. The objectives are:
Keep the file's content encrypted to eliminate unwanted change by unauthorised way.
Have a user interface to change tags, values for particular sections
Manage which sections ar...
i have a DLL of a VB 6 Project that has one class n a form............. the form is called from that class when its constructor is called..........i maked DLL on whole project......add that DLL in my .NET project references.....now when i call that class of that DLL.....it give following error
Creating an instance of the COM component w...
How to Resolve following Error in .net
Non-modal forms cannot be displayed in this host application from an ActiveX DLL, ActiveX Control, or Property Page.
...