The service '/Sample/SampleService.svc' cannot be activated due to an exception during compilation. The exception message is: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.

by Michel 17. September 2009 13:55

Getting the error below in your eventlog and do you have multiple identities for your website (i.e: sample.domain.tld & localhost)?

Event Type:        Error
Event Source:     System.ServiceModel 3.0.0.0
Event Category: WebHost
Event ID:           3
Date:                 16-9-2009
Time:                 8:46:15
User:                  NT AUTHORITY\NETWORK SERVICE
Computer:          COMPUTERNAME
Description:
WebHost failed to process a request.
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/40535505
Exception: System.ServiceModel.ServiceActivationException: The service '/Sample/SampleService.svc' cannot be activated due to an exception during compilation.  The exception message is: This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection.

You could solve this issue by adding the following config section to your web.config:

    <system.serviceModel>
        ...
        <serviceHostingEnvironment>
            <baseAddressPrefixFilters>
                <add prefix="http://sample.domain.tld/Sample/"/>
            </baseAddressPrefixFilters>
        </serviceHostingEnvironment>
        ...
    </system.serviceModel>

Tags:

C# | Debug | .Net | WCF

Performance testing of Dictionary, List and HashSet in the rebound.

by Michel 1. June 2009 16:52

After reading the following blog post I became curious if I could reproduce the same behavior on the HashSet.

So what did I do. I tested an List, Dictionary and a HashSet.

For all types I ran the test five times. Every run I added 10.000 items. Besides adding items to the collection I checked if the collection contained the item. This test I did 5 times with 10.000 items in the collection to check.

The figure show the result for adding the items to the different collections, and checking if the collection contained the item.

image

The horizontal line shows the amount of milliseconds to Add or check if the item contains in the collection. Without having a look at the numbers it is obvious that the Contains method on the List collections is slower than the Contains method on the HashSet or the Containskey on a Dictionary. The difference can be explained because the HashSet collection as well as the Dictionary collection uses a hashing algorithm to quickly retrieve data from it’s collection.

To get an better view on the time it takes to add an item to the different collection and see which collection is faster for retrieving the data, I removed the data duration data from the List Contains method is the graph below.

image

The graph shows that the HashSet is slower to do an lookup than the Dictionary. To be precise, it took the double amount of time to check every single item if it was in the collection. For adding stuff the List collection was the absolute winner. If we compare both structures who uses the a hashing table, the HashSet was the absolute winner. It took the Dictionary object 37,5% longer to add 10.000 items.

Even Stian Sveen got a lot of complains about his post. I got exactly the same result as he did. Until somebody else proven otherwise I believe that a Dictionary collection is faster for retrieving items than a HashSet when the collection contains 10.000 items.

 

 

 

download the test project here! DictionaryPerformance.rar

Tags:

Error Logging Modules and Handlers for ASP.NET (elmah)

by michel 18. May 2009 20:37

A while ago a friend a my promoted ELMAH via Live messenger, since then I am a FAN! ELMAH (Error Logging Modules and Handlers) is an application-wide error logging facility that is completely pluggable. It can be dynamically added to a running ASP.NET web application, or even all ASP.NET web applications on a machine, without any need for re-compilation or re-deployment.

Exceptions caught by ELMAH can be stored in memory, loose xml, VistaDb, Access, SQLLite, Oracle, MS Sql, or directly send by email. Storage- & mail configuration is done via the web.config.

The source of ELMAH is available and under the Apache License 2.0.
More info @: http://code.google.com/p/elmah/

In this post I’ll do an new implementation of the ELMAH Errorlog class to facilitate the MS SQL error logging with MOSS elevated privileges to solve the following problem.

The RunWithElevatedPrivilegesmethod will executes the specified code with Full Control rights even if the user does not otherwise have Full Control. In the MOSS environment it will execute the code under control of the the Application Pool Identity User. Implementing this method is really easy:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
   // put your code in here :)
});

