in

Community Blogs

Blogs of different SQL/Developers Community Members

This Blog

Syndication

DamirDobric

ožujak 2011 - Posts

  • Small Instance in Windows Azure

    Here are just two images which show few data about Windows Azure small instance configuration.

     

    image 
    image

    image

  • Windows Azure Upload Certificate Error

    When trying to install the certificate in Windows Azure Management portal you might experience following exception:

    The selected certificate is not valid.

    image

    This exception is thrown when the certified contains exported private key.

    image

    To workaround this, export certificate without private key. Certificate used for deployment within Visual Studio do not need the private key exported in Windows Azure.

  • My Session at WinDays 2011

    Welcome to all of you who will attend WinDays 2011. This year I will give the session about technologies which are owned by home-division called Microsoft Business Platform Division. All of you who do not know much about this division please just note what technologies are in focus: WCF, WF, BizTalk, Windows Server AppFabric, Windows Azure AppFabric, Service Bus, Access Control Service, etc. etc.
    This time the major focus is Windows Azure AppFabric which include many serious technologies for professional enterprise developers.
    My personal title of the session is:

    image

    Here is the agenda:

    image

    Note that I will keep the right to slightly change the program (you know like TV). Smile

     

    Follow on Facebook:

  • Windows Azure metadata issue when hosting service on multiple endpoints

    When working with WCF you might get following exception:

    The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address. Either supply an http base address or set HttpGetUrl to an absolute address.

    Note that there are few different reasons why this can happen. Basically this exception is thrown when there is a mismatch between binding and  metadata url. For example you use binding with transport security (HTTPS) and HttpGetUri is setup to provide metadata at the HTTP address. However this is not my focus in this post.

    I’m more interested to explain how to handle this error in the Windows Azure scenario.

    Imagine you already have one service which is hosted on premise at “http://localhost:801/MyService/”. Following configuration shows MyServ ice which is hosted at that address. More over, the same service exposes an endpoint  hosted in Windows Azure AppFabric Service Bus. When you run the host, it will fail with exception shown above.

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.serviceModel>
            <behaviors>
                <serviceBehaviors>
                    <behavior>
                        <serviceMetadata httpGetEnabled="true" />
                        <serviceDebug includeExceptionDetailInFaults="true" />
                    </behavior>
                </serviceBehaviors>

              <endpointBehaviors>
                <behavior name="sbBehavior">
                  <transportClientEndpointBehavior credentialType="SharedSecret">
                    <clientCredentials>
                      <sharedSecret issuerName="" issuerSecret="=" />
                    </clientCredentials>
                  </transportClientEndpointBehavior>
                  <serviceRegistrySettings
                  displayName="MyService for extranet users"
                  discoveryMode="Public">
                  </serviceRegistrySettings>
                </behavior>
              </endpointBehaviors>
                       
            </behaviors>
            <services>
                <service name="Service.MyService">
                    <endpoint address="" binding="wsHttpBinding" contract="Service.IMyService" >
                        <identity>
                            <dns value="localhost" />
                        </identity>
                    </endpoint>

                  <endpoint  address="sb://myservice.servicebus.windows.net/ExtranetServices/MyService/"
                             contract="Service.IMyService"
                             binding="netTcpRelayBinding"
                             behaviorConfiguration="sbBehavior" />

                     <host>
                        <baseAddresses>
                            <add baseAddress="http://localhost:801/MyService/" />
                        </baseAddresses>
                    </host>
                </service>
            </services>
        </system.serviceModel>
    </configuration>

     

    The host will fail, because WCF 4.0 enforces using of default behavior for all services defined in the application. In this case this will be the service MyService. If you take a deeper look in configuration you will notice that this service has additional rely-binding. This binding exposes the service via Service Bus by using of TCP (netTcpRelyBinding). This cases the service to bind default service behavior for all endpoints. By enabling of metadata WCF internally combines base address of the service with address specified in the endpoint. When this happens, metadata cannot be enabled, because base address is HTTP and endpoint requires TCP (sb://).

    To make this working change default behavior to named behavior and reference it by endpoint hosted on-premise:

                <serviceBehaviors>
                    <behavior name="onPremise">
                        <serviceMetadata httpGetEnabled="true"
                                        
                                         />
                        <serviceDebug includeExceptionDetailInFaults="true" />
                    </behavior>
                </serviceBehaviors>

                . . .

                <service name="Service.MyService" behaviorConfiguration="onPremise">
                    <endpoint address="" binding="wsHttpBinding" contract="Service.IMyService" >
                        <identity>
                            <dns value="localhost" />
                        </identity>
                    </endpoint>

  • Cannot start WCF Web Service, because of ASPNETAdapter failure

    Imaging you have a WCF Web Service which works fine. Unfortunately it can happen that following error occurs when somebody else try to start the service:

    Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.HostAdapters.ASPNETAdapter, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified

    This error is caused by mixed development environment. That means you have build the service with .NET 4 at he x64 machine and somebody else is trying to host the service at his x86 development machine.
    The solution is simple. Following picture shows configuration for both environments.

    image


    Hope this helps.

    Posted ožu 18 2011, 07:16 by anonymous
    Filed under: ,
  • 404 File not found when trying to invoke AJAX operation

    When working with AJAX web service you may notice that one service operation of some service (in this case Service1.svc) works well, but at some machines following exception can be thrown:

     

    Server Error in '/MvcApplication1' Application.


    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

    Requested URL:
    /MvcApplication1/Service1.svc/jsdebug


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1


    I figured out that the problem happens in our team when developers use mixed x86 and x64 environments. For example, I have built the service at 64-bit system and all team members who use x64 platform can use service.
    Unfortunately all team poor guys in team who use x86 platform can see exception shown above when the operation is invoked on service.

    In fact this exception indicates the routing problem in your application. Our application is is ASP.NET MVC, which in Global.asax registers a number of routes like:

    routes.MapRoute(
               "Default", // Route name
              "{controller}/{action}/{token}",
               new { controller = "Abc", action = "Create", token = UrlParameter.Optional, id = UrlParameter.Optional } 
               );

    To experience this issue do following. At x86 machine, enter in the browser http://localhost/YourServiceApp/Service1.svc. The page will answer properly. Then try following URL: http://localhost/YourServiceApp/Service1.svc/jsdebug.
    No the error shown above will appear. To be sure that the routing is problem, goto Global.asax and comment out all MapRoute statements. Now, open  http://localhost/YourServiceApp/Service1.svc/jsdebug again and JS-proxy will be generated.

    image

    This means that AJAX service works properly now. Unfortunately no any other MVC-controller action will work .

    Solution

    To fix the problem I have created the folder Services and moved the service Service1.svc in there. Finally I appended in Global.asax following line of code:

    routes.IgnoreRoute("Services/*.svc");

    Now, the AJAX service works in both x86 and x64 environment.


    Hope this helps.

    Posted ožu 18 2011, 07:07 by anonymous
    Filed under: , ,
  • Visual Studio Color schemas

    In general I work always with standard color schema provided by Visual Studio and like that my colleagues do it too.
    The reason is that we simply often change our places  by sitting in front of laptop of somebody else. Changing of color schema multiple times per day (by changing of place) is definitely more disturbing than to use one favorite schema all the time.
    I always say that to Jung developers who just started at daenet, because they are guys who mostly change the schema.
    Our team and most teams I know shares the default Vanila color schema. I do not think that this schema is the nicest one, but we all in average like it and use it.
    Anyhow, here is the link which shows few interesting styles for VS.

    If you like to rate your favorite schema here is the link provided by MS UK Limited.

    image

  • CloudTableClient “The method 'FirstOrDefault' is not supported.”

    When working with CloudTableClient you might get following exception:

    NotSupportedException

    “The method 'FirstOrDefault' is not supported.”


    This exception is caused for example by following example:

    SyncTableEntity item = ctx.TFiles.FirstOrDefault(f => f.PartitionKey == m_Container && f.RowKey == “…”);

    To workaround this you can use one of following two examples:    

    SyncTableEntity item = (from f in ctx.TFiles where f.PartitionKey == m_Container && f.RowKey == m_BookmarkFileName select f).FirstOrDefault();

    SyncTableEntity item = ctx.TFiles.Where(f => f.PartitionKey == m_Container && f.RowKey == m_BookmarkFileName).FirstOrDefault();

    In fact the workaround is semantically the same as original example which fails. However, the crucial difference is in location where query is executed. In the first case the query should be executed by Table Service running in Windows Azure. Both workarounds however enforce execution of the query at the caller’s side. And this is supported.

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