Normally you get this error when you are trying to use Selenium with C#. Download the IEDriverServer.exe file either in the Debug>bin or Release>bin depending on your compilation or add the path where the IEDriverServer.exe is located in your PC to the PATH environment variable. You can download the IEDriverServer.exe from http://www.seleniumhq.org/download/. Download the 32-bit version.
Sharing knowledge does not lessen your store, often it gets you more.
Success doesn't happen overnight and patience is key to living your dream life.
Success is a journey not a destination
Showing posts with label c#. Show all posts
Showing posts with label c#. Show all posts
Thursday, January 05, 2017
Sunday, April 13, 2014
Get Date and TimeStamp from an FTP Server
FtpWebRequest request = (FtpWebRequest)WebRequest.Create (serverUri);
request.Method = WebRequestMethods.Ftp.GetDateTimestamp;
FtpWebResponse response = (FtpWebResponse)request.GetResponse ();
Console.WriteLine ("{0} {1}",serverUri,response.LastModified);
Tuesday, April 23, 2013
Cookie Aware Web Client on .NET Framework 3.5
Have been working on a project where I needed to download some files from a website which uses forms authentication.
I created a console application using VS 2010 targeting .NET framework 4.0 and used the Cookie Aware version of WebClient class.
The authentication cookie is stored and the files were downloaded successfully.
Unfortunately the code doesn't work once I started targeting .NET framework 3.5
To make the authentication cookie to be stored, the authentication need to be performed twice to make it to work in .NET framework 3.5
Thursday, November 10, 2011
.NET User Group: iPhone Application Development for .NET Junkies
Did my first presentation at the .NET User Group yesterday on Developing iPhone Applications using .NET (C# and MonoTouch).
Really encouraging feedback and comments.
Slides: iPhone Application Development for .NET Junkies
Really encouraging feedback and comments.
Slides: iPhone Application Development for .NET Junkies
Thursday, May 26, 2011
Cannot convert lambda expression to type 'string' because it is not a delegate type
Got this odd error and but not so meaningful.
Solution
Just include the Linq namespace that will fix the error.
using System.Linq;
Solution
Just include the Linq namespace that will fix the error.
using System.Linq;
Tuesday, February 08, 2011
Entity framework and calling a stored procedure
Calling a stored procedure using Entity Framework without adding the stored procedure to the Designer.
Monday, December 13, 2010
Get Time difference using C#
DateTime startTime, endTime;
startTime = Convert.ToDateTime("2:30 AM");
endTime = Convert.ToDateTime("3:30 AM");
var timeDiff = new TimeSpan(endTime.Ticks - startTime.Ticks);
MessageBox.Show("Time difference in hours is " + timeDiff.Hours);
startTime = Convert.ToDateTime("2:30 AM");
endTime = Convert.ToDateTime("3:30 AM");
var timeDiff = new TimeSpan(endTime.Ticks - startTime.Ticks);
MessageBox.Show("Time difference in hours is " + timeDiff.Hours);
Tuesday, November 30, 2010
How to get ErrorDescription in SSIS
If you use an Error Output in SSIS you will get the ErrorColumn and ErrorCode and not the Error Description. You can get the ErrorDescription by using a script component.
Make sure you a column to the Output that is going to contain the Error Description and use the following code.
VB.NET
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Row.ErrorDescription = ComponentMetaData.GetErrorDescription(Row.ErrorCode)
End Sub
C#
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
Row.ErrorDescription = ComponentMetaData.GetErrorDescription(Row.ErrorCode);
}
Make sure you a column to the Output that is going to contain the Error Description and use the following code.
VB.NET
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Row.ErrorDescription = ComponentMetaData.GetErrorDescription(Row.ErrorCode)
End Sub
C#
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
Row.ErrorDescription = ComponentMetaData.GetErrorDescription(Row.ErrorCode);
}
Wednesday, November 10, 2010
How to raise Error event in SSIS?
Syntax
ComponentMetaData.FireInformation(int InformationCode,
string SubComponent,
string Description,
string HelpFile,
int HelpContext,
out bool pbFireAgain
)
FireCustomEvent
Raises a user-defined custom event in the package.
FireError
Informs the package of an error condition.
FireInformation
Provides information to the user.
FireProgress
Informs the package of the progress of the component.
FireWarning
Informs the package that the component is in a state that warrants user notification, but is not an error condition.
e.g.
bool pbFireAgain = false;
ComponentMetaData.FireInformation(0, string.Empty, "Information", string.Empty, 0, ref pbFireAgain)
ComponentMetaData.FireInformation(int InformationCode,
string SubComponent,
string Description,
string HelpFile,
int HelpContext,
out bool pbFireAgain
)
FireCustomEvent
Raises a user-defined custom event in the package.
FireError
Informs the package of an error condition.
FireInformation
Provides information to the user.
FireProgress
Informs the package of the progress of the component.
FireWarning
Informs the package that the component is in a state that warrants user notification, but is not an error condition.
e.g.
bool pbFireAgain = false;
ComponentMetaData.FireInformation(0, string.Empty, "Information", string.Empty, 0, ref pbFireAgain)
Sunday, August 08, 2010
Named arguments and Optional Parameters
Optional parameters - the ability to define a function parameter with a default value. When the function is called, the caller can pass the parameter value if not the default value is used.
Named arguments - C# now provides an ability to name the argument and pass the value along with that in a function call.
VB.NET had it for a while. This will be useful when you code with COM API's.
Note: Optional parameters must be specified at the end (after defining the required parameters)
Named arguments - C# now provides an ability to name the argument and pass the value along with that in a function call.
VB.NET had it for a while. This will be useful when you code with COM API's.
Note: Optional parameters must be specified at the end (after defining the required parameters)
System.Dynamic - ExpandoObject in C# 4.0
The ExpandoObject enables to create new members for an object in runtime. The ExpandoObject was introduced in C# version 4.0.
Note: You must reference System.Dynamic.dll to use ExpandoObject.
Note: You must reference System.Dynamic.dll to use ExpandoObject.
Sunday, August 01, 2010
How to escape XML text in c#?
Escaping XML text is basically encoding the following symbols (<, >, &, ", ').
This can be done in the following ways.
a) Using Replace function
string xmlData = "I live in \"wellington\" & I love listening to music. "
string escapedXmlData = xmlData.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'");
Note: Replace the & symbol first.
b) Using System.Security.SecurityElement.Escape() method
string xmlData = "I live in \"wellington\" & I love listening to music. "
string escapeXmlData = System.Security.SecurityElement.Escape(xmlData);
This can be done in the following ways.
a) Using Replace function
string xmlData = "
string escapedXmlData = xmlData.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'");
Note: Replace the & symbol first.
b) Using System.Security.SecurityElement.Escape() method
string xmlData = "
string escapeXmlData = System.Security.SecurityElement.Escape(xmlData);
Sunday, July 18, 2010
DateTime MinValue in SQL SERVER and C#
I was trying to store C# DateTime.MinValue in SQL SERVER and got the following exception
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
In SQL Server the minimum date that can be stored in a datetime field (1753/1/1), is not equal to the MinValue of the DateTime .NET data type (0001/1/1).
Therefore if your datetime value is DateTime.MinValue then don't save it in SQL SERVER.
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
In SQL Server the minimum date that can be stored in a datetime field (1753/1/1), is not equal to the MinValue of the DateTime .NET data type (0001/1/1).
Therefore if your datetime value is DateTime.MinValue then don't save it in SQL SERVER.
Monday, July 05, 2010
System.Data.SqlClient.SqlException: New transaction is not allowed because there are other threads running in the session.
I got this error when using Entity Framework with the following code.
Solution
The foreach loops were the culprits. I needed to call EF but return it into an IList of that target type then loop on the IList.
Solution
The foreach loops were the culprits. I needed to call EF but return it into an IList
Friday, June 18, 2010
First project
Time for some real work after all other initial stuff in my new work place. I have started working on a project which has a mix of technologies Sharepoint, ASP.NET, C#, Linq to Entities, WCF, ASMX Web services, SQL SERVER 2008.
I am working on an Import/Export task using C#, Linq to Entities, WCF, ASMX Web Services.
I know about the Linq to Sql Debugger Visualizer addin for Visual Studio and it looks like Linq to Entitites also have one similar to that.
Linq to Entities Debugger Visualizer
I am working on an Import/Export task using C#, Linq to Entities, WCF, ASMX Web Services.
I know about the Linq to Sql Debugger Visualizer addin for Visual Studio and it looks like Linq to Entitites also have one similar to that.
Linq to Entities Debugger Visualizer
Thursday, January 28, 2010
Data at the root level is invalid. Line 1, position 1
I got this error "Data at the root level is invalid. Line 1, position 1" when I tried to read an XML file using C#.
Initially I was checking whether the XML is well formed and tried opening in IE to make sure whether it opens fine. IE didn't show any errors and my XML document was fine.
I couldn't figure out what's gone wrong. After a few minutes I realised that I was using XML.LoadXML() instead of XML.Load().
Actually I had my code initially to load an XML string so I was using XML.LoadXML() but changed the logic to load an XML document but forgot to change the code to XML.Load().
XML.Load() - to load an XML File
XML.LoadXML() - to load a XML String
Initially I was checking whether the XML is well formed and tried opening in IE to make sure whether it opens fine. IE didn't show any errors and my XML document was fine.
I couldn't figure out what's gone wrong. After a few minutes I realised that I was using XML.LoadXML() instead of XML.Load().
Actually I had my code initially to load an XML string so I was using XML.LoadXML() but changed the logic to load an XML document but forgot to change the code to XML.Load().
XML.Load() - to load an XML File
XML.LoadXML() - to load a XML String