Jan 29, 2014

WCF & IIS tips

When clean WCF project is initially created and hosted on server/local IIS this might be necessary to configure:

  • On entire folder in Security Tab give rights for IIS_IUSRS control
  • In IIS on Authentication enable Forms authentication

Also if you reference 32-bit DLL's like I did with Microsoft Script Control you need to enable 32 bit applications on advanced properties of website application pool.



Jan 20, 2014

Powershell - replace text in file(s) & custom functions in separate script

PowerShell example how to replace string and use custom function.
On bottom is example that uses regex expression for replace.

."c:\Users\sinisabencetic\Dropbox\*******\Dcs5Net\dcs5net-lib.ps1"
<# AdServer root folder
#>
$devRoot = "c:\Development\DCS5Net\trunk\WebSite\Config\";
$target = $devRoot + "AppSettings.config"
<# This is syntax for calling parameter less functions#>
DisableFVB
DisableGF
<# Enable FVB config #>
(Get-Content $target) | Foreach-Object {
$_ -replace '<appSettings>',
'<appSettings><add key="FVBPortal" value="True"/>'
} | Set-Content $target

dcs5net-lib.ps1

function DisableFVB
{
<# Disable FVB config #>
<#  If exists commented remove it
#>
(Get-Content $target) | Foreach-Object {
$_ -replace '<!--<add key="FVBPortal" value="True"/>-->',
   ''
} | Set-Content $target <#
If exists uncommented remove it
#>
(Get-Content $target) | Foreach-Object {
$_ -replace '<add key="FVBPortal" value="True"/>',
   ''
} | Set-Content $target
}


This code replaces attribute value contents. It expects chars or \ in match expression and replaces it with contents of variable provided as argument of function.

function FixAppSett($pathToReport)
{
$webconfig = "c:\Development\DCS5Net\trunk\WebSite\web.config"
(Get-Content $webconfig) | Foreach-Object { $_ -replace "(<add key=`"OrdnerBerichte`" value=`")([a-zA-Z\\]+)(`"/>)","`$1$pathToReport`$3"
} | Set-Content $webconfig
}

Jan 17, 2014

Crystal Reports 13.0.2000.0 with Visual Studio 2013

Website ASP.NET 4.0 uses Crystal Reports 13.0.2000.0
They are referenced in web.config like this:

        <add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
        <add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
        <add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
        <add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
        <add assembly="CrystalDecisions.Windows.Forms, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
        <add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>-->
       
Website was created and maintained on colleague's machine.
I checked it out from source control.
Solution did not build.
Compiler could not resolve Crystal assembly:

CrystalDecisions.ReportAppServer.ClientDoc

Of course, I had to install Crystal Reports assemblies because they don't exists in bin folder.
BTW here is detail explanation where .NET compiler searches for referenced assemblies:

http://stackoverflow.com/questions/981142/dll-in-both-the-bin-and-the-gac-which-one-gets-used

I searched for Crystal assemblies here:

http://scn.sap.com/docs/DOC-7824

Make sure to download "Install executable" from first column.
You can not self-extract it, it will fail.
Right click on EXE and choose extract.
Then start setup.

Crystal will properly register both in GAC and in Visual studio.

Do NOT use MSI packages runtimes!
They will install but you will not be able to reference them. Worst thing is that you can find them in GAC and even copy. Nothing will work. Tried it. Stick to biggest package that integrates into IDE.



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

http://scn.sap.com/message/14688220#14688220




Jan 14, 2014

Web Essentials 2013

Yea it's stupid, people waited for it for ages... but I just want it to go away...
Surprisingly it took me to many seconds to find out how ...

http://blogs.msdn.com/b/webdev/archive/2013/06/28/browser-link-feature-in-visual-studio-preview-2013.aspx

Jan 13, 2014

Javascript tips & tricks


  • Coll way to join strings:


var base = 'http://acme.com',
    action = 'get',
    param = 'apple';
var fullUrl = [base,action,param].join('');
alert(fullUrl);


  • Closure ?

http://stackoverflow.com/questions/111102/how-do-javascript-closures-work

  • Private & public members in JSON

var myWidget = function(){  
      //private method declaration
    var myShow;
    //private method body
    myShow = function(){ return "I'm private!"; }
    //public method declaration
    this.Show = function Show() { alert(["I'm calling ->",myShow()].join('')); }
    //this.Show = function Show() { alert('xx'); }
}
var coolWidget = new myWidget();
//this works
coolWidget.Show();
//this does not works. It's private member!
coolWidget.myShow();
                          •  Use Console.Log() for quick debugging instead of annoying alert