Categories
- Active Directory
- Apache
- ASP.Net
- Attributes
- Batch Files
- C#
- FireFox
- Generics
- IIS
- Internet Explorer
- JavaScript
- jQuery
- LINQ
- Microsoft AJAX
- Microsoft Office
- Microsoft TechNet
- MS Build
- MS SQL Server
- MVC
- Regular Expressions
- SSIS
- Subversion
- T-SQL
- Team Foundation Server
- This and that
- Visual Studio
- WCF
- Web Services
- Windows 7
- Windows Server 2008 R2
- WinForms
- WordPress
Archives
- January 2012
- October 2011
- September 2011
- August 2011
- June 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- May 2006
- March 2006
- January 2006
Meta
Category Archives: C#
Reading a CSV File with an OleDbDataAdapter and Jet
Reading a comma delimited is quite simple with an OleDbDataAdapter and Jet 4.0: private static DataTable ReadCsvFileViaJetOleDb(string file) { string connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"" + Path.GetDirectoryName(file) + "\\\";Extended Properties=\"text;HDR=Yes;FMT=Delimited\""; string query = "SELECT * FROM " + file; DataTable dt … Continue reading
Posted in C#
Leave a comment
Sys.WebForms.PageRequestManagerServerErrorException in FireFox with MSFT Ajax
If you encounter this error while navigating away from an AJAX-enabled page with a non-IE browser, you can silence it with the following JavaScript: if (!document.all) //non-ie { window.onbeforeunload = function() { Sys.WebForms.PageRequestManager.getInstance().add_endRequest(ignoreOnEndRequest); } } function ignoreOnEndRequest(sender, e) { err … Continue reading
Posted in ASP.Net, C#, FireFox, JavaScript
1 Comment
ASP.Net WebServices: Enabling or Disabling POST, GET, and Documentation Requests
It is relatively easy to control access to the various HTTP request types (protocols) for your ASP.Net WebService. Add something like this to the system.web section of your web.config: <webServices> <protocols> <add name="HttpSoap"/> <add name="HttpGet"/> <!– Because this web service … Continue reading
Posted in C#, Web Services, WinForms
Leave a comment
Regular Expression (RegEx) to Find Whole Words in a String
Ever want to match and replace whole words with in a string? Regular expressions (System.Text.RegularExpressions) makes it a one line operation: Regex.Replace(inputText, @"\b" + wordToReplace + @"\b", replacementText, RegexOptions.IgnoreCase); This pattern uses “word boundries” as your delimiters for matching text.
Posted in C#, Regular Expressions
Leave a comment
WinForm Exception Catching
Here’s a general way to catch most outside exceptions in your WinForm code. Add this to your program wrapper: Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Of course, it is always better to handle specific cases with specific types … Continue reading
Posted in C#, WinForms
Leave a comment
How much time does a method take to run?
I frequently run into the situation where I quickly want to learn how fast one method or section of code runs in my unit testing. Here’s a quick and dirty way to get it done: long startTime = DateTime.Now.Ticks; ExecuteMyMethod(); … Continue reading
Posted in C#
Leave a comment
WCF: System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL
If you are getting the “Your process does not have access rights to this namespace” error after switching your WCF service to run under a different account, try the following: 1) Install the Windows support tools from your Windows 2003 … Continue reading
Posted in C#, WCF
Leave a comment
Add your WebControls to your Web.Config to Simplify References
Ever get sick of repeating the same user control registrations at the top of your user controls, pages, and master pages within your web application? If so, you might want to try the following to save your self from all … Continue reading
Posted in C#
Leave a comment
Dynamically Instantiate Objects from Another Assembly within the Current AppDomain
Reflection is one of the coolest features in .Net. But to support instantiation of objects from different assemblies within your application domain requires a little finagling: // try this assembly first; full className e.g. MyNameSpace.Pattern.MyClass Type typeToCreate = Type.GetType(className); if … Continue reading
Posted in C#
Leave a comment
Find the Previous Method Called
To determine what the previous method called was prior to your current location in the code, try the following: string previousMethod = new System.Diagnostics.StackFrame(1, false).GetMethod().Name; This is a great quick way to determine the previous method for logging purposes in … Continue reading
Posted in C#
Leave a comment