in

Community Blogs

Blogs of different SQL/Developers Community Members

This Blog

Syndication

DamirDobric

veljača 2010 - Posts

  • The best of WCF 4.0 and WF 4.0

    At March 18th 2010 at Microsoft in Bad Homburg (Frankfurt area) I will give an overview of most important new features of upcoming WCF 4.0 and WF 4.0. The talk will be covered in context of .NET User Group Frankfurt am Main.
    Please feel invited all of you software architects and developers who leverage .NET technologies to build none trivial enterprise application for Windows platform.
    The session will take two hours at least of scheduled official part. After that we will step into none official part in legendary Bravery few hundred meters out of MS office. Please follow the official page of the .NET Group Frankfurt  for detailed schedule.

     

    Here is the agenda.

    •Simplified Configuration

    •File-Less Activation

    •Multiple Site Bindings

    •Standard Endpoints

    •Service Discovery

    •Routing Service

    •Workflow Services

    Optional (depending on time)

    •AppFabric

    •REST Improvements

    If anybody thinks, there would be something important I missed above, please let me know.

    Hope to see you there.

     

    Damir

  • How to enable multiple site bindings in WCF 4.0

    This post describes shortly how to enable multiple site bindings in WCF 4.0. Open IIS 7 Manager and create new site. Add two bindings to the site like shown in the picture below:

    image
    After that either configure your DNS or change host file %SYSTEM%\System32\drivers\etc\hosts like:


    127.0.0.1    sample1
    127.0.0.1    sample2

    When you now browse now for the service page by http://sample1/MyService.svc or http://sample2/MyService.svc you should get following error:

    This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'.
    Parameter name: item

    To make this working open the service’s config file and add following in the serviceModel element:

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

    That’s all…

    Posted vlj 28 2010, 01:00 by anonymous
    Filed under: ,
  • WCF 4.0 file-less activation error: ServiceHost only supports class service types.

    When working with WCF 4.0 and File-Less Service Activation you may get following error:

    ServiceHost only supports class service types.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentException: ServiceHost only supports class service types.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

     

    This scaring and possibly nothing saying error has very simple solution. I have following service:

    public class MyService : IMyService


    I used following configuration, which tryies to activate the service contract.

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true">
          <serviceActivations>
            <add relativeAddress="VirtualSvc.svc"
                
    service="Daenet.NetFx40.RoutingHost.IMyService" />
          </serviceActivations>
    </serviceHostingEnvironment>

     

    File Less service activation however requires the service class name and NOT the contract name. Here is the solution:

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true">
          <serviceActivations>
            <add relativeAddress="VirtualSvc.svc"
                
    service="Daenet.NetFx40.RoutingHost.MyService" />
          </serviceActivations>
    </serviceHostingEnvironment>

    Posted vlj 25 2010, 11:12 by anonymous
    Filed under: ,
  • Standard Endpoints and MexBindings

    WCF 4.0 provides few so called standard endpoints:

    WorkflowControlEndpointElement
    ServiceMetadataEndpointElement
    AnnouncementEndpointElement
    UdpDiscoveryEndpointElement : DiscoveryEndpointElement
    DynamicEndpointElement

    They can be used to add some specific features to service. For example udpDiscoveryEndpoint enables add-hoc discovery of the service. This endpoint according to specification provides discovery of the service address. Unfortunately, this does not provide information about the binding and other service policies. To make this happen, there is mexEndpoint which enables metadata exchange. The mexEndpoint provides following bindings:

    MexHttpBindingElement, MexHttpsBindingElement, MexNamedPipeBindingElement and MexTcpBindingElement.

    Here is one example, which enables discovery of address (udpDiscovery) and whole binding with policies (mex):

    <services>

          <service name="Daenet.DNetfx40Discovery.SampleService">

            <endpoint name="Daenet.DNetfx40Discovery.ISampleService" binding="wsHttpBinding" contract="Daenet.DNetfx40Discovery.ISampleService" />     

     

           <endpoint kind="udpDiscoveryEndpoint"/>

     

           <endpoint kind = "mexEndpoint" address = "MEX" binding = "mexTcpBinding" />

          </service>

        </services>

  • Samples for WF 4.0 and WCF 4.0 Release Candidate

    Posted vlj 21 2010, 11:54 by anonymous
    Filed under:
  • Uninstalling of AppFabric Beta 1

    If you have installed the AppFabric beta 1, and want to install VS 2010 RC, note that you have to uninstall AppFabric BETA 1 before installing of VS RC bits.
    This is NOT documented in installation documentation of VS 2010 BETA 1. AppFabric BETA 1 is buld with dependency to .NET 40 BETA 1 which is build 4 v4.0.21006. The new version of .NET 4.0 is build v4.0.30128.

    When uninstalling AppFabric setup looks for the old version of .NET 40 BETA 1 which is renamed as old_4 v4.0.21006. The exact dependency of AppFabric Beta 1 is a dependency on the presence on these .NET Framework 4 configuration files:

    1. %SystemRoot%\Microsoft.NET\Framework[64]\v4.0.21006\config\machine.config
    2. %SystemRoot%\Microsoft.NET\Framework[64]\v4.0.21006\config\web.config

    To be sure that this cause the setup to fail uninstall process grab out the log file %systemroot%:\Windows\Logs\CBS\CBS.LOG
    You will find there following:

    Info: Loading configuration: C:\Windows\Microsoft.NET\Framework64\v4.0.21006\config\machine.config
    Error: Failed to load configuration.
    Error: Xml parse error 0x800c0006: The system cannot locate the object specified.


    Solution:
    To avoid this problem, uninstall AppFabric Beta 1 before uninstalling .NET Framework 4 v4.0.21006. Assuming that you are reading this you probably already uninstalled .NET BETA 1 :(

    So, to work around this problem if .NET Framework 4 v4.0.21006 was already removed, create the machine.config and web.config files in the old .NET Framework 4 location by copying from new .NET Framework 4 location. I simply have copied all existing config of v4.0.30128 to .4 v4.0.21006.
    After that unsinstall AppFabric and restart the machine.

    Then open applicationHost.config file of IIS 7 and remove following attrubutes from all apps which have it defined: "serviceAutoStartMode" and "previouslyEnabledProtocols
    These attributes are in ther if you have used “Always Running” feature of AppFabric.

    Thanks to AppFabric team which helped me solving this issue. Failed under.

  • First VS 2010 RC Patch for Brave Hearths

    If you are one of brave VS 2010 starters, you might notice that the VS IDE just diaper frequently  in front of your eyes.
    This happens if you are looking to critically focused on the screen or if you type something like MyClass<TypeHereAnything> or, or,..
    Anyhow, there is a help patch for this.

    :)

  • Visual Studio 2010 RC Setup does not start on Windows 7 - x64

    I tried to install Visual Studio Release Candidate 2010  on one one Windows 7 - 64 – Bit machines. Unfortunately the setup just does not start. If I try to start the same setup (to be sure that hash is correct) from other Win7 64-Bit machine it starts successfully.

    Note that my machine which cannot start the setup had previously installed VS 2010 Beta 2. I did my best to uninstall bunch of components in the right order. But, who knows.

    To workaround this problem I started the setup.exe in Setup folder and not setup.exe in the root of installation media (ISO, DVD or whatever you have). The setup.exe has been started elevated.

    This issue is documented at Microsoft connect site: https://connect.microsoft.com/VisualStudio/feedback/details/533209/visual-studio-2010-rc-setup-does-not-start-on-windows-7-x64

  • File-less activation of Routing Service

    while using File-Less activation feature to activate RoutingService you may experience an error.

    To make sure that RoutingService works at all, I added RoutingService.svc file which hosts RoutingService:

    <%@ ServiceHost Language="C#" Debug="true" Service="System.ServiceModel.Routing.RoutingService, System.ServiceModel.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"%>


    When I open the page /RoutingService.svc the WSDL description is shown as expected.

    However, when I add file-less activation (se below), the error appears, when trying to open RoutingService.svc (delete this file when using file-less activation):

    Here is the configuration:

    <add relativeAddress="RoutingService2.svc" service="System.ServiceModel.Routing.RoutingService" />

    .. and these are errors:

    "The resource cannot be found" OR

    The type 'System.ServiceModel.Routing.RoutingService', provided as the Service attribute value in the ServiceHost directive could not be found.

    Following configuration solves the problem:

    <add relativeAddress="RoutingService.svc" service="System.ServiceModel.Routing.RoutingService, System.ServiceModel.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

  • WinSpool.Drv SetPort function fails

    When calling SetPort function implemented in WinSpool.Drv within .NET, you may get following error:

    0x0000007C - The system call level is not correct.

    After intensive digging in internet I didn’t find anything related to this error. The problem is that obviously nobody has ever called it within .NET. This is reasonable, because this function is designed to be called within one port monitor, and port monitor is always written in C++ as user mode driver. Till now.

    The error above has no logical meaning. In my case indicates stack corruption, because .NET code didn’t marshal few parameters as expected. The reason for this is that all interop definitions of SetPort function, which you can found in internet  are just wrong. They probably have been generated automatically.

     

    The right definition is for sure:

    [DllImport(DllNames.WinSpool, CharSet = CharSet.Unicode, SetLastError = true)]
    public static extern bool SetPort(

    [In, MarshalAs(UnmanagedType.LPWStr)] string pName,
    [In, MarshalAs(UnmanagedType.LPWStr)] string portName,
    uint dwLevel,
    IntPtr pData);

     

    And the ultimate call to SetPort looks like:

    IntPtr handle;
    PORT_INFO_3 pInf = new PORT_INFO_3();
    pInf.dwSeverity = WinSpooler.PORT_STATUS_TYPE_INFO;
    pInf.dwStatus = WinSpooler.PORT_STATUS_OFFLINE;
    pInf.pszStatus = null; // This works with OS Ver. >= 6

    uint level = 3;

    IntPtr pData = Marshal.AllocHGlobal(Marshal.SizeOf(pInf));

    Marshal.StructureToPtr(pInf, pData, true);

    bool res = WinSpooler.SetPort( null, "DOT4_002", level, pData);


     

Copyright of SQL/Developers Community
Powered by Community Server (Commercial Edition), by Telligent Systems