Tuesday, September 15, 2015

Problem resolved - Remote debugging the windows service

Problem resolved - Remote debugging the windows service

The following error happens when trying to debug the windows service via remote debugger by visual studio.  You will find the breakpoints you set shows a cycle instead of substantial. It points the debugger issue. The application I need to debug is windows service with installation package. It finally works with copy directly the services application into the running folder instead of running installation package to setup. So, when the debugger runs with issue, try the direct from source to target and use copy instead of any other deployment or delivery way. It'll get you straight approaching.


The breakpoint will not currently be hit. No symbols have been loaded for this document




Thursday, February 26, 2015

SharePoint Error - You do not have appropriate permissions to create a new workbook in the specified location

Error that happening during generating a excel document in a SharePoint document library.


Error:

Cannot open file "You do not have appropriate permissions to create a new workbook in the specified location".
Correlation ID: c9fe6615-10bb-4542-b6de-9429258b99db
Date and Time: 2/26/2015 2:34:55 PM



02/26/2015 14:32:32.54 w3wp.exe (0x2EB0)                       0x2438 SharePoint Foundation         Runtime                       tkau Unexpected System.Runtime.InteropServices.COMException: Cannot open file "You do not have appropriate permissions to create a new workbook in the specified location".    at Microsoft.SharePoint.Library.SPRequestInternalClass.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, String& pEtagNew, String& pContentTagNew)     at Microsoft.SharePoint.Library.SPRequest.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, String& pEtagNew, String& pContentTagNew) 0b836823-fd28-4d03-944a-8a89b8e12892


Solution:

  1. add the permissions of excel service owner to the db
  2. remove the Excel Services Service application
  3. recreate the excel service application as well as the following proxy
  4. set the URI of excel document library in SharePoint  excel services application - Trusted File Locations.

Wednesday, February 25, 2015

Web service or WCF interface issue. The maximum nametable character count quota (16384) has been exceeded while reading XML data.

I have a proxy application that pass the same functionality outside of our corp network. It consumes internal web service (ASMX) through SSL required and opens through SharePoint web service port. It pops up the following error when I added some new functions which supposed to hit the default max limit. There a bunch solutions from internet and basically, most of them are targeting the configuration file (app.xml etc). As the proxy application is consuming the web service through encapsulated internal layer. So the solution that finally solved the issue is via the code. Here lists the proxy call function that specify the max limit value (2147483647).


Error: 

The maximum nametable character count quota (16384) has been exceeded while reading XML data. 



Solution function:


Public Shared Function SecureProxyCall(Of T)(targetUrl As String, programaticUserID As String, programaticPassword As String, domain As String) As T
        Dim binding As New BasicHttpBinding()
        Dim timeout As New TimeSpan(0, 20, 0)

        binding.MaxReceivedMessageSize = 2147483647
        binding.MaxBufferSize = 2147483647
        binding.ReaderQuotas.MaxStringContentLength = 2147483647
        binding.ReaderQuotas.MaxNameTableCharCount = 2147483647
        binding.SendTimeout = timeout
        binding.ReceiveTimeout = timeout

        Dim address As New EndpointAddress(targetUrl)
        Dim securedClient = Activator.CreateInstance(GetType(T), New Object() {binding, address})
        If String.IsNullOrEmpty(programaticUserID) Then
            'Force to anonymous
            binding.Security.Mode = BasicHttpSecurityMode.None
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None
        Else
            binding.Security.Mode = BasicHttpSecurityMode.Transport
            securedClient.ClientCredentials.Windows.ClientCredential = New Net.NetworkCredential(programaticUserID, programaticPassword, "nfm")
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows
        End If
        Return securedClient
    End Function

Thursday, February 19, 2015

SharePoint Error solution.

Error Message of SharePoint Log:


02/19/2015 09:41:32.81 w3wp.exe (0x0674)                       0x2468 SharePoint Foundation         Runtime                       tkau Unexpected System.MissingMethodException: Method not found: 'System.String Microsoft.Office.Server.UserProfiles.SynchronizationRunStatus.get_ConnectionName()'.    at Microsoft.SharePoint.Portal.WebControls.UserProfileServiceImportStatisticsWebPart.RenderSectionContents(HtmlTextWriter writer)     at Microsoft.SharePoint.Portal.WebControls.UserProfileServiceImportStatisticsWebPart.RenderWebPart(HtmlTextWriter writer)     at Microsoft.SharePoint.WebPartPages.WebPart.Render(HtmlTextWriter writer)     at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)     at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)     at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)     at System.Web.UI.HtmlControls.Html... 54625c4e-29c1-4b1c-bca1-117563688d20