The first step is to setup a class in Visual Studio (my example SqlErrorLogWEP (Sql ErrorLog With Elevated Privileges) and implement the abstract Errorlog class.

namespace Elmah
{
    using System;

    class SqlErrorLogWEP : ErrorLog
    {
        public override string Log(Error error)
        {
            throw new NotImplementedException();
        }

        public override ErrorLogEntry GetError(string id)
        {
            throw new NotImplementedException();
        }

        public override int GetErrors(int pageIndex, int pageSize, IList errorEntryList)
        {
            throw new NotImplementedException();
        }
    }
}

Because our SqlErrorLogWEP looks really for 99,9% like the classic SqlErrorLog class. In fact our class will act as a wrapper to implement the MOSS elevated privileges functionality for the SqlErrorLog class. To do this our constructor will initialize the (classic) SqlError log class and use the private sqlErrror object to perform the database logging. The above methods which still need to be implemented will use the sqlError object to do the work.

Our new class will look like this:

namespace Elmah
{
    using System;
    using System.Text;
    using System.Collections;
    using Microsoft.SharePoint;
    

    class SqlErrorLogWEP : ErrorLog
    {
        SqlErrorLog sqlErrorLog;

        public SqlErrorLogWEP(IDictionary config)
        {
            sqlErrorLog = new SqlErrorLog(config);
        }

        public SqlErrorLogWEP(string connectionString)
        {
            sqlErrorLog = new SqlErrorLog(connectionString);
        }

        public override string Log(Error error)
        {
            string retVal = String.Empty;
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                retVal = sqlErrorLog.Log(error);
            });

            return retVal;
        }

        public override ErrorLogEntry GetError(string id)
        {
            ErrorLogEntry retVal = default(ErrorLogEntry);

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                retVal = sqlErrorLog.GetError(id);
            });

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
               // put your code in here :)
            });
            return retVal;
        }

        public override int GetErrors(int pageIndex, int pageSize, System.Collections.IList errorEntryList)
        {
            int retVal = -1;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                // put your code overhere 
            });

            return retVal;
        }
    }
}

Pro’s  / Con’s
Pro’s: Implementation in 2 minutes, completely ELMAH proof, extendable.
Con’s: Instead of only deploying the ELMAH assembly you will have an extra reference to the Microosoft.SharePoint assembly.

Tags: , , ,

.Net | C# | Microsoft | SharePoint | Tooling

New version Ajax Control Toolkit (.NET 3.5)

by michel 18. May 2009 19:12

asp.net Ajax The AJAX Control Toolkit is a joint project between the community and Microsoft. Built upon the ASP.NET 3.5 AJAX Extensions, the Toolkit aims to be the biggest and best collection of web-client components available.
The Toolkit addresses three needs. First it gives website developers a place to get components to make their web applications spring to life, second it gives a set of great examples for those wishing to write client-side code, and third it is a place for the best script developers to get their work highlighted.

Version number: 3.0.30512

info: here!

Tags: , , ,

Microsoft | .Net

BizTalk 2009 Deep Dive Training

by Michel 10. May 2009 09:43

As with every new release of Microsoft BizTalk, InfoSupport is setting up a DeepDive training track with a trainer coming from Redmond. I bet it is Robert or John Callaway from Quicklearn. For everybody who is interested in BizTalk these DeepDives are the place to be. 

Info: 
BizTalk 2009 Developer Deep Dive (5 dagen)
After five extended-hour days of training and intensive labs, Deep Dive attendees will leave prepared with the advanced skills required to build complete enterprise-level SOA and integration solutions using BizTalk 2009. Deep Dive attendees are guaranteed to be challenged as they use advanced BizTalk techniques to build a complex integration solution.
You can choose to complete labs using BizTalk 2006 R2, or use the latest features of BizTalk 2009, including updates for Hyper-V, improved clustering capabilities, and the enhanced BAM, EDI, and ESB Guidance 2.0!
Inschrijven en meer informatie:

Tags:

Microsoft

Welcome to BlogEngine.NET 1.5.0

by Administrator 2. April 2009 08:00

If you see this post it means that BlogEngine.NET 1.5.0 is running and the hard part of creating your own blog is done. There is only a few things left to do.

Write Permissions

To be able to log in to the blog and writing posts, you need to enable write permissions on the App_Data folder. If you’re blog is hosted at a hosting provider, you can either log into your account’s admin page or call the support. You need write permissions on the App_Data folder because all posts, comments, and blog attachments are saved as XML files and placed in the App_Data folder. 

If you wish to use a database to to store your blog data, we still encourage you to enable this write access for an images you may wish to store for your blog posts.  If you are interested in using Microsoft SQL Server, MySQL, VistaDB, or other databases, please see the BlogEngine wiki to get started.

Security

When you've got write permissions to the App_Data folder, you need to change the username and password. Find the sign-in link located either at the bottom or top of the page depending on your current theme and click it. Now enter "admin" in both the username and password fields and click the button. You will now see an admin menu appear. It has a link to the "Users" admin page. From there you can change the username and password.  Passwords are hashed by default so if you lose your password, please see the BlogEngine wiki for information on recovery.

