Um in einem Testprojekt auf als internal ausgewiesene Klassen zugreifen zu können müssen diese explizit für die TestAssembly freigegeben werden. Dies erfolgt über das Attribut
[assembly: InternalsVisibleTo("VisualWebPart1Tests")]
Ist die zu testende Klasse mit einem Strongkey signiert, muss auch das TestAssembly mit einem StrongKey signiert werden. Bei der Freigabe muss dann aber zusätzlich der PublicKey (nicht PublicKeyToken) der Test-Assembly angeben werden.
[assembly: InternalsVisibleTo("VisualWebPart1Tests, PublicKey=XXX")]
Diesen kann man unter anderem mit den folgenden Befehlen aus dem zur Signierung der Test-Assembly verwendeten Key-File extrahieren
sn.exe -p ..\..\key.snk publickey.snk
Sollte hierbei der Fehler
Failed to extract public key from key pair -- Bad Version of provider.
angezeigt werden handelt es beim key.snk bereits um ein publickey-File
den eigentlichen Publickey erhält man mit
sn.exe -tp
publickey.snk > publickey.txt
Freitag, 23. Dezember 2011
Mittwoch, 21. Dezember 2011
Unsichtbare WebParts auf Wiki Seiten
Mischa Mundwiler beschreibt ein fehlerhaftes Verhalten im Zusammenspiel von Filterwebparts und Wiki-Seiten.
Diese werden im Edit-Modus nicht angezeigt
http://sharepoint.namics.com/2010/05/stolperfalle-we.html
Freitag, 16. Dezember 2011
Liste aller Sharepoint Features
unter http://bit.ly/shpntftres gibt es eine Liste aller Sharepoint features
Labels:
2010,
Feature,
Features,
Sharepoint
Mittwoch, 7. Dezember 2011
Loginname von All authenticated users
Möchte man über das OM "All authenticated users" zu einer Gruppe hinzufügen, benötigt man dessen Loginnamen.
Dieser ist etwas kryrptisch, und sieht wie folgt aus "c:0(.s|true".
Gefunden bei Yaroslav Pentsarskyy
http://bit.ly/rqkQ72
Donnerstag, 1. Dezember 2011
Case sensitive Werte in Field Definitions
Attribute vom Typ "boolean" in einer Field Definition sind case sensitive.
Probleme machen vor allem die folgende Attribute:
Filterable="FALSE"
ShowInNewForm="FALSE"
d.h. immer "FALSE" bzw. "TRUE" verwenden.
Labels:
case,
Definition,
Field,
Sharepoint,
SPField
Montag, 28. November 2011
BreakRoleInheritance und AllowUnsafeUpdates
Wird auf einem SPWeb-Objekt die Methode BreakRoleInheritance aufgerufen wird der Wert der Property AllowUnsafeUpdates auf false gesetzt.
web.AllowUnsafeUpdates = true;
web.BreakRoleInheritance(false);
web.AllowUnsafeUpdates = true;
Weitere Infos zu AllowUnsafeUpdates unter:
http://hristopavlov.wordpress.com/2008/05/16/what-you-need-to-know-about-allowunsafeupdates/
web.AllowUnsafeUpdates = true;
web.BreakRoleInheritance(false);
web.AllowUnsafeUpdates = true;
Weitere Infos zu AllowUnsafeUpdates unter:
http://hristopavlov.wordpress.com/2008/05/16/what-you-need-to-know-about-allowunsafeupdates/
Freitag, 25. November 2011
Custom WebPart zu einer WebPartpage hinzufügen
Um ein Custom WebPart zu einer Page hinzuzufügen benötigt man eine Instanz der spezifischen WebPart-Klasse. Steht einem In dem Moment keine Referenz zu entsprechenden Assembly zur Verfügung kann man sich mit Hilfe eines ObjectHandle eine Instanz erzeugen.
Dazu benötigt man den Klassennamen und den kompletten Assembly-Namen
Die Werte für typeName und Assembly können auch über eine Query auf die WebPartGallery ermittelt werden
Dazu benötigt man den Klassennamen und den kompletten Assembly-Namen
String typeName = "Klassenname";
String assemblyName = "Assembly Name");
ObjectHandle webPartHandle = Activator.CreateInstance(assemblyName, typeName);
WebPart webPart = (WebPart)webPartHandle.Unwrap();
webParts[0].GetFormattedValue("WebPartTypeName")
Die Werte für typeName und Assembly können auch über eine Query auf die WebPartGallery ermittelt werden
SPQuery query = new SPQuery();
query.Query = string.Format("{0}", webpartname);
SPList webPartGallery = this.site.RootWeb.GetCatalog(SPListTemplateType.WebPartCatalog);
SPListItemCollection webParts = webPartGallery.GetItems(query);
String typeName =webParts[0].GetFormattedValue("WebPartTypeName");
String assemblyName = webParts[0].GetFormattedValue("WebPartAssembly");
Montag, 21. November 2011
WebPart Audience
Der string für WebPart.AuthorizationFilter setzt sich wie folgt zusammen:
string[] globalAudienceIDs = new string[] {"e4687e64-c9d8-4860-bbc3-ec036bf9915d"};
string[] dlDistinguishedNames = new string[] {"cn=group1,cn=users,dc=spdev,dc=com", "cn=group2,cn=users,dc=spdev,dc=com"};
string[] sharePointGroupNames = new string[] {"Demo Members", "Demo Owners"};
string result = string.Format("{0};;{1};;{2}",
string.Join(",", globalAudienceIDs),
string.Join("\n", dlDistinguishedNames),
string.Join(",", sharePointGroupNames));
d.h. soll eine Sharepoint Gruppe hinzugefügt werden sieht der string wie folgt aus :
";;;;Gruppenname" bzw.
";;;;Gruppenname1, Gruppenname2"
von
Lapointe Blog -Eintrag
Dienstag, 8. November 2011
Montag, 7. November 2011
Thmxtheme.ApplyTo und SPContext
Sharepoint 2010 Themes können über das ObjectModel nur innerhalb der SiteCollection aktiviert werden, auf die sich der aktuelle SPContext bezieht.
Die sicherste Methode ist das Theme über einen Web-EventReciever der auf WebProvisioned reagiert zu setzen. Alle anderen Versuche haben immer wieder zu Problemen geführt.
Siehe auch
http://sadomovalex.blogspot.com/2010/08/fix-security-validation-for-this-page.html
Die sicherste Methode ist das Theme über einen Web-EventReciever der auf WebProvisioned reagiert zu setzen. Alle anderen Versuche haben immer wieder zu Problemen geführt.
Siehe auch
http://sadomovalex.blogspot.com/2010/08/fix-security-validation-for-this-page.html
Implement IDisposable Correctly
http://msdn.microsoft.com/en-us/library/ms244737(v=vs.80).aspx
public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } // NOTE: Leave out the finalizer altogether if this class doesn't // own unmanaged resources itself, but leave the other methods // exactly as they are. ~Resource() { // Finalizer calls Dispose(false) Dispose(false); } // The bulk of the clean-up code is implemented in Dispose(bool) protected virtual void Dispose(bool disposing) { if (disposing) { // free managed resources if (managedResource != null) { managedResource.Dispose(); managedResource = null; } } }
MeetingWorkspace in Calendar verstecken
Setzt man das Feld WorkspaceLink eines Kalenders auf hidden kann auch für diesen Kalender kein Meetingworkspace angelegt werden.
var list = web.Lists["Events"];
var field = list.Fields[SPBuiltInFieldId.WorkspaceLink];
field.Hidden = true;
field.Update();
Gefunden auf
http://www.sharepointblues.com/2010/04/26/how-to-remove-workspace-link-from-a-calendar/
var list = web.Lists["Events"];
var field = list.Fields[SPBuiltInFieldId.WorkspaceLink];
field.Hidden = true;
field.Update();
Gefunden auf
http://www.sharepointblues.com/2010/04/26/how-to-remove-workspace-link-from-a-calendar/
Adding a Taxonomy Field
TermStore termStore = session.DefaultKeywordsTermStore;
Group group = termStore.GetSiteCollectionGroup(this.site);
TermSet termset = group.TermSets[0];
TaxonomyField field = (TaxonomyField)list.Fields.CreateNewField("TaxonomyFieldType", name);
field.Required = required;
field.Description = description;
field.SspId = termStore.Id;
field.TermSetId = termSet.Id;
field.AllowMultipleValues = allowsMultiple;
field.EnforceUniqueValues = enforceUniqueValues;
field.IsPathRendered = renderpath;
// field must be indexed to enfoce unique values!
field.Indexed = enforceUniqueValues;
Term anchor = termSet.GetTermByPath(anchorPath);
field.AnchorId = anchor.Id;
field.NoCrawl = noCrawl;
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.taxonomysession.aspx
http://www.communardo.de/home/techblog/2011/10/18/sharepoint-2010-der-termstore-und-der-priviligierte-nutzer/
Was wird durch die folgende Methode veranlasst?
Möglicher Fix für Probleme nach Content Deployment
// Resync the taxonomy hidden list to make sure it is update-to-date
TaxonomySession.SyncHiddenList(site);
DisplaceOnUpgrade
Optional Boolean. If a field definition already exists for the field, TRUE to force updates to field properties with the values that are specified in this field definition.
http://www.sharepointconfig.com/2011/03/the-complete-guide-to-provisioning-sharepoint-2010-managed-metadata-fields/
Group group = termStore.GetSiteCollectionGroup(this.site);
TermSet termset = group.TermSets[0];
TaxonomyField field = (TaxonomyField)list.Fields.CreateNewField("TaxonomyFieldType", name);
field.Required = required;
field.Description = description;
field.SspId = termStore.Id;
field.TermSetId = termSet.Id;
field.AllowMultipleValues = allowsMultiple;
field.EnforceUniqueValues = enforceUniqueValues;
field.IsPathRendered = renderpath;
// field must be indexed to enfoce unique values!
field.Indexed = enforceUniqueValues;
Term anchor = termSet.GetTermByPath(anchorPath);
field.AnchorId = anchor.Id;
field.NoCrawl = noCrawl;
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.taxonomysession.aspx
http://www.communardo.de/home/techblog/2011/10/18/sharepoint-2010-der-termstore-und-der-priviligierte-nutzer/
Was wird durch die folgende Methode veranlasst?
Möglicher Fix für Probleme nach Content Deployment
// Resync the taxonomy hidden list to make sure it is update-to-date
TaxonomySession.SyncHiddenList(site);
DisplaceOnUpgrade
Optional Boolean. If a field definition already exists for the field, TRUE to force updates to field properties with the values that are specified in this field definition.
http://www.sharepointconfig.com/2011/03/the-complete-guide-to-provisioning-sharepoint-2010-managed-metadata-fields/
Labels:
2010,
ListView,
Managed Meta Data; Taxonomy,
Sharepoint
the default termstore for site cannot be identified
Wird beim Versuch den SiteCollecttion Termstore zu aktivieren die Fehlermeldung
"the default termstore for site cannot be identified" angezeigt, muss in der Central Administration für die Managed Meta Data Service Application die entsprechende Property gesetzt warden.
Wird unter den folgenden URLs genauer beschrieben
http://www.sharepointfabian.com/blog/Lists/Posts/Post.aspx?ID=186
http://www.bfcnetworks.com/the-default-termstore-for-this-site-cannot-be-identified/
"the default termstore for site cannot be identified" angezeigt, muss in der Central Administration für die Managed Meta Data Service Application die entsprechende Property gesetzt warden.
Wird unter den folgenden URLs genauer beschrieben
http://www.sharepointfabian.com/blog/Lists/Posts/Post.aspx?ID=186
http://www.bfcnetworks.com/the-default-termstore-for-this-site-cannot-be-identified/
Montag, 28. Februar 2011
Problem with SPSiteDataQuery
... that SPSiteDataQuery always treats fields of type TaxonomyFieldTypeMulti as empty fields (remember that Language field is mandatory and all documents have some values in it)
http://sadomovalex.blogspot.com/2011/02/problem-with-spsitedataquery-and.html
http://sadomovalex.blogspot.com/2011/02/problem-with-spsitedataquery-and.html
Donnerstag, 17. Februar 2011
DisableLoopbackCheck on Error 401.1
Wenn Sie mithilfe des vollqualifizierten Domänennamens (FQDN) oder eines
benutzerdefinierten Hostheaders eine lokale Website aufrufen, die auf einem
Computer mit Microsoft Internet Information Services (IIS) 5.1 oder höher
gehostet wird, wird möglicherweise eine Fehlermeldung etwa folgenden Inhalts
angezeigt:
http://support.microsoft.com/kb/896861
HTTP 401.1 - Unautorisiert: Anmeldung
fehlgeschlagen
http://support.microsoft.com/kb/896861
Adding paging to SPGridView
oGrid.PageSize = 3;
oGrid.AllowPaging = true;
oGrid.PageIndexChanging += new GridViewPageEventHandler (oGrid_PageIndexChanging);
oGrid.PagerTemplate = null;
// Must be called after Controls.Add(oGrid)
http://blogs.msdn.com/powlo/archive/2007/03/23/Adding-paging-to-SPGridView-when-using-custom-data-sources.aspx
oGrid.AllowPaging = true;
oGrid.PageIndexChanging += new GridViewPageEventHandler (oGrid_PageIndexChanging);
oGrid.PagerTemplate = null;
// Must be called after Controls.Add(oGrid)
http://blogs.msdn.com/powlo/archive/2007/03/23/Adding-paging-to-SPGridView-when-using-custom-data-sources.aspx
Unit testing Sharepoint
To get
started read this
|
Some interesting Links
Roy Osherove (Der ausm Biergarten)
Homepage
21Apps
Homepage
Richard Fennell (blackmarble)
Is Pex and Moles the answer to Sharepoint testing?
Channel9
Pex - Unit Testing of SharePoint Services that Rocks! ( Video, classified as unwanted by your administrator)
Video: Unittesting Sharepoint That Rocks ( Stored on S: )
Microsoft Research
Pex Project
Pex and Moles - Getting Started with Pex
Unit Testing SharePoint Foundation with Microsoft Pex and Moles (PDF)
Downloads
PEX Academic (MSI)
TypeMock
Exception on starting Unittests
If you recieve this error during starting Unittests in Visual Studio
just open the "Team Explorer" and let VisualStudio establish a connection to TFS
Get all workflows associated with an item
SPWorkflowAssociationCollection.GetAssociationByBaseID(Guid BaseID) only
returns "activated" workflows.
This means only workflows which have AutoStartCreate, AutoStartChange or AllowManual set to true will be returned.
To get all workflows associated with the item, just enumerate over the WorkflowAssociations member.
This means only workflows which have AutoStartCreate, AutoStartChange or AllowManual set to true will be returned.
To get all workflows associated with the item, just enumerate over the WorkflowAssociations member.
Approval of Listitems and Folders
Approving a Listittem
SPListItem item = …;
item.File.Approve("Initial Version");
Approving a folder
SPFolder folder = … ;
SPListItem li = folder.Item;
li.ModerationInformation.Status = SPModerationStatusType.Approved;
li.Update();
Using Moles with 64Bit
Add the following Directive to each Testclass
[assembly: MolesAssemblySettings(Bitness = MolesBitness.x64)]
CSS styles used on Team Site
The following table summarizes selected top-level elements and CSS styles used on the default Team Site home page. Use this table as a starting point for understanding how to use cascading style sheets to customize SharePoint Foundation
http://msdn.microsoft.com/en-us/library/ms438349.aspx
http://msdn.microsoft.com/en-us/library/ms438349.aspx
Mittwoch, 16. Februar 2011
Do not use "MaintainScrollPositionOnPostBack = true" in WebParts
Using "this.Page.MaintainScrollPositionOnPostBack = true" will break javascript functions on the Webpage
xmlnamespace without prefix
Regarding the following XML, the XPath-Expression "//title" will only return the second title node.
The reason is the Namespace "withoutPrefix" which is defined without any Prefix, applying to all "nacked" nodes.
To retrieve the first title node, a "default" Prefix has to be added to the Namespacemanger.
Add the defined Prefix to your xPath-Expression and you 'll get the node.
The reason is the Namespace "withoutPrefix" which is defined without any Prefix, applying to all "nacked" nodes.
To retrieve the first title node, a "default" Prefix has to be added to the Namespacemanger.
Add the defined Prefix to your xPath-Expression and you 'll get the node.
<rootnode>
<firstnode xmlns="withoutPrefix" xmlns:inf="withPrefix">
<title>the first title</title>
<inf:type>nonsense</inf:type>
</firstnode>
<secondnode xmlns:inf="withPrefix">
<title>the second title</title>
<inf:type>crap</inf:type>
</secondnode>
</rootnode>
nsmgr.AddNamespace("default", "withoutPrefix");
string xPath = "//default:title");
Adding a ListViewWebPart to Page
[UPDATE 01.Feb.2012: wp.ViewGuid = string.Empty gilt nur für 2007]
Hier eine Erklärung für 2010
[ENDUPDATE]
[UPDATE: Set View to "Summary View"]
using Microsoft.SharePoint; using Microsoft.SharePoint.WebPartPages; // Get a reference to a web and a list SPSite site = new SPSite("http://localhost:8000"); SPWeb web = site.OpenWeb(); SPList list = web.Lists["Contacts"]; // Instantiate the web part ListViewWebPart wp = new ListViewWebPart(); wp.ZoneID = "Left"; wp.ListName = list.ID.ToString("B").ToUpper();
// wp.ViewGuid = list.DefaultView.ID.ToString("B").ToUpper();
// Set the ViewGuid to string.Empty to get the "Summery View"
// including the "Add New Item"-Button
// Thanks to sadomovalewp.ViewGuid = string.Empty;
// Get the web part collection SPWebPartManager mgr = new SPWebPartManager("default.aspx", Storage.Shared);
// Add the web part
coll.Add(wp);
Labels:
2007,
2010,
ListView,
ListViewWebPart,
Sharepoint
Donnerstag, 25. November 2010
Montag, 22. November 2010
Future of Silverlight Starts Now
The Future of Silverlight Starts Now
Hear the official news about what's coming up next for Silverlight from Scott Guthrie, Microsoft Corporate Vice President.
Hear the official news about what's coming up next for Silverlight from Scott Guthrie, Microsoft Corporate Vice President.
Managed MetaData
TechNet: Managed metadata overview (SharePoint Server 2010)
Adding a managed metadata column to a list via SharePoint Server 2010 object modelThis article introduces the core concepts about managed metadata, and then describes the way you use managed metadata. An example is used throughout this article to illustrate the concepts. The final section presents several benefits of incorporating managed metadata into your SharePoint Server 2010 solution.
By Peter Holparmy solution for adding managed metadata type field to lists.
Sonntag, 21. November 2010
Scrum and Visual Studio
Link
Die von vielen Anwendern lange ersehnte Prozessvorlage Microsoft® Visual Studio® Scrum 1.0ist ab sofort als kostenloser Download verfügbar. Bei Microsoft Visual Studio Scrum 1.0 handelt es sich um ein umfassendes Prozesstemplate für Team Foundation Server zur professionellen Abbildung eines vollständigen Scrum-Prozesses mit Visual Studio und Team Foundation Server. Microsoft Visual Studio Scrum 1.0 ergänzt damit die beiden vorhandenen Prozesstemplates MSF for CMMI® Process Improvement und MSF for Agile Software Development.
Mittwoch, 10. November 2010
Sonntag, 7. November 2010
Donnerstag, 28. Oktober 2010
Never remove SharePointWebControls:TextField runat="server" FieldName="Title"
<PublishingWebControls:EditModePanel runat="server" CssClass="edit-mode-panel">
<SharePointWebControls:TextField runat="server" FieldName="Title" />
</PublishingWebControls:EditModePanel>
Why?? What was the Problem
Why?? What was the Problem
Dienstag, 26. Oktober 2010
How to Add a ListViewWebPart to a Publishing Page
neuer Versuch das ListViewWebPart zu verstehen
Adding a ListViewWebPart to a "Publishing Page" is easy.
Create a Instance of a SPWebpartmanager, with the relevant Page-Url and get the WebPartCollection.
Create a new ListViewWebPart instance, set the ListID to the ID of SPList object you want to show.
Provide a ViewID to the Webpart and add it to the Collection, including the ID of the WebPartZone and a Sequence Number for the order within the zone.
Showing a Document Library including the "Add document" Button isn't easy at all.
In the UI it is just a click away -> Edit WebPart -> select ToolbarType and set it to "Summary ToolBar".
I think its almost default in UI.
[UPDATE: see adding-listviewwebpart-to-page]
If you want to use OM to add this WebPart you have to use a "hack" by modifying the schema of the used view. Which can affect also the view of the document library.
Jalil Sear describes it at his blog listviewwebpart-programatically-setting-the-toolbartype-property/
I worked around this issue by adding my own "Add Document" button to the page, having the possibillity of positioning, using audiences and renaming.
[UPDATE: see adding-listviewwebpart-to-page]
Labels:
2010,
ListView,
ListViewWebPart,
Sharepoint,
ToolbarType,
WebPart
Multiselect in MultiChoice
To get a default Selection of a Multichoice Field defined in a listdefinition
use the DefaultFormula-Tag
<list>
use the DefaultFormula-Tag
<list>
<CHOICES>
<CHOICE>Legal</CHOICE>
<CHOICE>Tax</CHOICE>
<CHOICE>Accounting</CHOICE>
<CHOICE>Asset Liability Management</CHOICE>
<CHOICE>Shareholdings</CHOICE>
<CHOICE>Risk Management</CHOICE>
</CHOICES>
<DefaultFormula>=";#Legal;#Tax;#Accounting;#Asset Liability Management;#Shareholdings;#Risk Management;#"</DefaultFormula>
</list>
Sonntag, 17. Oktober 2010
Das mächtige Sharepoint:DelegateControl
Chiris O'Brian beschreibt die Verwendung des DelegateControls unter MOSS 2007.
http://www.sharepointnutsandbolts.com/2007/06/using-delegate-control.html
panvega erklärt das DelegateControl in seinem Blog etwas ausführlicher
http://panvega.wordpress.com/2008/10/12/sharepoint-delegate-controls/
Für Sharepoint 2010 hat sich an dieser Stelle nichts geändert.
Ruchi hat in seinem Kommentar bzgl. Parametern auf folgenden MSDN -Artikel verwiesen:
IMHO sind Delegatecontrols eine einfache aber mächtige Methode um eine Sharepoint Site um Funktionalitäten zu erweitern bzw. auch um standardkomponenten auszutauschen.
In vielen Fällen kann man statt einem Webpart ein DelegateControl verwenden
http://www.sharepointnutsandbolts.com/2007/06/using-delegate-control.html
panvega erklärt das DelegateControl in seinem Blog etwas ausführlicher
http://panvega.wordpress.com/2008/10/12/sharepoint-delegate-controls/
Für Sharepoint 2010 hat sich an dieser Stelle nichts geändert.
Ruchi hat in seinem Kommentar bzgl. Parametern auf folgenden MSDN -Artikel verwiesen:
IMHO sind Delegatecontrols eine einfache aber mächtige Methode um eine Sharepoint Site um Funktionalitäten zu erweitern bzw. auch um standardkomponenten auszutauschen.
In vielen Fällen kann man statt einem Webpart ein DelegateControl verwenden
Abonnieren
Posts (Atom)