Hello, Welcome to my blog. If you like feel free to refer others

Thursday, 15 May 2014

Difference between Lamda expression and LINQ query

Each style has their pros and cons. Query syntax is nicer when it comes to joins and it has the useful letkeyword that makes creating temporary variables inside a query easy.
Fluent syntax on the other hand has a lot more methods and operations that aren't exposed through the query syntax. Also since they are just extension methods you can write your own.
I have found that every time I start writing a LINQ statement using the query syntax I end up having to put it in parenthesis and fall back to using fluent LINQ extension methods. Query syntax just doesn't have enough features to use by itself.

There are some LINQ extension methods which do not have counterparts in LINQ query expressions, and will require the use of Lambda Expressions. A good example is Enumerable.ToLookup - if you want to create an ILookup, you need to use lambdas to generate this

Tuesday, 13 May 2014

Programatically setting up Physical Path Credential on IIS server for a virtual directoty

Below mentioned function will do the same for you. But only thing you need to do add the reference of Microsoft.Web.Administration dll on your project(

private void SetPhysicalPathCredential(string virDirName)
                if (!String.IsNullOrEmpty(physicalPathCredentialUserDomain) && !String.IsNullOrEmpty(physicalPathCredentialUserUserName) && !String.IsNullOrEmpty(physicalPathCredentialUserPassword))
                    using (ServerManager manager = new ServerManager())
                        Site defaultSite = manager.Sites["Default Web Site"];

                        // Read the data back from the updated configuration system, 
                        // then modify the Physical Path credential.
                        Application apps = manager.Sites["Default Web Site"].Applications["/" + virDirName];
                        VirtualDirectory appDir = apps.VirtualDirectories[0];
                        LogMessage("Setting up Physical Path Credential: " + virDirName);
                        appDir["userName"] = physicalPathCredentialUserDomain + "\\" + physicalPathCredentialUserUserName;
                        appDir["password"] = physicalPathCredentialUserPassword;
                        LogMessage("Successfully set up Physical Path Credential");
            catch (Exception e)
                LogMessage("ERROR: Error Setting up Physical Path Credential " + virDirName);
                throw e;

Windows Installer error like while running light.exe from WiX

Unregister vbscript.dll and jscript.dll from HKEY_CURRENT_USER to resolve this error:

1. Click on the Start menu, choose Run, type cmd and click OK
2. To unregister the VBScript engine, run this command:  reg delete "HKCU\SOFTWARE\Classes\CLSID\{B54F3741-5B07-11CF-A4B0-00AA004A55E8}" /f
3. To unregister the VBScript engine on a 64-bit OS, run this command:  reg delete "HKCU\SOFTWARE\Classes\Wow6432Node\CLSID\{B54F3741-5B07-11CF-A4B0-00AA004A55E8}" /f
4. To unregister the JScript engine, run this command: reg delete "HKCU\SOFTWARE\Classes\CLSID\{F414C260-6AC0-11CF-B6D1-00AA00BBBB58}" /f

5. To unregister the JScript engine on a 64-bit OS, run this command: reg delete "HKCU\SOFTWARE\Classes\Wow6432Node\CLSID\{F414C260-6AC0-11CF-B6D1-00AA00BBBB58}" /f

So here you just need to do depending your OS version(32bit/64bit) you need to run the appropriate command.

Once I did that, my build started working as expected.  I still do not know how this information ended up in HKEY_CURRENT_USER on my system, particularly because the same build worked correctly on the same machine a couple of days ago.  However, I am now back into a state where I can build successfully, and I know of a possible workaround to try if I end up with similar build issues in the future.

Hope this information will everyone who face this issue...... :)

Happy learning.......................................