Thursday, August 27, 2009

The application domain or application pool is currently running version 4.0 or later of the .NET Framework. This can occur if IIS settings have been set to 4.0 or later for this Web application

Error :

 

“The application domain or application pool is currently running version 4.0 or later of the .NET Framework. This can occur if IIS settings have been set to 4.0 or later for this Web application, or if you are using version 4.0 or later of the ASP.NET Web Development Server. The <compilation> element in the Web.config file for this Web application does not contain the required 'targetFrameworkMoniker' attribute for this version of the .NET Framework (for example, '<compilation targetFrameworkMoniker=".NETFramework,Version=v4.0">'). Update the Web.config file with this attribute, or configure the Web application to use a different version of the .NET Framework.”

 

 

Solution :

 

Go to the web.config and set the targetframeworkmoniker as below

 

<compilation debug="true"   targetFrameworkMoniker=".NETFramework,Version=v4.0" />

 

Hope this helps

 

 

A name was started with an invalid character - WCF 4.0

The below error may lead the developer to confusion.

A name was started with an invalid character. Error processing resource 'http://localhost:81/MyWCFHello/MyHelloWcfApp.Servi...
<%@ ServiceHost Service="MyHelloWcfApp.Service1" %>
-^


Actually problem lies in your IISAdmin.

Follow the steps to resolve the same.
1. Open Inetmgr
2. Select your website
3. right click to properties -> Select ASP.Net tab
4. Change the version to ASP.Net 4.0

Hope this helps

Tuesday, August 25, 2009

WCF 4.0 Beta - Service Configuration Enhancements

 

Introduction

 

The .Net Framework 4.0 beta1 has shown lots of improvements in the area of Windows Communication Foundation. The new version has simplified the developer experience. It also provides us a rich integration with Workflow foundation. On top of all the improvements done one thing stands apart.

That is nothing but easier configuration of your services.

 

List of Configuration Improvements

1.      File less activation

2.      Default Endpoint

3.      Default Protocol Mapping

4.      Default Binding Configurations

5.      Default Behavior Configurations

 

File – less  Activation

 

In .Net 3.5 we were using .svc files to expose the services. We can configure the .svc extension by using IIS filter with little complexity.  Now .Net 4.0 introduces file-less activation for the services. What they mean by this is “There is no more .svc files”.

Following configuration will set you free from .svc files.

<configuration>

  <system.serviceModel>

    <serviceHostingEnvironment>

      <serviceActivations>

        <add relativeAddress="/MyPath" service="MyService"/>

      </serviceActivations>

    </serviceHostingEnvironment>

  </system.serviceModel>

</configuration>

 

Now we can browse the site like http://localhost/MyIISSite/MyPath.

 

Isn’t it cool ?

 

Default Endpoint

 

In WCF 3.5 / 3.0 if we host WCF service without endpoints it will throw error. Isn’t it ?

In .net 4.0 it is no longer an issue. In the runtime, default endpoints will be added

When the open method of ServiceHost is called, it will check the configuration file for the number of endpoints. If it is zero it will call the public method AddDefaultEndPoints to add the endpoint. One endpoint will be added per base address per service.

 

Default Protocol Mapping

 

WCF 4.0 allows you to map the transport protocol schemes and the WCF bindings. There are two ways to map the same. One in machine.config and the other by overriding  application configuration file.

In Machine.Config

    <protocolMapping>

        <add scheme="http" binding="basicHttpBinding"/>

        <add scheme="net.tcp" binding="netTcpBinding"/>

        <add scheme="net.pipe" binding="netNamedPipeBinding"/>

        <add scheme="net.msmq" binding="netMsmqBinding"/>

    </protocolMapping>

 

In App.Config

<system.serviceModel>

    <protocolMapping>

      <add scheme="http" binding="wsHttpBinding"

           bindingConfiguration="secureConfiguration"/>

    </protocolMapping>

  </system.serviceModel>

 

This will be useful if  in my application I am always going to use wshttpbinding rather than basic httpbinding for http protocol.

 

 

Default Binding Configurations

 

In WCF 3.5/3.0 we will define a named binding configuration which will be used against any endpoints. The problem here is we need to specify the configuration properly in the endpoints which may be cumbersome when we have more endpoints.

In WCF 4.0 we no longer have the name attribute. This will be considered as default and used by all default endpoints

<configuration>

  <system.serviceModel>

    <bindings>

      <basicHttpBinding>

        <binding messageEncoding="Mtom"> <!—No Name attribute -->

        </binding>

      </basicHttpBinding>

    </bindings>

  </system.serviceModel>

</configuration>

 

Default Behavior Configurations

 

Similar to Binding Configurations , WCF 4.0 supports default behavior Configurations.

<configuration>

  <system.serviceModel>

    <behaviors>

      <serviceBehaviors>

        <behavior> <!-- notice no name attribute -->

          <serviceMetadata httpGetEnabled="true"/>

        </behavior>

      </serviceBehaviors>

    </behaviors>

  </system.serviceModel>

</configuration>

 

Conclusion

 

WCF 4.0 provides more features apart from configuration enhancements which will reduce the developer burden as well as provide more opportunities to use WCF in new environments.

The configuration changes made in WCF 4.0 is for sure to make a difference to the developer / IT department world as they are the more concerned users.

Tuesday, August 4, 2009

command line proxy setting in vista

Hi,

To set proxy details through command line do the following

1. Open command prompt as administrator
2. netsh winhttp set proxy proxy-server="give ur server name" bypass-list="ur list"

To reset

netsh winhttp reset proxy


HTH

MJ

Monday, August 3, 2009

WCF Service throws "Page Cannot be displayed"

Hi,

When you create a website for your WCF services and it throws "Page cannot be displayed, open inet mgr -> right click on the site -> properties -> Asp.net change the version fron ASP.Net 1.1 to 2.0.


HTH

MJ