Configuration and Profile

Now that you have your blog secured, take a look through the settings and give your new blog a title.  BlogEngine.NET 1.4 is set up to take full advantage of of many semantic formats and technologies such as FOAF, SIOC and APML. It means that the content stored in your BlogEngine.NET installation will be fully portable and auto-discoverable.  Be sure to fill in your author profile to take better advantage of this.

Themes and Widgets

One last thing to consider is customizing the look of your blog.  We have a few themes available right out of the box including two fully setup to use our new widget framework.  The widget framework allows drop and drag placement on your side bar as well as editing and configuration right in the widget while you are logged in.  Be sure to check out our home page for more theme choices and downloadable widgets to add to your blog.

On the web

You can find BlogEngine.NET on the official website. Here you'll find tutorials, documentation, tips and tricks and much more. The ongoing development of BlogEngine.NET can be followed at CodePlex where the daily builds will be published for anyone to download.

Good luck and happy writing.

The BlogEngine.NET team

Tags: ,

1234567890 Day

by Michel 13. February 2009 12:13

More info: here!

Tags: ,

Fun

This version of the Enterprise Library cannot be installed side-by-side with version 4.0. Please uninstall Enterprise Library v4.0 and try again

by michel 3. February 2009 17:21

Getting the following error after uninstalling version 4.0?

This version of the Enterprise Library cannot be installed side-by-side with version 4.0. Please uninstall Enterprise Library v4.0 and try again

Try to remove the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Enterprise Library v4

Tags:

New SharePoint training @ Up The Ramp

by michel 3. February 2009 07:18

After part 1, part 2 has just been release before the weekend. I have to admit that I’m not completely ready with part one yet :)

What Is Ramp Up?
Ramp Up is a free, online, community-based learning program, with a number of different tracks that will help you build your portfolio of professional development skills. Ramp Up has a solid foundation of premium technical content from subject-matter gurus, and provides easy-to-access content in a variety of forms that guide you in learning the important skills. Join Ramp Up (it's free!) and help advance your career - click on a track now to start!


The following five SharePoint tracks for Developers are available at Ramp Up – Part 2:

Level 1: Page Navigation
Did you know that you can integrate your application into SharePoint’s navigation? This topic looks at how SharePoint pages are arranged into web sites. Menus such as the site actions menu, the top navigation bar menu and the edit control block menu are explained. It shows how the menus in SharePoint can be updated so that a web site built on SharePoint can be customized.

Level 2: Page Branding
Did you know that you can completely brand a SharePoint site to look like your existing web? Web applications need design and SharePoint allows for this using master pages, cascading style sheets and themes. This topic walks through how to apply these artifacts to a SharePoint site and covers the process for modifying them to achieve a web site design in SharePoint.

Level 3: Web Services
Did you know that SharePoint developers have access to SharePoint list data using built in Web Services? SharePoint allows access using code running on the SharePoint server machine and also access using web services. This topic covers use of some of the simple web services provided by SharePoint and it also shows how to create a new web service on a SharePoint machine.

Level 4: Custom Content Types
Did you know that SharePoint developers can implement different behaviors for different document types? Content types define what documents or other content types are used in SharePoint document libraries. Content types can have several SharePoint aspects associated with them including custom menus and custom processing. This topic shows how to create a custom content type and how to associate an event handler with the new content type to do data validation.

Level 5: User Management
Did you know that you don’t have to write code to manage web site users in SharePoint? SharePoint allows for end user site creation and when a user creates a site they can also manage the user permissions on that site. This topic shows how some aspects of user management are handled in SharePoint including how you can audit activities that users do and show different data depending on the role a user belongs to.

Btw: Next week MOSS Administration training in U2U  Brussels, anybody else?

Tags: , , , ,

SharePoint | Microsoft

Webservice: The test form is only available for requests from the local machine

by michel 14. January 2009 13:30

Receiving the the above message while trying to test your .NET web service remotely? Try to add the follwing xml snippet in the right place of your web.config file.

<system.web>
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
</system.web>

 

happy coding :)

Tags: , , ,

Debug | .Net

About the author

Michel TolMy name is Michel Tol. I'm a developer specialized in .NET technologies. Mainly focussing on SharePoint Technologies and web development. I am Certified Technology Specialist for MOSS 2007 -  Configuration, .Net Framework 2.0 - Web applications and Biztalk Server 2006 - Custom Applications.

View Michel Tol's profile on LinkedIn

  

E-mail me Send mail

Page List