mscommunity.net

Interactive mscommunity.net online activities
Signed in as anonymous | Edit Profile | Sign out | Help
in Search

Weblog :: Boris Ševo

Sporadic posts about my interests, e.g. software development (mostly .NET), technology in general and some occasional rant.

listopad 2007 - Posts

  • Hosting WCF services in IIS7 and Windows Vista

     Today I spent almost 2 hours trying to run a WCF service hosted in IIS7. After I read a lot of blog and forum posts I finally got a solution which works. Basically, you just need to do this four steps:

     Step1: Change the C:\Windows\System32\inetsrv\config\applicationHost.config file. You must add handlers section and one mimeMap tag.

    ....
    <location path="Default Web Site" overrideMode="Allow">
    <system.webServer>
    <asp />
    <handlers>
    <add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode" />
    <add name="svc-ISAPI-2.0" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
    </handlers>
     
    </system.webServer>
    </location>
    ...
    <staticContent>
    ...
    <mimeMap fileExtension=".svc" mimeType="application/octet-stream" />
    ...
    </staticContent>

    Step2: Then you should run servicemodelreg with a -i option:
          C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation>ServiceModelReg -i

    Step3: Turn a Windows Communication Foundation HTTP Activation feature on. Go to Add/Remove programs, Turn Windows Features on/off and install Windows Communication Foundation HTTP Activation (it is in a Microsoft .NET Framework 3.0 section).

    Step4: Go to IIS Manager and add new application to your web site (you must choose Add Application ... option, I also tried with a Add Virtual Directory ..., but it didn't work for me) which physical path will point to your WCF service.

     

    That's all. I hope it will help you if you run in a similar problem.
     

    Posted lis 30 2007, 07:48 by boris.sevo with 2 comment(s)
    Filed under: ,
  • CASE tools

     I'm currently working on my master thesis at FER and I'm reengineering one business application and modeling a new one with the same purpose. My mentor gave me a licence for Sybase PowerDesigner 12.0 and I'm simplly delighted with its power and ease of use. But the purpose of this post isn't to promote this tool, then ask you, which CASE tools are you using and why? Are you using one at all? If you use one, do you use it through the whole process of  software development or just for some specific parts? I'm specially interested in answers of readers from Croatia (my domicile country).

    p.s. Is there any word mentioning Microsoft CASE tool?

    Posted lis 27 2007, 11:38 by boris.sevo with 1 comment(s)
    Filed under:
  • Silverlight deployment guide

    If you are working on some Silverlight project and you need to deploy it you will maybe be interested in Silverlight Enterprise Deployment Guide (.doc).

  • Functional programming in C# - filter function

    Wikipedia defines functional programming as: programming paradigm that treats computation as the evaluation
    of the mathematical functions and avoids state and mutable data
    . This is in contrast with the imperative
    programming (including object oriented programming) style which emphasizes changes in state. Those who
    are interested in finding out what are the benefits of functional programming can read this interesting (at least
    to me :-)) blog post by Slava Akhmechet.

    Here I will show how can we mimic higher-order function in C# (I said mimic because as you probably know C#
    isn't functional language). Functions are higher-order when they can take other functions as arguments and return
    them as results. I will demonstrate how we can implement higher-order function filter in C#. To implement filter
    function as higher-order function we need to be able to pass functions as arguments. In C# we can only pass
    around objects and primitiv values. So, we have to find a way to have an object mimic the behavior of a function.
    In C# there is a special kind of object, a delegate, that can do the job. C# also has three very helpful features
    which we will need. Those are:

    • methods can be converted in delegates automatically
    • delegates can be defined in-place, where the delegates are needed
    • generics can also be applied to delegates

    First we will define a delegate (an object which will mimic the behavior of a function):

        public delegate bool Fun<a>(A n);

    Then we will define an utility class which will contain our filter function:

        class Utilities
    {
    public delegate bool Fun<a>(A n);

    public static List<T> Filter<T>(List<T> list, Fun<T> fun)
    {
    List<T> filteredList = new List<T>();
    foreach (T t in list)
    {
    if(fun(t))
    filteredList.Add(t);
    }
    return filteredList;
    }
    }

    And that's it. We have implemented higher-order filter function. We can use this function to filter numbers of various
    types (integers, floats, doubles). We can use this function to filter numbers which are less then 3, even, greater
    then some random number and many more possibilities. All this can be done using the same function which is
    defined in one place and which you can easily use in all your projects.

            public static void Main(string[] args)
    {
    List list = new List();
    list.AddRange(new int[] { 5, 2, 6, 1, 8, 7, 3, 4, 9 });

    //filter numbers less or equal to 3
    foreach (int i in Utilities.Filter(list, delegate(int n) { return n <= 3; }))
    {
    Console.WriteLine(i);
    }

    Console.WriteLine();

    //filter even numbers
    foreach (int i in
    Utilities.Filter(list, delegate(int n) { return (n % 2 == 0); }))
    {
    Console.WriteLine(i);
    }

    Console.WriteLine();

    //filter numbers greater then some random number
    Random rnd = new Random();
    int j = rnd.Next(9);
    foreach (int i in Utilities.Filter(list, delegate(int n) { return (n > j); }))
    {
    Console.WriteLine(i);
    }
    }

    <UPDATE>
    Note: I'm not suggesting that you should use this Filter function to filter some list. As Miha Markic said in his
    comment, for that purpose you should use List<T>.FindAll(Predicate<T> match method. The main purpose of
    this blog post was to demonstrate one "functional programming" concept in C# and to make an introduction to
    lambda expressions (which will probably be my next post).
    </UPDATE>

  • Weird Firefox problem - Enter username and password for "" at http://localhost

    I was working on one of mine projects and I was using Visual Studio's built in web server. Then I decided to switch to IIS5 and when I tried to run my web site in Firefox I got this weird message: Enter usename and passwod for "" at http://localhost. However, this message wasn't popping up in IE. I googled for this message and found the solution at Pete Orlogas's blog. The solution is to make some configuration changes in Firefox.
    The interesting thing is that you can find this kind of problem also if you use Safari. Take a look at this forum post.

    Posted lis 04 2007, 09:44 by boris.sevo with no comments
    Filed under:
  • Rounded corners for Web Parts in ASP.NET 2.0 using only CSS

    ASP.NET Web Parts controls are an integrated set of controls for creating web sites that enable the
    users to modify the content, appearance, and behavior of web pages directly in a browser. Although
    they are very handy controls, specially when you are building a web site which users can customize
    by their needs and preferences, they are sometimes not so friendly when you need to customize
    Web Parts layout. Few months ago I was working on a web site which has a similar purpose as
    pageflakes and I was trying to customize web parts so that they have rounded corners. Only solution
    that I found was this David Barkol's post in which he wrote: To get rounded corners you have to
    extend both the WebPartZone and WebPartChrome classes to override a few methods and basically
    add padding to the corners.
    This solution obviously works, but it is a little bit complicated. I was thinking that this can't be the
    only way to accomplish it. Yesterday, after 2 hours of playing with CSS and Web Parts I
    finally found a solution. You don't need to extend any part of Web Parts, you just need to specify few
    CSS classes and you have Web Parts with rounded corners.
    Note that this solution provides only rounded corners for left and right corners at top.

    So, here are the snippets of code.

     


    /*ASPX*/
    <asp:WebPartZone ID="Zone1" runat="server" EmptyZoneText="Drag widgets here"
             HeaderStyle-CssClass="PartZoneHeader" CssClass="PartZone"
    BorderStyle="None"
             PartStyle-CssClass="PartStyle" PartTitleStyle-CssClass="PartTitleStyle"
    PartChromeStyle-BorderColor="White" MenuPopupStyle-BackColor="#C1D4E3" MenuPopupStyle-Font-Size="10px">
                    <ZoneTemplate>
                          ... your controls
                    </ZoneTemplate>
     </asp:WebPartZone>

     


    /*CSS*/
    .PartTitleStyle {
                        background-color:#C1D4E3;
                        height:25px;
                        font-size:8px;
                        padding:0px 0px 5px 10px;
                        background-image:url(../images/boxHeaderTopLeft.gif);
                        background-repeat: no-repeat; background-position: left top; }
    .PartTitleStyle table {
                       background-image:url(../images/boxHeaderTopRight.gif);
                       background-repeat: no-repeat;
                       background-position: right top;}

    .PartTitleStyle table tr td {
                     padding:10px 10px 0 10px;}
    .PartTitleStyle table tr td span {
                     font-size:12px;
                     font-weight:bold;
                     background-color:#C1D4E3;
                     padding-right: -10px; }

    .PartStyle {
                    background-color: #F8F8f0; 
                    border: solid 1px #DDDDDD; }
    .PartZone {
                   border:dashed 1px #DDDDDD; }
    .PartZoneHeader {
                  height:0px;
                  display:none; }





     






Powered by Community Server (Commercial Edition), by Telligent Systems