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

Monday, April 27, 2009

gacutil path for VS 2008

c:\Program Files\Microsoft SDKs\Windows\v6.0A\bin

Sunday, March 29, 2009

BizTalk and Dublin.

My take on it.

BizTalk will be used for integrating LOB applications EDI, Rosettanet and HIPPA, which it has proven over and over....

Dublin: use it for hosting traditional WCF and WF services, using BizTalk is way a big overhead and moreover Dublin is going to be free

But down the line, someday BizTalk will be replaced.......

Tuesday, March 24, 2009

Testing events in VSTS

Create a anonymous delegate and a variable to set
ManualResetEvent statsUpdatedEvent = new ManualResetEvent(false);
bool serviceFaulted = false;

Classevent += delegate
{
System.Diagnostics.Debug.WriteLine("Runtime faulted");
serviceFaulted = true;
statsUpdatedEvent.Set();

};

do some operation to trigger the event.
.......
Wait for the event to trigger
statsUpdatedEvent.WaitOne(5000, false);

then

Assert.IsFalse(serviceFaulted);


This is taken from the following link

http://www.philosophicalgeek.com/2007/12/27/easily-unit-testing-event-handlers/

Thursday, March 19, 2009

wshttpbinding - httpsys - netsh - certificates

http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2005/11/17/5628.aspx

step 1
"makecert -r -pe -n "CN=localhost" -b 01/01/2000 -e 01/01/2036 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12"

step2
httpcfg.exe set ssl -i 0.0.0.0:9091 -c "MY" -h XXXXXXXX

for vista and 2008

appid int he netsh http add sslcert is nothing but a new guid(Create one).


http://www.inventec.ch/chdh/notes/14.htm
-------------------------------------------------------------
server 2008 and vista

http://msdn.microsoft.com/en-us/library/ms733791.aspx

appid int he netsh http add sslcert is nothing but a new guid(Create one).

Wednesday, March 18, 2009

Testing email in .NET

Testing email in .NET require us a smtp server for send a pop3 to download, smtpserver is not a problem but POP3 is there are lot of products that are out there which are not free(may be a evaluation period), you can use a Exchange server(this according to me is a pain becasue of setting up AD and all) another solution might be using your inbox,but that dosent qualify as a unit test.

the simple solution is use nDumbster

http://ndumbster.sourceforge.net/default.html

Serialize and deserialize a workflow ruleset

Serailze

private void SerializeRuleSet(RuleSet ruleSet)
{
StringBuilder ruleDefinition = new StringBuilder();
WorkflowMarkupSerializer serializer = new WorkflowMarkupSerializer();

if (ruleSet != null)
{
try
{
StringWriter stringWriter = new StringWriter(ruleDefinition, CultureInfo.InvariantCulture);
XmlTextWriter writer = new XmlTextWriter(stringWriter);
serializer.Serialize(writer, ruleSet);
writer.Flush();
writer.Close();
stringWriter.Flush();
stringWriter.Close();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
else
{

}

XmlDocument rule = new XmlDocument();
rule.LoadXml(ruleDefinition.ToString());
rule.Save("c:\\message.xml");
}

Deserialize


public static RuleSet GetSampleRule(string type)
{

ruleSetXmlDefinition = GetEmbeddedTextFileContent("EsbMsgSampleRule.xml");


WorkflowMarkupSerializer serializer = new WorkflowMarkupSerializer();

StringReader stringReader = new StringReader(ruleSetXmlDefinition);
XmlTextReader reader = new XmlTextReader(stringReader);
return serializer.Deserialize(reader) as RuleSet;
}

Tuesday, March 17, 2009

Saturday, March 7, 2009

Type Converters to the rescue.

Issue:
We had a a requirement to make our property grid Read only,the out of the box propertygrid provided by the .net framework even disable the ellipses button for a collection property of my class(array...etc) so there is no other way of looking into all the collection elements.

Solution:
Create a TypeConverter class and overwrite the CanConvertTo and ConverTo methods, what i did was i Converted the array into a delimited sting and decoreated my class property with this coverter class and now in the propertyGrid is see a delimited string instead of a collection object.

the example is as follows.....