Dailycode.info

Short solution for short problems

AllowPartiallyTrustedCallers

When you are develloping web parts for a WSS based site, without using the VS 2005 Extensions, you will probably encounter this word.

I found an article on how to create Web Parts on a develop machine, not on the WSS server. It was written Dmitry Andreev on a msdn blog. He misspelled the word AllowPartiallyTrustedCallers and wrote it like this: AllowPartialTrustedCallers. Try googling for a solution then. The article said that you had to add this attribute to the assembly info. But even  when I found the correct spelling of the word (AllowPartiallyTrustedCallers=correct), my solution wouldn't compile. The reason was that you had to add the "using System.security;" on top. Now it worked fine. I copy the dll to the bin folder and the webpart shows.

Here is the url of the microsoft article with the misspelled attribute:

http://msdn2.microsoft.com/en-us/library/ms515056.aspx


Nasty problem, simple solution!

If you receive this error during, let’s say a custom search:

"Your search cannot be completed because this site is not assigned to an indexer. Contact your administrator for more information."

You’ll find a setting in Central Administration->Application Management->Content databases->(click on your database)
Third line down:
“Select Windows SharePoint Services search server ”
Select one, and now you have assigned your site to an indexer.

 


WSS 3.0 Webservices

Here is a list of all webservices and their functions:

Below is a list of all WSS 3.0 web services and their methods. This is not intended to be comprehensive documentation of each service and its methods. This is simply a quick list of web methods intended to simplify the process of finding a particular method.

Web Service
Methods

Admin Web Service
http://<AdminSite>/_vti_adm/Admin.asmx
Provides methods for managing a deployment of Microsoft Windows SharePoint Services, such as for creating or deleting site collections.
CreateSite
DeleteSite
GetLanguages
RefreshConfigCache


Alerts
http://<Site>/_vti_bin/Alerts.asmx
Provides methods for working with alerts for list items in a SharePoint site.
DeleteAlerts
GetAlerts


Authentication
http://<Site>/_vti_bin/Authentication.asmx
Login
Mode


Copy
http://<Site>/_vti_bin/Authentication.asmx
Provides methods for copying files to or from or within a SharePoint site.
CopyIntoItems
CopyIntoItemsLocal
GetItem


Document Workspace
http://<Site>/_vti_bin/Dws.asmx
Exposes methods for managing Document Workspace sites and the data they contain.
CanCreateDwsUrl
CreateDws
CreateFolder
DeleteDws
DeleteFolder
FindDwsDoc
GetDwsData
GetDwsMetaData
RemoveDwsUser
RenameDws
UpdateDwsData


Forms
http://<Site>/_vti_bin/Forms.asmx
Provides methods for returning forms that are used in the user interface when working with the contents of a list.
GetForm
GetFormCollection


Imaging
http://<Site>/_vti_bin/Imaging.asmx
Provides methods that enable you to create and manage picture libraries.
CheckSubwebAndList
CreateNewFolder
Delete
Download
Edit
GetItemsByIds
GetItemsXMLData
GetListItems
ListPictureLibrary
Rename
Upload


List Data Retrieval (StsAdapter)
http://<Site>/_vti_bin/DspSts.asmx
Represents the adapter service used to perform queries against sites and lists in Microsoft Windows SharePoint Services.
Query


Lists
http://<Site>/_vti_bin/Lists.asmx
Provides methods for working with lists and list data.
AddAttachment
AddDiscussionBoardItem
AddList
AddListFromFeature
ApplyContentTypeToList
CheckInFile
CheckOutFile
CreateContentType
DeleteAttachment
DeleteContentType
DeleteContentTypeXmlDocument
DeleteList
GetAttachmentCollection
GetList
GetListAndView
GetListCollection
GetListContentType
GetListContentTypes
GetListItemChanges
GetListItemChangesSinceToken
GetListItems
GetVersionCollection
UndoCheckOut
UpdateContentType
UpdateContentTypesXmlDocument
UpdateContentTypeXmlDocument
UpdateList
UpdateListItems


Meetings
http://<Site>/_vti_bin/Meetings.asmx
Enables you to create and manage Meeting Workspace sites.
AddMeeting
AddMeetingFromICal
CreateWorkspace
DeleteWorkspace
GetMeetingsInformation
GetMeetingWorkspaces
RemoveMeeting
RestoreMeeting
SetAttendeeResponse
SetWorkspaceTitle
UpdateMeeting
UpdateMeetingFromICal


People
http://<Site>/_vti_bin/People.asmx
ResolvePrincipals
SearchPrincipals


Permissions
http://<Site>/_vti_bin/Permissions.asmx
Provides methods for working with the permissions for a site or list.
AddPermission
AddPermissionCollection
GetPermissionCollection
RemovePermission
RemovePermissionCollection
UpdatePermission


