in

mscommunity.net

Interactive mscommunity.net online activities

DamirDobric

veljača 2009 - Posts

  • Announcing Release Candidate for BizTalk RFID 2009

    The BizTalk RFID team is pleased to announce the Release Candidate for BizTalk RFID 2009.

     Key features of BizTalk RFID 2009 include:

    ·         BizTalk RFID Mobile (RFID platform for Windows Mobile and Windows CE based devices)

    o   BizTalk RFID Mobile consists of a runtime engine, tools and components to develop, deploy and manage RFID solutions on mobile devices.

    o   Store and Forward: BizTalk RFID Mobile supports the ability to store events locally as well as forward them to the server.

    o   Remote Management: BizTalk RFID Mobile allows remote management of Windows Mobile-based devices.

    o   SQL Sink service: BizTalk RFID Mobile supports using a SQL database to store events and information on the mobile device, in much the same way that BizTalk Server RFID does.

    o   Support for Windows CE 5.0, Windows Mobile 5.0, Windows Mobile 6.0, Windows Mobile 6.1 platforms

    ·         Support for industry Standards

    o   EPCIS: EPCIS Object Model and Capture Client to enable you to capture raw data, convert to EPCIS documents and use the capture client to post to a capture service. Capture service is not included.

    o   LLRP Provider: Out-of-the-box connectivity with readers using the EPCglobal-ratified Low-Level Reader Protocol (LLRP) reader-host standard.

    o   TDT: Services to decode tag attributes natively via the Tag Data Translation (TDT) standards library

    o   WS Discovery: A library for providers to discover devices using the standard web services based discovery mechanism.

    ·         Support for newer platforms             

    o   Windows Server 2008

    o   SQL Server 2008

    o   .Net 3.5 SP1 and Visual Studio 2008

    ·         RFID Manager Usability Improvements

     

    Microsoft has integrated BizTalk RFID Mobile and BizTalk RFID Standards Pack which were released separately this year into BizTalk Server 2009 release.

    To migrate your existing BizTalk RFID Server 2006 R2 installation, please uninstall the R2 installation and install this RC. Please note that all existing Providers, Event Handlers and Applications built for BizTalk RFID Server 2006 R2 will work with BizTalk RFID Server 2009, without needing a recompile.

  • Hotfix for BizTalk RFID

    Today Microsoft has published a hotfix for several issues, which have been experienced in last months. The hotfix for all listed issues can be downloaded here. It contains only assemblies that are required to correct listed issues and do not perform update of the whole product. If you do not experience any of these issues, you do not have to install the fix on productive systems. The list of affected assemblies can be found behind provided link above.

    Here is the list:

    High IO latency  issue

    It occurs while setting of output values on digital input/output (I/O) ports. For example, you wont to swich some light by setting of the IO property.
    This problem causes a delay in operator tasks or incorrect results in automated operations.

    Disappering Events while restarting

    When the BizTalk RFID Service is restarted while the service is receiving tag events from devices, some tag events are lost. The loss of events occurs for a short time.

    Device Discovery Issue
    This issue targets devices which obtain IP address via DHCP protocol or by connecting via Active Sync. Please read more about this here.

     

    First  one is my personal favorite, which made me often crazy.

    Enjoy

    Posted vlj 25 2009, 11:32 by anonymous
    Filed under:
  • Manipulating of Message Header in Silverlight

    Almost two years ago I have posted in "Hacking of WCF's OperationContext" about manipulating of header of the message in WCF. The same feature is also provided in Silverlight since RTW 2 BETA2. Here is an example:

         Service proxy = new Service();

         proxy.OnOperationCompleted +=
              new EventHandler<DoWorkCompletedEventArgs>(onCompleted);

         using (OperationContextScope ctx=
         new OperationContextScope(proxy.InnerChannel))
         {

            OperationContext.Current.OutgoingMessageHeaders.Add
            (MessageHeader.CreateHeader("SomeHeader",
             "http://daenet.eu", "..."));

             proxy.OperationkAsync("foo");
         }

    Next example shows how to obtain the header value:

    void onCompleted(IAsyncResult result)
    {
         Service proxy = (Service1)result.AsyncState;

         using (OperationContextScope ocs =
         new OperationContextScope(((Service1Client)proxy).InnerChannel))
         {

              string res = proxy.EndDoWork(result);

              string header=
              OperationContext.Current.IncomingMessageHeaders.GetHeader<string>
              ("
    SomeHeader", "http://daenet.eu");
         }
    }


     

  • Processing of neutral culture in ASP.NET application

    While processing http request in a ASP.NET application, the current culture of the thread on which the request is processing, depends on the language settings of the browser.
    For example, if the user has set languages [de-de], [en-us] and [bs-Latn-ba] in his browser, then property Request.UserLanguages will contain the list of same languages.
    You can use these values to process the request in the culture, which depends on user browser settings and application logic.
    However, by default the first language in the list will define the culture of the thread, which is processing the request.

    This is all fine, but there is a case, which could cause some formatting errors. That happens when the user has set a neutral culture like [de] or [bs]. In that case the thread culture will be set on the neutral culture. Unfortunately there are many formatting functions in .NET (e.g. DateTime.Parse) which do not understand neutral cultures.

    This example shows hot to check whether the current culture is neutral one:

    Thread.CurrentThread.CurrentUICulture.IsNeutralCulture

    In other words, when the user has chosen the neutral culture, it is likely possible that your ASP.NET application will file while doing some formatting.

    To work around this you can set specific culture from neutral one, before request gets processed:

    protected void Application_BeginRequest(Object sender, EventArgs e)
    {

         Thread.CurrentThread.CurrentUICulture =
         CultureInfo.CreateSpecificCulture(Thread.CurrentThread.CurrentUICulture.Name);
    }

    This is very simple solution, which unfortunately has one hidden issue. ASP.NET framework under the hub will in some cases (for example dynamic loading of controls) rewrite the thread’s culture again (over and over again).
    To work around this do following:

    protected void Application_BeginRequest(Object sender, EventArgs e)
    {

                Thread.CurrentThread.CurrentUICulture =
                CultureInfo.CreateSpecificCulture(Thread.CurrentThread.CurrentUICulture.Name);

               Request.UserLanguages[0] = Thread.CurrentThread.CurrentUICulture.Name;
    }

     

    Note: If other browser supported languages also have to be processed somewhere in the application logic, the last line should overwrite all of languages and not the first one only!
  • Pex: Allowing of an Exception

    During discovering of the code (method) Pex may find a number of different parameter variations. For each variation of input parameters the program will step through a different execution paths. In the example below one method is shown, which implements three different paths 1, 3 and 4. 

    public string Method1(int a, int b, string st)
    {
               string res = "result: ";

               if (a > b)
               {
                   res += "a > b";
               }
               else if (b > a)
               {
                   res += "a < b";
               }
               else
               {
                   res += "a = b";
               }

               return res + st.Length;
           }

     

    In the line 4 at picture below, PEX has found that for st=null, the method will throw a NullReferenceException. At this point there are in general two thing you can do:

    a) You should define a precondition, which specifies a kind of contract for the method.
    In this case caller should be aware of your assumption in precondition. To do this select "Add Precondition". This will create following code in the method:

    public string Method1(int a, int b, string st)
    {
             CodeContract.Requires(st != (string)null);

             // Contract.Requires(st != (string)null); In. NET40
              . . .
    }

     

    b) You leave the code as it is.
    In this case you can disable PEX to take a care about this exception. The PEX would just ignore it while executing the test.
    Tp do this select "Allow Exception" and PEX will inject following peace of code in PexAssemblyInfo.cs file which has been generated in TestProject by PEX.

    [assembly: PexAllowedExceptionFromAssembly(typeof(NullReferenceException), "Microsoft.ExtendedReflection")]


    If you want to prevent this behavior in the future, just remove this line.

    image

  • Hot downloads February 09

    For this month I vote for next two downloads:

    Azure Services Training Kit - February Update

    The Azure Services Training Kit includes a comprehensive set of technical content including hands-on labs, presentations, and demos designed to help you learn how to use the Azure Services Platform.

    ILMerge

    ILMerge is a utility for merging multiple .NET assemblies into a single .NET assembly.

  • Publishing of Outlook 2007 AddIn with ClickOnce and VS2008

    1. Open the project properties and select “Publish”. Following dialog appears:
    image

    Here you have to choose the name of directory where published files will be copied.

    More interesting is the “Installation Folder”. This is the location from where your addin should be installed. At same later point of time when outlook decides to download new version of addin, the download will be performed from this folder.
    For this reason, after publishing is finished, open the “Publish Folder” and copy all files from that folder to folder “Installation Folder”.

    2. You can optionally select what certificate will be used for signing of manifest.

    image

    3. In “Publish” dialog click on button “Updates”. Here you can choose when updates will be performed.


    image


    4. Click “Publish Now” and following files will be created:


    image

    5. Now, open the “Publishing Folder” and copy all files from that folder to folder “Installation Folder”. Note that users who wants to install the AddIn should have an access to the “Install Folder”. Note also, that this folder should be a trusted location.

    6. When you start Outlook, you should make sure that you your AddIn is installed.

    7. Now you can create a new version of AddIn and publish it again. Note that after this step you will not be able to install the AddIn, because publishing process implicitly start the build which will confuse AddIn-loader and Click Once mechanism.
    To work around this issue you can simply use another machine for testing. I know this will probably not satisfy you. Fortunately there is another way how to do this.

    When you have published Version V1, copy all of published files in some Folder. For example Folder_V1. Then delete all content from the "Publishing Folder".  Now build and publish the version V2. Analog, copy all of files from "Publishing Folder" to some folder Folder_V2.
    Uninstall the current version of AddIn, which is now V2.

    To install the version V1 follow step 5 and start outlook. Close Outlook, delete all files from folder “Installation Folder” and copy all files from Folder_V2 to “Installation Folder”.

    Start Outlook and you will see that AddIn is updated.(Assuming that “check every time the customization runs” is selected”). If this option is not selected, you will have to wait 7 days to update AddIn, which is default setting :)

     

    Hope this helps you...

  • .NET4.0 Code Conditions: Implementing Custom Rewriter

    Runtime behavior of assertions and assumptions are already defined in the original Contract class. However,
    their behavior can be modified with the rewriter. My problem is that defined assertions are not designed for
    real productive use. Application which does not hold defined conditions should not fail with assert. The application
    should rather throw exceptions.

    Here is an example of rewriter, which throws exceptions.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Diagnostics;

    namespace SampleApplication {

        public class RequiresException : Exception
       
    {
            public RequiresException(string message) { }
        }

        public class EnsuresException : Exception
        {

         public EnsuresException(string message) { }
        }

         public class InvariantException : Exception
        {
            public InvariantException(string message) { }
        }

     
        public class AssertException : Exception
        {
            public AssertException(string message) { }
        }
           

        public class AssumeException : Exception
        {

            public AssumeException(string message) { }
        }

         public static class CustomRewiterMethods
     
       {

            public static void Requires(bool cond, string msg)
            {
                if (!cond) throw new RequiresException(msg);
            }       

           
            public static void Ensures(bool cond, string msg)
            {
                if (!cond) throw new EnsuresException(msg);
            }       


           
    public static void Assert(bool cond, string msg)
            {
                if (!cond) throw new AssertException(msg);
            }


           
    public static void Assume(bool cond, string msg)
            {
                if (!cond) throw new AssumeException(msg);

            }


           
    public static void Invariant(bool cond, string msg)
            {
                if (!cond) throw new InvariantException(msg);
            }
        }
    } 

     

  • Implementing of custom rewriter in .NET4.0: error MSB3073

    When implementing custom rewriter you may get following error:

    error MSB3073: The command ""C:\Program Files\Microsoft\Contracts\Bin\ccrewrite" /rewrite  "/rewriterMethods:SampleApplication,SampleApplication.CustomRewiterMethods" "D:\Tfs\hyperion\DaenetProjects\DiverseTests\ContractBasedProgramming\SampleApplication\bin\Debug\SampleApplication.exe"" exited with code -1.

    To solve the error note that specified assembly which implements rewriter methods has to be specified by assembly extension suffix. In the example shown at the
    following picture I implemented custom rewriter in an (EXE) executable assembly.

     

    image

  • Inversion of Control in 5 minutes

    Imagine You have classes that have dependencies on services or components whose concrete type is specified at design time. To replace or update the dependencies, you would have to change your classes' source code, The concrete implementation of the dependencies must be (in this case) available at compile time. More over such classes are difficult to test in isolation, because they have a direct reference to their dependencies. This means that these dependencies cannot be replaced with mock objects.

    Such solution is unfortunately common one. In ideal case You should to decouple your classes from their dependencies. The methodology which helps you solve this problem is called "Inversion of Control".

    There are two types (sub-patterns) of Inversion of Control: Dependency Injection and Service Locator.

    Dependency Injection

    Do not instantiate the dependencies explicitly in the host of your class. IUse a Builder object to obtain valid instances of your object's dependencies and pass them to your object during the object's creation and/or initialization (this can alos be done declaratively for example in MEF). Next Figure illustrates this.

    Cc707845.360cdd41-4418-4fff-9dee-fc6140458c1d(en-us,MSDN.10).png

    In general there are two main forms of dependency injection:

    · Constructor injection (Builder creates a class and you inject dependencies in constructor)

    · Setter injection (Builder creates a class and you set properties.)

    Following example shows constructor injection.

    public class NewsReaderPresenter : INewsReaderPresenter
    {
              private INewsReaderView readerView;

    public NewsReaderPresenter(INewsReaderView view)
    {
      this.readerView = view;
    }

    public void SetNewsArticle(NewsArticle article)
    {
       readerView.Model = article;
    }

    public void Show()
    {
       readerView.ShowView();
    }

    }

    [TestMethod]
    public void ShowInformsViewToShow()
    {
        var view = new MockNewsReaderView();
        var presenter = new NewsReaderPresenter(view);
        presenter.Show();

       Assert.IsTrue(view.ShowViewWasCalled);

    }

    [TestMethod]
    public void SetNewsArticlesSetsViewModel()
    {

        var view = new MockNewsReaderView();

        var presenter = new NewsReaderPresenter(view);

        NewsArticle article = new NewsArticle() { Title = "My Title", Body = "My Body" };

        presenter.SetNewsArticle(article);

        Assert.AreSame(article,view.Model);

    }

    Service Locator

    In this case create a service locator that contains references to the services and that encapsulates the logic to locate them. In your classes, use the service locator to obtain service instances. Next figure illustrates this.

    Cc707905.f66cafe4-309e-4f6a-a1e0-8bd75b622b28(en-us,MSDN.10).png

    public void Initialize()
    {

         RegisterViewsAndServices();
         INewsController controller = _container.Resolve<INewsController>();

         controller.Run();

    }

    [TestMethod]
    public void InitCallsRunOnNewsController()
    {

         MockUnityResolver container = new MockUnityResolver();

        var controller = new MockNewsController();

        container.Bag.Add(typeof(INewsController), controller);

        var newsModule = new NewsModule(container);

        newsModule.Initialize();

        Assert.IsTrue(controller.RunCalled);

    }

     

    For more information: http://msdn.microsoft.com/en-us/library/cc707841.aspx

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