Thursday, June 7, 2012

calendar for asp.net

had so many problems with calendar extender finally used this

Tuesday, June 5, 2012

WCF converting exceptions to faults


To return all errors (dev) without any configurations:
<serviceBehaviors>
  <behavior name="Debug">
    <serviceDebug includeExceptionDetailInFaults="true" />
  </behavior>
</serviceBehaviors>

WCF   converting exceptions to faults
1)Create basic class
[DataContract]
    public class BlahServiceFault
    {
        [DataMember]
        public string Message { get; set; }

        [DataMember]
        public Guid Id { get; set; }
    }

2)Add reference to Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling

3)Add to interface
[OperationContract]
        [FaultContract(typeof(BlahServiceFault))]
        IEnumerable<blases> GetUserBlases();

4)add to service config file
<exceptionHandling>
    <exceptionPolicies>
      <add name="WCF Exception Shielding">
        <exceptionTypes>
          <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="ThrowNewException">
            <exceptionHandlers>
              <add type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" exceptionMessage="An error occured while processing the request." faultContractType=" BlahServiceFault" name="Fault Contract Exception Handler">
                <mappings>
                  <add source="{Message}" name="Message" />
                  <add source="{Guid}" name="Id" />
                </mappings>
              </add>
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>


5)Usage in client
try
           {
               url = client.GetUserBlases(Params);
           }
           catch (FaultException<BlahServiceFault> ex)
           {
               lblError.Text = ex.Detail.Message;
           }

Diagnostics in WCF

for diagnostics - add the following to config

<system.diagnostics>
    <sources>
      <source propagateActivity="true" name="System.ServiceModel" switchValue="Error,ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default"></add>
          <add initializeData="c:\logs\blah.svclog" type="System.Diagnostics.XmlWriterTraceListener" name="traceListener"></add>
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

interestingly, if you add this twice the config still works.
 for bugs that stop the request from ever reaching the service, check the event log

Monday, June 4, 2012

ajax toolkit

I was creating calendar controls on the fly and this was producing bizarre javascript errors. The answer -
I was using plain scriptmanager instead of
 <asp:ToolkitScriptManager ID="Scriptmanager1" runat="server"></asp:ToolkitScriptManager>


The HTTP service located at blah is too busy

Could just mean the application pool is down

Friday, May 18, 2012

Thursday, May 17, 2012

Visibility in IE

Visibility in IE - make sure you pass valid values and it works fine
also the difference between visibility and display