Tuesday, November 23, 2010

find all listening ports - back to basics

netstat -an |find /i "listening"


open a port from cmd
netsh> add portopening TCP 9353 "xyz"

Monday, November 8, 2010

Eliminate if else statements for disabling and enabling controls

if (count > 0)
{
this.control.Enabled = false;
}
else
{
this.control.Enabled = true;
}



// this is 1 line compared to what we have above.
this.control.Enabled = (count <= 0);

Tuesday, November 2, 2010

DateTime vs DateTimeOffset

if (you are developing applications with globalization in mind)
{
use DateTimeOffset
}
else
{
use dateTime
}

Saturday, October 30, 2010

Security Prompt when trying to call a webhttpbinding service method.

i was working with a webhttpbinding service which was being called from Javascript and which inturn calls a wshttpbinding service, and all of a sudden i was getting a login prompt when i was trying to invoke this new method that i created, after a while i found out that the problem, my datacontracts were not updated, it was missing a new field that i added, once i added this new field, the login prompt went away....

Thursday, October 28, 2010

WCF Performance.

http://webservices20.blogspot.com/2010/10/important-wcf-performance-issue.html and i said WOW....

Tuesday, October 26, 2010

Team Foundation Error The cache file C:\Users\Administrator\AppData\Local\Microsoft\Team Foundation\3.0\Cache\VersionControl.config is not valid and cannot be loaded. Please correct or delete the file.

Fired up my VPC and tried connecting to TFS and i run into this error, i thought i need to setup bindings and working folders again....

*****************************************************************************
The cache file C:\Users\Administrator\AppData\Local\Microsoft\Team Foundation\3.0\Cache\VersionControl.config is not valid and cannot be loaded.

Please correct or delete the file.
*****************************************************************************

The solution was simple get a copy the "VersionControl.config" from your fellow dev on the project and replace it, TFS internally stores all the team members source control setting in this file.

Dll is locked

We had an issue where in our dll was locked and we were unable to delete it, i thought of using processexplorer from sysinternals to look at the process, while downloading it i came across this link
http://blogs.msdn.com/b/winclient/archive/2004/07/08/177947.aspx

and the solution was :
tasklist /m thelocked.dll

Monday, October 25, 2010

Exception: New transaction is not allowed because there are other threads running

this was crazy the solution was found in the following thread

http://stackoverflow.com/questions/2113498/sqlexception-from-entity-framework-new-transaction-is-not-allowed-because-there/3902790#3902790

Reason: we cannot do savechanges while still the reader is open.

//This will fail because we are doing savechanges while the reader is open
xs= Dataservice.GetX().Where(x=>!x.Ideleted)

foreach(x in xs)
{
//do something
Savechanges()
}

//this will succed becasuse we did a tolist(which closed the reader) and then did savechanges

xs= Dataservice.GetX().Where(x=>!x.Ideleted).ToList();

foreach(x in xs)
{
//do something
Savechanges()
}

One the Primary Limitations of the DataContract Serializer.

-One the Primary Limitations of the DataContract Serializer, is it cannot do xml attributes, it always serializes in elements, contrary to this xmlserializer does attributes, which leads to small message size.

Need to Explore.

-WCFMock (should be very interesting to find how the contexts(operation,security) are tested

-AppFabric (should we be calling it B..Ta.k

-ServiceBus.

Sunday, October 24, 2010

my favorite tools

1) resharper
2) msbuild
3) debugview
4) linqpad
5) msbuildpad (imagine multiple branches)
6) Ninject

Saturday, October 23, 2010

SQL LEN function

Well, i was having an issue comparing a string retrieved from sql server and user input, the comparsion was always failing, wonder why, after debugging i found that the value in sql server had a space at the end (right), so i fired up ssms and did a LEN() function on the string, the len function result was same as what the user entered, then why was the comparsion failing, after sometime i realized that len function ignores spaces on the right, so then i used the datalength function and it gave me the correct result.

wonder why the LEN function ignores the right white spaces......

Identity Key in Entity Framework

we have a sql table with a composite key , and later on we decided to use, an Identity key so altered the table to include a new identity column (we still kept the composite key), now after re-generating the edmx, the entitycreate method was expecting an ID to be passed, but this was supposed to be autogenerated, did not have enough time to debug the issue, but after searching the net for sometime i found that you have to pass an id (can be any int), to the create method as it complains and the savechanges ovverides it with an appropriate id value, i have a todo on that and hopefully i will update regarding the issue in the future.

convert html to text.

i had the requirement to convert existing html into text, tried regular expression there are limitations to it, ex:

Saturday, July 3, 2010

RIA

RIA : Automates the Data Access layer (push and pull mechanism) and generate client data access code.


RIA Service = Domain service.
RIA Client = Domain context.

Populating a datagrid
grid.ItemSource=Context.Entites
EntityQuery query=context.GetEntity();
LoadOperation loadOp=Context.Load(query);

Wednesday, June 30, 2010

Fluent query Syntax and query expression syntax

string names[]= {"name1",name2"};

Fluent Query syntax= query with predicates

ex:
IEnumerable query=names.Where(n=> n.Contains("a");

Query expression Syntax
IEnumerable query =from name in names
where name.Contains("a")
select name;

Thursday, December 10, 2009

Handling Change in WCF contracts.

The following is from the url

http://www.devx.com/dotnet/Article/42005/0/page/3

  1. Always use the Name and Namespace parameters on all contracts.
  2. Always use the Order parameter on data members.
  3. Implement the IExtensibleDataObject on all data contracts.
  4. Use namespaces for contract versioning.
  5. Always remember that new versions require new endpoints.
  6. When using strict schema validation, do not change contracts. Create new versions.
  7. When removing an operation from a service contract, create a new version.
  8. When changing the signature of an operation, create a new version.

Wednesday, September 9, 2009

Issue exposing an orchestration as a wcf service

You built your orchestration, deployed it and tested it with a file port everything works fine.... cool

now you want to expose the orch as a wcf/asmx service, we launch the wcf publishing wizard and after specfying the name space you find that there are no public ports, ok, we go modify the the preceive port to Public and then launch the WCF Publishing wizard again, we still get the same error message,,,,,,

I wonder why??

Resolution:
un gac the orchestration assembly and then we try again, still the same error

I wonder why???

Restart visual studio and open the project and viola we can publish the orch as a service now,......

Tuesday, July 7, 2009

Assert.AreSame dosent compare the properties of the two instances

as you guessed it dosent compare the properties but the pointer, so even if the two instances are initialzed to the same properties it will always fail.

the solution (Reflection).
http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=442