Posted by emadmagdy on January 25, 2007
I hve came across an issue today:
I wanted to copy some datarows from one table to another.
I tried first to do this:
foreach(DataSetSource.Row row in tableSource)
{
tableDestination.Add Row(row);
}
It compiled with no errors but at run time threw exception saying “row already belongs to another table”
So I found some other way to do it :
foreach(DataSetSource.Row row in tableSource)
{
tableDestination.Rows.Add(row.ItemArray);
}
and this way it worked just fine.
Posted in Uncategorized | Leave a Comment »
Posted by emadmagdy on January 23, 2007
Posted in Uncategorized | Leave a Comment »
Posted by emadmagdy on January 19, 2007
Since ASP.NET 2.0 compilation is different than the previous ASP.NET 1.x model, it is not obvious for web developers where are the DLLs to which the FxCop should be pointing to for analysis.
I have recently found this simple and effective solution posted http://www.madskristensen.dk/blog/Use+FxCop+With+ASPNET+20.aspx.
In the post you will see steps of how to do it.
What he suggests in simple words is to publish the web site to a folder which will make the visual studio copy the DLL files there and then point the FxCop to the DLLs there.
Note: if using the Visual studio team suite, no need to worry about this as the built in code analysis tool handles this issue transparently.
FxCop home page and downloads can be found at http://www.gotdotnet.com/Team/FxCop/
Posted in Uncategorized | Leave a Comment »
Posted by emadmagdy on January 17, 2007
It is not allowed to have overloaded web methods. Trying to do so will not result in compile error but will generate a runtime error saying something like “Error: two methods having name”.
A possible workaround for this situation is to use the MessageName Property for the webmethod Attribute.
Example:
The following Code will cause errors
*********************************************
[WebMethod]
public string GetStatus(string username)
{
return “status1″;
}
[WebMethod]
public string GetStatus(int userId)
{
return “status1″;
}
***************************************************
A possible solution could be :
*********************************************
[WebMethod(MessageName="GetStatusByName")]
public string GetStatus(string username)
{
return “status1″;
}
[WebMethod(MessageName="GetStatusById")]
public string GetStatus(int userId)
{
return “status1″;
}
***************************************************
Posted in Uncategorized | Leave a Comment »