Site Data
http://<Site>/_vti_bin/SiteData.asmx
Provides methods that return metadata or list data from sites or lists in Microsoft Windows SharePoint Services.
EnumerateFolder
GetAttachments
GetChanges
GetContent
GetList
GetListCollection
GetListItems
GetSite
GetSiteAndWeb
GetSiteUrl
GetURLSegments
GetWeb


Sites
http://<Site>/_vti_bin/Sites.asmx
Provides a method for returning information about the collection of site templates on the virtual server.
ExportWeb
GetSiteTemplates
GetUpdatedFormDigest
ImportWeb


Search
http://<Site>/_vti_bin/spsearch.asmx
The QueryService class is the entry point for calling the Search in Microsoft Windows SharePoint Services Query web service.
GetPortalSearchInfo (MOSS only)
GetSearchMetadata (MOSS only)
Query
QueryEx
RecordClick (MOSS only)
Registration
Status


Users and Groups
http://<Site>/_vti_bin/usergroup.asmx
Provides methods for working with users, role definitions, and groups.
AddGroup
AddGroupToRole
AddRole
AddRoleDef
AddUserCollectionToGroup
AddUserCollectionToRole
AddUserToGroup
AddUserToRole
GetAllUserCollectionFromWeb
GetGroupCollection
GetGroupCollectionFromRole
GetGroupCollectionFromSite
GetGroupCollectionFromUser
GetGroupCollectionFromWeb
GetGroupInfo
GetRoleCollection
GetRoleCollectionFromGroup
GetRoleCollectionFromUser
GetRoleCollectionFromWeb
GetRoleInfo
GetRolesAndPermissionsForCurrentUser
GetRolesAndPermissionsForSite
GetUserCollection
GetUserCollectionFromGroup
GetUserCollectionFromRole
GetUserCollectionFromSite
GetUserCollectionFromWeb
GetUserInfo
GetUserLoginFromEmail
RemoveGroup
RemoveGroupFromRole
RemoveRole
RemoveUserCollectionFromGroup
RemoveUserCollectionFromRole
RemoveUserCollectionFromSite
RemoveUserFromGroup
RemoveUserFromRole
RemoveUserFromSite
RemoveUserFromWeb
UpdateGroupInfo
UpdateRoleDefInfo
UpdateRoleInfo
UpdateUserInfo


Versions
http://<Site>/_vti_bin/Versions.asmx
Provides methods for working with file versions.
DeleteAllVersions
DeleteVersion
GetVersions
RestoreVersion


Views
http://<Site>/_vti_bin/Views.asmx
Provides methods for working with views of lists.
AddView
DeleteView
GetView
GetViewCollection
GetViewHtml
UpdateView
UpdateViewHtml
UpdateViewHtml2


Web Part Pages
http://<Site>/_vti_bin/WebPartPages.asmx
Provides methods for working with Web Parts.
AddWebPart
AddWebPartToZone
AssociateWorkflowMarkup
ConvertWebPartFormat
DeleteWebPart
ExecuteProxyUpdates
FetchLegalWorkflowActions
GetAssemblyMetaData
GetBindingResourceData
GetCustomControlList
GetDataFromDataSourceControl
GetFormCapabilityFromDataSourceControl
GetSafeAssemblyInfo
GetWebPart
GetWebPart2
GetWebPartCrossPageCompatibility
GetWebPartPage
GetWebPartPageConnectionInfo
GetWebPartPageDocument
GetWebPartProperties
GetWebPartProperties2
GetXmlDataFromDataSource
RemoveWorkflowAssociation
RenderWebPartForEdit
SaveWebPart
SaveWebPart2
ValidateWorkflowMarkupAndCreateSupportObjects


Webs
http://<Site>/_vti_bin/Webs.asmx
Provides methods for working with sites and subsites.
CreateContentType
CustomizeCss
DeleteContentType
GetActivatedFeatures
GetAllSubWebCollection
GetColumns
GetContentType
GetContentTypes
GetCustomizedPageStatus
GetListTemplates
GetWeb
GetWebCollection
RemoveContentTypeXmlDocument
RevertAllFileContentStreams
RevertCss
RevertFileContentStream
UpdateColumns
UpdateContentType
UpdateContentTypeXmlDocument
WebUrlFromPageUrl


Microsoft Active sync 4.5: Wireless connecton problem

I'm working with netpads which use Microsoft CE 4.0 and Microsoft CE 5.0.

When I wanted to deploy and/or debug applications with VS I had to setup a connection via Active sync. After I upgraded my active sync version from 3.7 to 4.5, I noticed that it was impossible to make a wireless connection. The option is still present but it fails to connect. When I downgraded back to 3.7 everything worked fine again. So I kept it for the moment. No time to look for another solution. Acitve sync 3.7 has all the functions I need.

Then I started working with VS 2005 and noticed that Active sync 3.7 is not supported anymore. I need to upgrade to an newer version, the only problem is that version 4 and later disabled the ethernet connection. Now it isn't possible anymore to debug using active sync and VS 2005.

The solution to this problem is debugging without the help of ActiveSync.

VS 2005 does not automatically copy the connectivity binaries down to the device. In order to use debugger on Windows CE 5.0 devices without active sync, you need to:

Step 1. Manually copy the following files down to the device

Clientshutdown.exe
ConmanClient2.exe
TcpConnectionA.dll
eDbgTL.dll
CMaccept.exe

From the desktop folder:
 <VS Install Dir>\compactframeworksdk\connectionmanager\target\wce400\<CPU Type>, to \windows on device

If you can't find EdbgTL.dll look here: <VS Install Dir>\smartdevices\debugger\target\wce400\<CPU Type>, to \windows on device

Step 2. Manually launch the conmanclient2.exe

On the device side, open the command prompt and run
Conmanclient2.exe (in case this doesn't work, try opening like this: /transport:tcpconnectiona.dll /property:port=5655 /id:Con )

Step 3. Set the correct IP address

On the desktop side, open VS 2005
Tools -> options -> device tools -> devices
Choose Windows CE 5.0 device, click on “properties”.
On the “Windows CE 5.0 device properties” dialog, click on “configure”.
On the “Configure TCP/IP” Transport dialog, choose “use specific IP address” and type in the IP address of your windows CE 5.0 device.
Click OK.

Step 4. Enable the connection (You can skip this step if the security is already disabled on the CE device by setting "HLKM\System\CoreConOverrideSecurity = 1". But disabling security may expose your device to malicious attack)

Run cMaccept.exe

Connect to the device within 3 minutes after you run cMaccept.exe. (The 3 minutes window is for the first connection. As long as you establish the first connection within 3 minutes, the following deployment/debugging sessions using the same VS instance is not limited by this 3 minutes window)

You need to perform Step 4 again when you try to connect from another instance of VS.

Now debugger is ready to go, and you should be able to deploy and debug program(s) running on Windows CE 5.0 device now.

This solution is stable, I'll never turn back to active sync, it gave me to much problems!

Source: http://blogs.msdn.com/vsdteam/archive/2005/01/05/347332.aspx and http://blogs.msdn.com/vsdteam/archive/2005/04/28/413304.aspx


Sort a generic List

When you want to sort a generic List you'll have to implement a simple IComparer class. You can sort based on a string comparer or use objects, Eg. datetime. This example implements a string comparer. PCLOC is the object and PK is the property of the object on which we want to sort the list.
    public class ToStringComparer : IComparer
    {
        public int Compare(object x, object y)
        {
            return ((MYOBJECT)x).PK.ToString().CompareTo(((MYOBJECT)y).PK.ToString());
        }
    }
 
 
public List<MYOBJECT> SortIList(List<MYOBJECT> list)
 
{
ArrayList.Adapter((IList)list).Sort(
new ToStringComparer());
 
return list;
 
}
 
 
 
Now when you want to sort you're List, you just call following code:
returnList = SortIList(returnList);
 
When you use the generic list for a regular string or int object, you can use the IList .Sort() method!
List<string> roomsList = new List<string>();
 
foreach (XmlNode nod in list)
{
    foreach (XmlNode room in nod.ChildNodes)
    {
          roomsList.Add(room.Attributes["id"].Value);
    }
}
roomsList.Sort();
 
Hope this helps?

Generic List

This is maybe the most beautifull feature of the new framework.

I use this List a lot. It has all the basic features a list needs. Sort function, find function etc. Here are some examples where I use this list:

if (list.ContainsKey(Functions.getValueFromComboBox(comboBox1)))
 

In this case I want to look up a value in the list, no more need to loop over the list! To get this value you'll have to loop over the list. You can use an easy foreach loop where you handle the comparison. Use the list with your own objects :

List <PCLOC> list= csLogic.GetComputersForRoom(_rect.Description);
 

or standard.Net objects :

List <string> computersInCS = new List<string>();

 

I don't see any reason why you should create an instance of an one dimensional array of any kind of object. Always use the Generic List. It has by default a Sort function, you can cast it to an array if you like (for databinding) and so on... Instead of using string [] sArray = new string [15]; use List<string> sList = new List<string>(); You might not need the sort or contains function now, but it could be handy later, or when specs change. The size of the list is dynamically increased. It works like an ArrayList, but there is no more boxing to be done. My advice is never use ArrayList or an array of objects when you can use the Generic list!

Josh Williams even showed in his post that an IList uses less space then an ArrayList. These are his results:             

         ArrayList    List<int>    Difference (%)
32-bit   19MB         8MB          237%
64-bit   39MB         8.1MB        481%

Read more about this on his blog.