Solution:


  1. Delete the old User Profile Service Application (SharePoint Central Administration).
  2. Delete the User Profile Sync Database (Keep the Profile DB and Social DB)
  3. Recreate User Profile Service Application (Specify new name of DBs)
  4. Set Administrators for User Profile Service Application (Add the farm account and user account in)
  5. Reboot the server.




Wednesday, April 3, 2013

Silverlight listbox item selection binding with dynamic border setting

The requirement needs the listboxitem with a dynamic border by a binding property. Once I implemented this by adding a border tag over the ContentPresenter, it automatically overwrote the default selection border. That means when you click the item from listbox, there's nothing happening with the border. It took me a few of days to fight on the dynamic borders of Silverlight listbox items. Finally it comes up with the VSM (VisualStateManager) solution as following code. One special thing that happening on my case is if you click once to select the item, the first item would be always auto selected, you'd have to click other item or other area once again to dime the first item border selection. The fix will be commenting the Storeboard of Focused VisualState. Here shows you the entire code.

(Notice: The 2 converters by binding Tag were my custom function to give the BorderBrush a custom color by listbox sourceitem property, it will need to implement IValueConverter as a reference class as the bottom code)

Xaml:

<ListBox x:Name="SKUImageListBox" Height="250" Width="600" SelectionMode="Single" HorizontalContentAlignment="Left" TabIndex="1"

HorizontalAlignment="Left" VerticalAlignment="Top" Margin="3,2,115,0" DataContext="{Binding}">

<ListBox.ItemContainerStyle>

<Style TargetType="ListBoxItem">

<Setter Property="Padding" Value="3" />

<Setter Property="HorizontalContentAlignment" Value="Left" />

<Setter Property="VerticalContentAlignment" Value="Top" />

<Setter Property="Background" Value="Transparent" />

<Setter Property="BorderThickness" Value="1"/>

<Setter Property="TabNavigation" Value="Local" />

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="ListBoxItem">

<Grid Background="{TemplateBinding Background}">

<vsm:VisualStateManager.VisualStateGroups>

<vsm:VisualStateGroup x:Name="CommonStates">

<vsm:VisualState x:Name="Normal" >

<Storyboard>

<DoubleAnimation Storyboard.TargetName="BorderSquare" Storyboard.TargetProperty="Opacity" Duration="0" To=".50"/>

</Storyboard>

</vsm:VisualState>

<vsm:VisualState x:Name="MouseOver">

<Storyboard>

<DoubleAnimation Storyboard.TargetName="fillColor" Storyboard.TargetProperty="Opacity" Duration="0" To=".35"/>

</Storyboard>

</vsm:VisualState>

<vsm:VisualState x:Name="Disabled">

<Storyboard>

<DoubleAnimation Storyboard.TargetName="ContentPresenterImg" Storyboard.TargetProperty="Opacity" Duration="0" To=".55" />

</Storyboard>

</vsm:VisualState>

</vsm:VisualStateGroup>

<vsm:VisualStateGroup x:Name="SelectionStates">

<vsm:VisualState x:Name="Unselected" />

<vsm:VisualState x:Name="Selected">

<Storyboard>

<DoubleAnimation Storyboard.TargetName="fillColor2" Storyboard.TargetProperty="Opacity" Duration="0" To=".75"/>

</Storyboard>

</vsm:VisualState>

</vsm:VisualStateGroup>

<vsm:VisualStateGroup x:Name="FocusStates">

<vsm:VisualState x:Name="Focused">

<!--<Storyboard>

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility" Duration="0">

<DiscreteObjectKeyFrame KeyTime="0">

<DiscreteObjectKeyFrame.Value>

<Visibility>Visible</Visibility>

</DiscreteObjectKeyFrame.Value>

</DiscreteObjectKeyFrame>

</ObjectAnimationUsingKeyFrames>

</Storyboard>-->

</vsm:VisualState>

<vsm:VisualState x:Name="Unfocused"/>

</vsm:VisualStateGroup>

</vsm:VisualStateManager.VisualStateGroups>

<Rectangle x:Name="fillColor" Opacity="0" Fill="#FFBADDE9" IsHitTestVisible="False" RadiusX="1" RadiusY="1" />

<Rectangle x:Name="fillColor2" Opacity="0" Fill="#FFBADDE9" IsHitTestVisible="False" RadiusX="1" RadiusY="1" />

<Border x:Name="BorderSquare" Opacity="0" IsHitTestVisible="False" BorderBrush="{Binding Tag,Converter={StaticResource SquareImageBorderBrushConverter}}" BorderThickness="{Binding Tag,Converter={StaticResource SquareImageBorderThicknessConverter}}"/>

<ContentPresenter x:Name="ContentPresenterImg" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}"/>

<Rectangle x:Name="FocusVisualElement" Stroke="#FF6DBDD1" StrokeThickness="1" Visibility="Collapsed" RadiusX="1" RadiusY="1" />

</Grid>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

</ListBox.ItemContainerStyle>

<ListBox.ItemsPanel>

<ItemsPanelTemplate>

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20"/>

</ItemsPanelTemplate>

</ListBox.ItemsPanel>

<ListBox.ItemTemplate>

<DataTemplate>

<StackPanel Orientation="Horizontal">

<StackPanel Orientation="Vertical">

<Image Source="{Binding Path=Source}">

</Image>

</StackPanel>

</StackPanel>

</DataTemplate>

</ListBox.ItemTemplate>

</ListBox>


Converter:


Namespace Converters
    Public Class SquareBorderBrushConverter
        Implements IValueConverter

        Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
            Dim returnValue As String = String.Empty
            Dim img As New SkuOpsSvcRef.SKUImage
            Try
                If value IsNot Nothing Then
                    img = CType(value, SkuOpsSvcRef.SKUImage)
                    If Not img.IsSquare And Not img.IsNew Then
                        returnValue = "Red"
                    Else
                        returnValue = "Transparent"
                    End If
                Else
                    returnValue = String.Empty
                End If
            Catch
                returnValue = String.Empty
            End Try
            Return returnValue
        End Function

        Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
            Return Nothing
        End Function
    End Class

End Namespace


Namespace Converters
    Public Class SquareBorderThicknessConverter
        Implements IValueConverter

        Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
            Dim returnValue As String = String.Empty
            Dim img As New SkuOpsSvcRef.SKUImage
            Try
                If value IsNot Nothing Then
                    img = CType(value, SkuOpsSvcRef.SKUImage)
                    If Not img.IsSquare Then
                        returnValue = "4"
                    Else
                        returnValue = "3"
                    End If
                Else
                    returnValue = String.Empty
                End If
            Catch
                returnValue = String.Empty
            End Try
            Return returnValue
        End Function

        Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
            Return Nothing
        End Function
    End Class

End Namespace

Thursday, February 28, 2013

Silverlight Listbox Binding Image and Tag

It took me couple days to figure this out. The requirement needs me to show the images to the listbox. I do already have the ObservableCollection of Images to set as Item Source. Only way to get specified way is through some kind of style. Here I use background of ItemContainerStyle with converter to my custom highlighting on wanted images. Xaml Code follows:

<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="SkuMaintain.SKUDetailUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:localFormatter="clr-namespace:SkuMaintain.SkuDetailFormatter" >


<UserControl.Resources>
<localFormatter:SquareBackgroundConverter x:Key="SquareImageConverter"/>
</UserControl.Resources>


<ListBox x:Name="SKUImageListBox" Height="250" Width="600" SelectionMode="Single"  HorizontalContentAlignment="Left" TabIndex="1"
HorizontalAlignment="Left" VerticalAlignment="Top" Margin="3,2,115,0" >
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Background" Value="{Binding Tag,Converter={StaticResource SquareImageConverter}}"></Setter>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical">
<Image Source="{Binding Path=Source}"></Image>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

Converter file definition (DetailFomatter.vb)


Imports System.Windows.Data
Imports System.IO

Namespace SkuDetailFormatter
    Public Class SquareBackgroundConverter
        Implements IValueConverter

        Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
            Dim returnValue As String = String.Empty
            Dim img As New SkuOpsSvcRef.SKUImage
            Try
                If value IsNot Nothing Then
                    img = CType(value, SkuOpsSvcRef.SKUImage)
                    If Not img.IsSquare Then
                        returnValue = "Red"
                    End If
                Else
                    returnValue = String.Empty
                End If
            Catch
                returnValue = String.Empty
            End Try
            Return returnValue
        End Function

        Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
            Return Nothing
        End Function
    End Class
End Namespace