Feeds:
Posts
Comments

Archive for January, 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.

Read Full Post »

CodeFetch

 

CodeFetch.com  is a new web site that has a search engine where you can look up code used in programming books.

I found it first at  Chris Sell’s Blog

http://www.sellsbrothers.com/news/showTopic.aspx?ixTopic=2070

 

Interesting:)

Read Full Post »

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/

Read Full Post »

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”;

}

***************************************************

Read Full Post »