Tuesday, December 29, 2009

How to Fix Error 1606: Could not access network location

This error often comes while installing some software.
Scenario A: You are getting error 1606 saying "Could not access network location [Some environment variable with % in it]..." then these links may help you solve the issue.
http://support.microsoft.com/default.aspx/kb/330766
and
http://support.microsoft.com/kb/256986/


Scenario B: You are getting error 1606 saying it cannot access internet location. But you can download same file using internet explorer,
1. Try hitting 'Retry' button. You may be in luck.
2. Not solved yet? Most probably you are behind proxy server. To solve this issue, go to Control Panel -> Internet Options -> Connections -> LAN Settings. What do you see? Is "Automatic Detect Setting" checked? If yes then uncheck it and see if your installation works. If it still doesn't work, contact your network administrator and manually provide proxy IP and Port in the LAN Settings of Internet Options.

Still not working? Please find solution and put your solution here :)

Tuesday, September 15, 2009

Get Exception without being in catch block

In .NET, when exception is thrown, the exception passed though the call stacks. While debugging you may not be inside the catch block (may be in finally) or you may not have catch block at all. But if you want to still see what exception occurred then just go to 'watch' window in visual studio and type '$exception' and you will get the exception as it is.

Happy Debugging!

ps: I got this trick free from my ex-colleague Manish

Sunday, August 09, 2009

Syntax Highlighter on Blogger

At last, I got source Syntax Highlighter on my blog. Adding script in Gadget didn't work for me as I couldn't add <link> tag in HTML/Javascript gadget. Then I tried adding script in template itself and it works like a charm :)


function test() : String
{
return 10;
}

Friday, July 31, 2009

Interoperability Problem with WCF Web Service Solved

I've spoken to many of my friends about how WCF services do not work with older system (and some time modern system like Flex). Well it is my bad that I didn't search for a solution. Sorry! I didn't search for the 'problem' itself.
Now, when I was generating WSDL file from my .svc, I good a strange thought. I didn't want to give 1 WSDS and 3 xsd imports (yeah 3 xsd:import.. see your WSDL), I wanted to flatten it a bit and give single WSDL. While searching for the solution, I found this article by Christain Weyer. It revealed to me that lack of 'single and complete' WSDL file is the problem for old consumers. I highly encourage you to visit his blog and see the solution by yourself.

Friday, July 24, 2009

Wix with util:User

Wix installer is my latest adventure. It's good but few thing may leave you scratching you head for hours. One of them is user right assignment.
I wanted to give ASPNET user some access right to my MSMQ. So defining user went like this (after that I gave permission):
<util:User Id="aspnet" Name="ASPNET" / >
Everything worked fine, until my product was uninstalled (for testing... in real life people will love it). Uninstaller 'owned' the ASPNET user and deleted while uninstalling the product. Leaving system corrupt. I had to rescue my system's dangled processes by re-registering ASP.NET. And found (hit and try) this is the right way:
<util:User Id="aspnet" Name="ASPNET" CreateUser="no" UpdateIfExists="no" />
I don't know much about it but this worked and 'happy ending' is all I want at the starting of my weekends :)
Happy Weekends 2 u 2!

Thursday, July 16, 2009

Don't flush the Session after an exception occurs

I recently moved my all 'flush' at central location i.e. on session closed. And I close session in "finally" block of the code, to ensure that it really gets closed (not really).
So code would look like

try
{
//Use Session like never used before
}
finally
{
NhibernateSessionManager.CloseCurrentSession();
//closes session that was assigned to the thread
}

CloseCurrentSession in NhibernateSessionManager would look like this,

CloseCurrentSession()
{
ISession session = GetCurrentContextSession();
if(session != null && session.IsOpen)
{
session.Flush(); //evil is here
session.Close();
RemoveCurrentContextSession();
}
}


I was proud of this solution until I got into a database exception in my main code (which happens rarely after I write millions of lines of code).
If any such exception occurred and you try to flush, you will be delighted with another exception when you use session.Flush() It says "don't flush the Session after an exception occurs". For undisclosed reason, I couldn't use autoflush (reserved for next blog may be ;)

I believe there are alternate solutions but I as I told, I am lazy (like any other ORM), so I reverted back to my 'Flush manually' everytime when you make some entity dirty. Pretty shitty stuff huh???

Anyways, thanks for reading the blog even though the title "Don't flush the Session after an exception occurs" tells it all and inside matter is just ramblings.

Tuesday, June 16, 2009

Caching Problem with XMLHttpRequest

Using XMLHttpReuest is fun. But if you have just started the fun, you should know this.
IE has a known issue which caches the data if request is same. It's real mystery for me why Microsoft ended up with such default behavior for functionality which is responsible to load dynamic data. But as we have to live with it, here is a small hack which will turn off the caching for that page. You need to add this two lines in your HTML Head tag.

< meta equiv="Pragma" content="no-cache"/>
< meta http-equiv="Expires" content="-1" />

Solution Source: http://en.wikipedia.org/wiki/XMLHttpRequest#Workaround

Tuesday, May 12, 2009

About CProxyType*_NHibernate_ProxyINHibernateProxy_System_Runtime_SerializationISerializable2

Are you getting this exception while debugging on Visual Studio?
CProxyType*ENTITY_FULL_NAME*_NHibernate_ProxyINHibernateProxy_System_Runtime_SerializationISerializable2

Are you worried? Are you banging your head? Don't worry now, I have a solution for you! Follow as described below (step by step):
Step 1. Stop Debugging. Sometime NHibernate doesn't load lazy loaded entity during debug (specially in 'watch' or 'quick watch'). Test your code at runtime like Message Pop-up box or Console.Write etc
Step 2. Take a cup of tea.

Sunday, March 01, 2009

Software Performance Consideration while Coding

Some tips when you write a code (an excerpt from Eric Lippert's Blog):
  • Set meaningful, measurable, customer-focused goals.
  • Write the code to be as clear and correct as possible.
  • Carefully measure your performance against your goals.
  • Did you meet your goal? Great! Don't waste any time on performance analysis. Spend your valuable time on features, documentation, bug fixing, robustness, security, whatever.
  • If you did not meet your goal, use tools to discover what the worst-performing fixable thing is, and fix it.

It tells how to walk on a blur trade-off between ‘correct’ and ‘preferment’ code. Success in the industry depends upon lot other factor and people just want workable code. Unnecessarily fast code doesn’t create any value of customer and time taken to think about or writing code is merely a waste in this hurry-burry software industry. Popularity of framework like .NET and Java are greatest example of it. Even the master, Donald Knuth, has said:
"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil."