Showing posts with label Error. Show all posts
Showing posts with label Error. Show all posts

Tuesday, 26 June 2012

User vs UserMulti

I spent almost a whole day trying to figure out why ViewFieldsOverride only imports the UserName of AssignedTo field in Content Query Web Part.

After trying various ways and banging my head against the table, it turns out that by changing Type="UserMulti" from Type="User", AssignedTo field will have the format 'ID;#UserName'.

Friday, 8 June 2012

Add Presence Icon to SPGridview

I spent hours trying to figure out why my presence image only appears for the last instance of the particular user, and I finally figured out why, id has to be unique.
to show image presence, I attached to rowdatabound event with the required javascript

       protected void gvProjOverview_RowDataBound(object sender, GridViewRowEventArgs e)
        { 
            if(e.Row.DataItem!=null)
            {
                SPWeb web = SPContext.Current.Web; 

                SPUser user = web.EnsureUser("DOMAIN\login");
 
                e.Row.Cells[4].Text = ""
                    + " "
                    + ""
                    + "" + user.Name +  ""
                    + "";
            }
        }

id='imn_" + e.Row.RowIndex <- this was where I had used user.ID which was not unique and thus the presence icon was only showing for one of the available users.

The lack of distinct ID causes some presence icon to disappear, that is, if user Andy is on two of the rows, the presence icon only appears for the last row where Andy is in.

Thursday, 7 June 2012

EditorWebPart wierd behavior

I was trying to implement EditorPart and I find that the webpart doesn't update when OK or Apply is clicked. Only when it's been refreshed then the changes appear.
Going through the code shows that the cycle order is : CreateChildControls ApplyChanges OnPreRender
So since I am setting the value in CreateChildControls, it was using the old value before the changes happen in ApplyChanges.
Moving code under CreateChildControls to be in OnPreRender sets automatic update when Apply/OK is clicked.

Monday, 4 June 2012

Attempted to use an object that has ceased to exist

I received this error when trying to insert/edit web part
Attempted to use an object that has ceased to exist

The resolution was to remove USING statement when using SPContext.Current.Web;

This issue happened because SPContext.Current.Web disposes the web object automatically, and by adding a

using
statement, it will try to dispose it again when there's nothing to dispose.

SPMenuField disappears when/after Edit Mode

There has been an issue that has been bugging me when I create an SPMenuField, editing the page will result in the menu field columns disappearing.

After spending hours trialing and erroring, it was resolved by adding a .DataBind() in the Page_Load method.

UserControl.ascx.cs

        protected void Page_Load(object sender, EventArgs e)
        { 
          gvPPL.DataBind();
        }

UserControl.ascx


<SharePoint:MenuTemplate ID="gvPPLMenu" runat="server">
    <SharePoint:MenuItemTemplate ID="editMenu" runat="server" Text="Edit" ClientOnClickNavigateUrl="/_layouts/BPOSproperties/ProjectSettings.aspx?type=edit&url=%EDIT%" />
</SharePoint:MenuTemplate>
<SharePoint:SPGridView ID="gvPPL" runat="server" AutoGenerateColumns="false" DataSourceID="pplDataSource">
    <Columns>
        <SharePoint:SPMenuField HeaderText="NameMenu" TextFields="Name" MenuTemplateId="gvPPLMenu"
        NavigateUrlFields="Email" NavigateUrlFormat="{0}" TokenNameAndValueFields="EDIT=Email" />
        <SharePoint:SPBoundField HeaderText="Name" DataField="Name"  />
    </Columns>
</SharePoint:SPGridView>

<asp:ObjectDataSource ID="pplDataSource" runat="server" TypeName="BPOSsite.PeopleManager, BPOSsite, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c9ab07f514f0925b" SelectMethod="GetPeople"  />

People.cs


namespace BPOSsite
{
    public class People
    {
        private string name;
        private string email;

        public People(string n, string e)
        {
            this.email = e;
            this.name = n;
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public string Email
        {
            get { return email; }
            set { email = value; }
        }
    }

    public class PeopleManager
    {
        public List<People> GetPeople()
        {
            List<People> list = new List<People>();
            list.Add(new People("John", "john@mail.com"));
            list.Add(new People("Nick", "nick@mail.com"));
            list.Add(new People("Tracy", "tracy@mail.com"));
            list.Add(new People("Dick", "dick@mail.com"));
            return list; 
        }    
    }
}

Friday, 1 June 2012

ObjectDataSource TypeName not found

In sharepoint i had to list ObjectDataSource this way

<asp:ObjectDataSource ID="pplDataSource" runat="server" TypeName="MyNameSpace.PeopleManager, MyNameSpace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c9ab07f514f0925b" SelectMethod="GetPeople"  />

else I will get 'TypeName not found' error.

Monday, 21 May 2012

Sharepoint 2010 Visio Workflow Visualization Error

I was faced with the following error when I tried to enable workflow visualization on SharePoint 2010

System.OperationCanceledException: The server failed to process the request. ---> System.ServiceModel.ServerTooBusyException: The HTTP service located at http://r9k7y7d:32843/80eb32d02df348f595a9d27e97f7238c/VisioGraphicsService.svc is too busy.  ---> System.Net.WebException: The remote server returned an error: (503) Server Unavailable.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
   --- End of inner exception stack trace ---

Server stack trace: 
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeEndService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Microsoft.Office.Visio.Server.GraphicsServer.IVisioGraphicsService.EndGetVectorDiagram(IAsyncResult asyncResult)
   at Microsoft.Office.Visio.Server.Administration.VisioGraphicsServiceApplicationProxy.GetVectorDiagram(VectorDiagramRequestContract vectorDiagramRequest)
   at Microsoft.Office.Visio.Server.ServiceWrapper.GetVectorDiagram(String visioFileUrl, Int32 pageNumber, Boolean disableRefresh, AddonDataSource[] dataSources)
   --- End of inner exception stack trace ---
   at Microsoft.Office.Visio.Server.ServiceWrapper.GetVectorDiagram(String visioFileUrl, Int32 pageNumber, Boolean disableRefresh, AddonDataSource[] dataSources)
   at Microsoft.Office.Visio.Server.GetDiagramAsyncTask.GetVectorDiagram()

After some tinkering and scratching my head, these are the steps I took which made it work!

  1. First follow the steps here: http://technet.microsoft.com/en-us/library/ee524058.aspx
  2. Create an apppool that uses LocalSystem.
  3. What I did at first was to use the wrong app pool for my service. When I changed the AppPool to the one with Identity: LocalSystem, it worked!

Wednesday, 2 May 2012

An attempt to track an entity or complex type failed because the entity or complex type 'OrderEntryProject.NWservice.Customer' does not implement the INotifyPropertyChanged interface.

I got this error when working on a WCF application,
"An attempt to track an entity or complex type failed because the entity or complex type 'OrderEntryProject.NWservice.Customer' does not implement the INotifyPropertyChanged interface."
After editing the Reference.cs file for Customer class, based on http://msdn.microsoft.com/en-us/library/ms229614(v=vs.90).aspx,
I added the following code to implement INotifyPropertyChanged in the class Customer,

public partial class Customer :  INotifyPropertyChanged
    {
       public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

 ......}
And the error disappears.