• How Trace works with Listner

    Listner control destination the output of Trace. Here is how.

  • How to contro whether output Trace

    We already know Listner affect Trace object's output destination. But that is only an aspect of behavior, another aspect is whether the message should be output. The control this we can test a configurable switch's value to determine whether we should output the message. But we need to manually Test the the switch, or we need to write a helper class to wrap the test code. Here is the code.

  • Trace.Assert

    In nunit or other test framework, we have Assert object to test whether result is as expected. If assert is false, then en exception is through. Trace.Assert is provide similar function, but for different purpose. It is for diagnostic. When assert is false, it output the error message to a listener. There is default listener in .net, which is DefaultTraceListener An instance of this class is automatically added to the Debug..::.Listeners and Trace..::.Listeners collections. Explicitly adding a second DefaultTraceListener causes the message also show in the debugger output window and the messageboxe for asserts. The DefaultTraceListner looks like throwing an exception, but it is not actually an exception, it is for user interaction and there is no exception to catch at all. If you remove the DefaultTraceListner like below, you will not see this output, and the execution will continue.

    <img style=”cursor:pointer; cursor:hand;width: 400px; height: 70px;” src=”http://1.bp.blogspot.com/_yUba7cqllFE/SUp5G3ixumI/AAAAAAAAAPw/LGnV259pTc4/s400/assertfail.PNG” border=”0” alt=”“id=”BLOGGER_PHOTO_ID_5281166671941319266” />

    <configuration>
      <system.diagnostics>
        <trace>
          <listeners>
            <clear/>
            <add name="text" />
          </listeners>
        </trace>
        <sharedListeners>
          <add name="text" type="System.Diagnostics.TextWriterTraceListener" initializeData="textfileListner.log" />
        </sharedListeners>
      </system.diagnostics>
    </configuration>
    
  • Forms - Based Authentication

    While it is possible to change a newly created SharePoint site collection to use FBA instead of Windows authentication, it is usually a better idea to extend a new Web application from an existing one and configure the new Web application for FBA, leaving the original one set to Windows authentication. There are numerous reasons for this, one being that SharePoint ’ s search uses NTLM (Windows authentication) to authenticate and crawl the site when indexing the content. In the following example, this is the model that is used.

  • SharePoint Group

    SharePoint allows permission levels to be applied to site users as well as security groups, such as Active Directory groups, that have been added to the site. However, this is not the recommended approach. Rather, Microsoft recommends that site owners and administrators assign permission levels to SharePoint groups and then add site users and security groups to the SharePoint groups.