in

Community Blogs

Blogs of different SQL/Developers Community Members

This Blog

Syndication

DamirDobric

svibanj 2009 - Posts

  • Code Contracts in .NET 4.0

    Since Visual Studio 10 BETA 1, the code contract library is fully integrated in .NET Framework 4.0. The VS 10 BETA1 installs by default the framework version 4.0.205506. In installation folder of .NET 4.0 there is as usual assembly mscorlib.dll which implements Code Contract functionality in the namespace System.Diagnostics.Contracts.

    image

    Code Contract static methods are by default integrated in the framework, but if you want to use full functionality with static and dynamic checking, you should install the code contract package.

    After installing following will appear in project settings:

    image

    Remarks: Run as Administrator on the picture above does not belongs to contract library!

  • Routing of Void-Messages

    When extending WCF stack in almost all enterprise relevant use cases reliable messaging is very important. Unfortunately in many scenarios, you will have a problem that WS-* trust of vendor one is not same as WS-* of vendor 2. In such cases (that are almost all interop cases) you will have to take a care that no message is lost.
    One may think that this is common requirement. This is true, but most common solutions do not support it just out of the box.
    For example, imagine you want to implement WCF channel which reads messages from some queue. Let say MQ. You will read message in your implementation of IOutput, IReply or related channel. After the message is dispatched to service operation the resulting message (operation response) will be send by Service Model to you IRequestContext only if the operation is not marked as OneWay. That means you will not be able to implement message reliable channel by using of contracts which requires OneWay messaging.

    Shortly following statements hold:

    a) if the message is OneWay then independent on contract which your channel implements the message will never be routed back to your channel. That means you will not be able to implement reliable messaging, because your channel is not notified about possible error in service operation.

    b) If the message is not OneWay then Service Model will route result message to the right place. This should be IRequestContext implementation.

    c) Independent on channel type and operation style (OneWay or not) Service Model will always invoke extensions of type MessageInspector. This holds even in a case of an failure in service operation. Unfortinatelly this is not a case for routing to zour channels like IRequestContext .

    d)If operation has return value (OneWay=false)then appropriate message will be be routed to IRequestContext concrete implementation.

    e)If operation has not a return value (return ‘void’) and operation fails, then appropriate fault message will be be routed to MessageInspectors. The fault message will also be routed to IRequestContext concrete implementation if the operation is not set as OneWay.

    e)If operation has not a return value (return ‘void’) and operation is completed successfully the service model will generate a void message if the operation is OneWay=false. This is very important statement, because many people think that VOID-returning operations do not generate messages. Void-Messages are not generated if the contract is OneWay=true.If OneWay=false, service model will for Void-response always generate one message (se below), but the channel implementation will decide whether to send the message or not.
    Following message is internally routed in WCF stack when a void operation returns if the operation is marked as OneWay.

    <s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing"
               
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <
    s:Header>
        <
    a:Action s:mustUnderstand="1">
                 
    http://tempuri.org/IOneWayReceiverTestInterface/InvokeResponse</a:Action>
        <
    a:RelatesTo>ID:414d5120514d312020202020202020204d93fd4902da0120</a:RelatesTo>
     
    </s:Header>
      <
    s:Body />
    </
    s:Envelope>

    This message is posted to BeginReply and Reply operations of RequestContext interface.

  • Attention: Important Information on MOSS Service Pack 2!

    Following information has been delivered Microsoft Gold Partners today. Because I find it important for all of herse is a short German Abstract and the original version in English.

    Vor kurzem hat die SharePoint Produktgruppe auf Ihrem Blog eine Nachricht veröffentlicht, die vor einem Fehler nach der Installation des Service Pack 2 für SharePoint Server 2007 warnt:

    Leider hat sich nach der Veröffentlichung des Service Pack 2 herausgestellt, dass es einen bisher unentdeckten Fehler gab, der dazu führt, dass sich der SharePoint Server nach der Installation des SP2 fälschlicherweise für eine Testversion hält und nach Ablauf von 180 Tagen seine Funktion einstellen würde.

    WICHTIG: Innerhalb dieser 180 Tage gibt es keine Einschränkung des Betriebes. Die Funktionalität ist in keinster Weise eingeschränkt und Ihre Daten sind nicht gefährdet.

    Die Produktgruppe arbeitet an einer Veröffentlichung eines Hotfixes, der dieses Problem automatisch behebt. Zusätzlich ist eine sofortige manuelle Behebung des Problems durch erneute Eingabe der Produkt-ID möglich.

    Weitere Informationen finden Sie im englischsprachigen Blog-Eintrag unter der Adresse: http://blogs.msdn.com/sharepoint/archive/2009/05/21/attention-important-information-on-service-pack-2.aspx. Dieses habe ich Ihnen zusätzlich an diese Mail unten beigefügt.

     

    Attention: Important Information on Service Pack 2

    Microsoft take product quality seriously and make every effort to avoid and resolve issues that adversely impact our customers.  Unfortunately, we have recently discovered a bug with Service Pack 2 (SP2) that affects all customers that have deployed it for SharePoint Server 2007.

    During the installation of SP2, a product expiration date is improperly activated. This means SharePoint will expire as though it was a trial installation 180 days after SP2 is deployed. The activation of the expiration date will not affect the normal function of SharePoint up until the expiration date passes. Furthermore, product expiration 180 days after SP2 installation will not affect customer’s data, configuration or application code but will render SharePoint inaccessible for end-users.

    We are working to release a hotfix to automatically fix this issue. A manual work-around is currently available and involves customers re-entering their Product ID number (PID) on the Convert License Type page in Central Administration.  For more information and detailed steps please read this KB article. (The KB link is not currently active, it will be available within the next 48hrs)

    We want to assure our customers that this issue does not impact data integrity or their SharePoint deployment in any other way.

    For your convenience, below are some answers to questions that you may have and we will update this blog post with a link to the hotfix as soon as it’s available.

    We apologize for any inconvenience this issue may cause you.

    Jeff Teper
    Corporate Vice President
    SharePoint.

    Q&A

    Which products are affected by this?
    Applying Service Pack 2 to any of the following products will result in this issue: Office SharePoint Server 2007, Project Server 2007, Form Server 2007, Search Server 2008 and Search Server 2008 Express.

    Windows SharePoint Services 3.0 is not affected by this issue.

    What can I do to fix it?
    To work around this issue customers will need to re-enter their Product ID numbers (PID) on the Convert License Type page in Central Administration.  Please see this KB article for detailed steps. (The KB link is not currently active, it will be available within the next 48hrs) 

    Customers can also wait for the hotfix (available for free from http://support.microsoft.com) to resolve this issue.

    Product ID numbers (PIDs) can be retrieved by logging into the Volume Licensing Service Center.

    Note: For Search Server 2008 Express the only way to resolve this issue is to apply the hotfix.

    What is Microsoft doing to fix it?
    Microsoft is working on a hotfix and public update for the product. We will update this blog post with details and a link to the hotfix as soon as it is available.

    Do I need to update all of the servers in my farm?
    No. The Product ID number only needs to be entered once.

    What if I haven’t installed SP2 yet but want to? What should I do?
    You can continue to plan for and install Service Pack 2 for SharePoint Server 2007 with the additional step of re-entering your Product ID number after the installation is complete by following the instructions in this KB article. (The KB link is not currently active, it will be available within the next 48hrs)

    Does this issue impact anything else?
    The issue only activates the product expiration date. The activation of the expiration date does not affect the normal function of SharePoint up until the expiration date passes, at which point SharePoint will be inaccessible for end-users. This issue does not affect customer’s data, configuration or application code.

    I can’t find/don’t know my original PID, where can I find it?
    Product ID numbers (PIDs) can be retrieved by logging into the Volume Licensing Service Center.

  • BizTalk Developer Center

  • Impersonation and Reverting of Identity

    When working with server based applications like ASP.NET and WCF or other services, you will for sure be required to use impersonation. I’m not going to describe in this post anything about impersonation, because it is pretty well described topic. Here is the link to ASP.NET related impersonation and this one is for WCF Impersonation.
    If you want to understand what this post is about, you have to understand what impersonation is.

    Problem Description

    Sometimes you will have a service or application which uses impersonation. For exampe in a case of ASP.NET application you will use

    <!-- Web.config file. –>
    <identity impersonate="true"/>

    In a case of WCF would be imperatively in your code : ImpersonationOption.Required

    When the request arrives some method or operation at the server side then current identity can be queried as follows:

    WindowsIdentity.GetCurrent();

    And this is the result of this statement:

    {System.Security.Principal.WindowsIdentity}
        AuthenticationType: "Kerberos"
        Groups: {System.Security.Principal.IdentityReferenceCollection}
        ImpersonationLevel: Impersonation
        IsAnonymous: false
        IsAuthenticated: true
        IsGuest: false
        IsSystem: false
        Name: "TESTDOMAIN\\myuseraccount"
        Owner: {S-2-2-32-514}
        Token: 588
        User: {S-1-5-21-000000000-3774364995-3200000000-1112}

    As you see I’m as a caller impersonated: myuseraccount. This is fine, but what if your code contains some statemens which requires identity of the process and not identity of impersonated user? You may asking yourself why somebody would need such crazy requirement? Here are few examples:

    - Imagine you have a API which is responsible for logging. Each time you call some method the method simply writes something in the file. To enable access to the file you have to enable all impersonated users to access the file. This will be very often an issue.

    - Another example is when you have a method which access one file by using of impersonated identities, but the same method has to asses the database which does not permit any of impersonated users, but the process account only.

    - Last but not least, using of DPAPI in context of interactive user (cluster) like
    ProtectedData.Protect(Encoding.UTF8.GetBytes(plainValue), entropy, DataProtectionScope.CurrentUser) will be a serius issue in this case.

    The solution

    The solution in this case is called Reverting or Undo operation. If you have impersonated by yourself as shown below, you can call Undo() to revert the context to the process identity.


    WindowsImpersonationContext ctx = WindowsIdentity.Impersonate(IntPtr.Zero);
    ctx.Undo();

    However, if you have been impersonated automatically by using of configuration, then you don;t have the context. That means you cannot call Undo(); But, you can use System32 API RevertToSelf();

    [DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern bool RevertToSelf()   
    . . .

    id = WindowsIdentity.GetCurrent(); // From here: TESTDOMAIN\myuseraccount

    RevertToSelf();                                  // From here: TESTDOMAIN\processaccount

    ... perform some operation in context of process identity…

    id.Impersonate();                              // From here: TESTDOMAIN\myuseraccount

    After calling of RevertToself the identity looks like:

    {System.Security.Principal.WindowsIdentity}
        AuthenticationType: "Kerberos"
        Groups: {System.Security.Principal.IdentityReferenceCollection}
        ImpersonationLevel: None
        IsAnonymous: false
        IsAuthenticated: true
        IsGuest: false
        IsSystem: false
        Name: "TESTDOMAIN\processaccount"
        Owner: {A-1-2-32-00000000--3007986800-1000}
        Token: 2764
        User: {A-1-2-32-00000000-389563229-3007986800-0000}

  • How to build SIlverlight V2 Apps with Silverlight Tools 3?

    If you are Silverlight developer you might be probably happy to try Silverlight 3 BETA. The bad thing about this is that you will after installing of Silverlght tools 3 not be able to build Silverlight apps for V2. Unfortunately, this is a feuture which every professional developer needs for sure. So, I’m asking myself how could “we” forget to support this scenario at all?

    Today I spend at least two hours with Andreas. For hobbies just two hours, but for people who are paid to build software, we spend 1/2 day of life. 

    Here is the solution which will help you to spend less time.
    We assume following constellation in your project:

    a) You have a solution Abc.sln which references to N silverlight projetcs.
    b) You have build the solution vor Silverlight V2 and then installed Silverlight V3 and toolkit.
    c) When you build the solution the build is by defaut always done for V2.
    d) You want to be able to make a build for both V2 and V3.

    Here is you have to do:

    0. Open V2 Solution and convert it to V3.

    1. Copy form some machine which only have V2 installed following folder: C:\Program Files\Microsoft SDKs\Silverlight\v2.0 to your development machine:
    This is result on your dev machine:
    imageimage 

    2. Copy also the content of C:\Program Files\Microsoft Silverlight\2.0.40115.0 to the development machine.

    3. Now create a copy of all N-silverlight project files. For example SilvProject1.Proj into SilvProject1 V2.proj

    3. Now create a ne solution called Abc V2.Sln and add all projects as in solution Abc.sln, but instead of original Silverlight projects add new Silverlight projects SilvProjK V2.proj.

    4. Open each new SIlverlight project file and look for

    “<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.CSharp.targets" Condition="" />”

    5. Remove this line and insert following block:

    <PropertyGroup>  
      <SilverlightBuildResources>C:\Program Files\MSBuild\Microsoft\Silverlight\v2.0\</SilverlightBuildResources> 
      <TargetFrameworkDirectory>C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\</TargetFrameworkDirectory> 
      <TargetFrameworkSDKDirectory>C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client\</TargetFrameworkSDKDirectory> 
      <SilverlightRuntimeVersion>2.0.31005.0</SilverlightRuntimeVersion> 
    </PropertyGroup>

    <Import Project="$(SilverlightBuildResources)Microsoft.Silverlight.CSharp.targets"/> 

    6. Optional:
    Note that Silverlight Tools 3 build the XAP file in root of Client bin folder and not in ClientBin\Debug or ClientBin\Release. If you have some references to ClientBin\Debug\xy.XAP in any of projects be sure that you have change them.

    7. Optional: Open the new solution, go to properties of WebProject which you use as Silverlight Application host (if you have such project) and add new starting Silverlight Application with new name SilvProjectXy.Proj. After this step you will have some strange looking list of Silverligth Applications in project properties, but don’t care it will work :)
    If in this list is one application which does not exist in the solution it will be just ignored and XAP file will not be build.
    Depending on what solution Abc.Sln or Abc v2.sln you have opened one app will always be the right one.

  • WinDays Session: .NET4.0: WF4.0 and WCF4.0

    Here is the WinDays presentation related to this session and here you can download demo samples. Note that samples contain much more than shown at the session.

    image

    Thanks for all who have attending this session and hope to see you next year again :)

     

    Last but not least, for all of those guys who have been looking for traditional lamb-sessions in Opatija and didn’t find a solution here is an ultimate tip for next year:

    IMAG0016_thumb IMAG0017_thumb

    Tagged under: “Janjetina”

  • Contract Based Programming & Programm Exploration

    Here is my presentation related to Microsoft.Contracts and Pex which has been shown at WinDays Croatia and TeamConf Munic 2009. Official link to TeamConf session is here.

    image

    Thanks for all who have attending this session and hope to see you next year again :)

    Last but not least, for all of those guys who have been looking for traditional lamb-sessions in Opatija and didn’t find a solution here is an ultimate tip for next year:

    IMAG0016 IMAG0017

    Tagged under: “Janjetina”

  • Downloads April 2009

     

    Internet Explorer 8 Language Packs for Windows Vista and Windows Server 2008

    Download the latest version of the Internet Explorer 8 Language Packs and get language-specific resource files, which allow users to view the user interface of Internet Explorer 8 in a different supported language.

     

    Windows SharePoint Services 3.0 with Service Pack 2

    Microsoft Windows SharePoint Services helps your team share and manage information and documents in a Web site.

     

    Windows SharePoint Services 3.0 x64 with Service Pack 2

    Microsoft Windows SharePoint Services for x64 helps your team share and manage information and documents in a Web site.

    Microsoft Windows Cryptographic Next Generation Software Development Kit for Windows Vista, Windows Server 2008, and Windows 7

    Download documentation, code, and tools designed to help you develop cryptographic applications and libraries targeting Windows Vista Service Pack 1, Windows Server 2008 R2, and Windows 7 operating systems.

  • Authenticode verification with signtool.exe

    This post shows two examples which shows how to verify signature of an application based on Authenticode policy. First example will fail, because the application is signed with the key, whose root certificate is not trusted.

    Example 1 (it will fail)

    C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin>signtool verify /v /pa c:\temp
    \SampleApplication.exe

    Verifying: c:\temp\SampleApplication.exe
    SHA1 hash of file: 99CE8EA6C1096C7CF9CD96C4A2E707A096CA1E76
    SignTool Error: WinVerifyTrust returned error: 0x800B010D
            The certification path terminates with the test root which is not truste
    d with the current policy settings.
    Signing Certificate Chain:
        Issued to: Root Agency
        Issued by: Root Agency
        Expires:   01.01.2040 01:59:59
        SHA1 hash: FEE449EE0E3965A5246F000E87FDE2A065FD89D4

            Issued to: daenetauthenticode
            Issued by: Root Agency
            Expires:   01.01.2040 01:59:59
            SHA1 hash: 79FBF8FAE05640808B8B488BD5728B59B19D0766

    File is not timestamped.
    SignTool Error: File not valid: c:\temp\SampleApplication.exe

    Number of files successfully Verified: 0
    Number of warnings: 0
    Number of errors: 1

    Example 2 (it will succeed)

    Now after the root certificate is installed under trusted publishers, the same verification will pass successfully.

    image

    C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin>signtool verify /v /pa c:\temp
    \SampleApplication.exe

    Verifying: c:\temp\SampleApplication.exe
    SHA1 hash of file: 99CE8EA6C1096C7CF9CD96C4A2E707A096CA1E76
    Signing Certificate Chain:
        Issued to: Root Agency
        Issued by: Root Agency
        Expires:   01.01.2040 01:59:59
        SHA1 hash: FEE449EE0E3965A5246F000E87FDE2A065FD89D4

            Issued to: daenetauthenticode
            Issued by: Root Agency
            Expires:   01.01.2040 01:59:59
            SHA1 hash: 79FBF8FAE05640808B8B488BD5728B59B19D0766

    File is not timestamped.
    Successfully verified: c:\temp\SampleApplication.exe

    Number of files successfully Verified: 1
    Number of warnings: 0
    Number of errors: 0

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