Main menu:

Site search

Archives

Categories

Archive for 'Programmieren'

Javascript onload in IE7

As pointed out in many articles, if you attach multiple events to an event in Javascript, only the last one will be executed. E.g.:
window.onload = fun1;
window.onload = fun2;
/* Reload page and only fun2 will be executed */

Unfortunately the ‘+=’ operator does not work.

The solution is attachEvent(), e.g.:
window.attachEvent("onload", fun1);
window.attachEvent("onload", fun2);

This code was only tested in IE7.
I also tried approaches like the addLoadEvent, but it did not work.

SharePoint: How to always have the stack trace at hand

  1. In the web config (C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config)
  2. Got to the section
    <system.web>
  3. Add the following line: <trace enabled="true" pageOutput="true"/>
  4. issreset

For more information: http://msdn.microsoft.com/en-us/library/ms916837.aspx#sharepoint_debugwebparts_topic5

How to install/uninstall a .wsp-File with stsadm

Install:

stsadm -o addsolution -filename path\mySolution.wsp
stsadm -o execadmsvcjobs
stsadm -o deploysolution -name mySolution.wsp -immediate -allowGacDeployment -force -allcontenturls

Uninstall:

stsadm -o retractsolution -name mySolution.wsp -immediate -allcontenturls
stsadm -o execadmsvcjobs
stsadm -o deletesolution -name mySolution.wsp -override
stsadm -o execadmsvcjobs

SharePoint: How to get the Lcid out of the context

uint lcid = Convert.ToUInt32(Thread.CurrentThread.CurrentUICulture.LCID);

Get Exception Messages and Stack Trace when SharePoint/ASP.NET Error occurs

  1. Navigate to the site directory.
  2. Backup web.config.
  3. Open web.config.
  4. Switch Custom Errors off. Search for “customErrors” and set the value to “Off” instead of “On”. You can also set the value to “RemoteOnly” to troubleshoot a production issue.
  5. Enable CallStack. Search for “CallStack” and set the value to “true” instead of “false”.
  6. Save web.config.

From: http://stevepietrek.com/2007/07/28/turn-off-sharepoint-custom-error-messages/

How to get the public key out of your key file

That doesn’t work. You have to compile the assembly with the key file and then get the public key out of the assembly.
sn -T <assemblypath>
More Info:
On the difference between the key token and the key blob
Integrate this utility into Visual Studio

How to supply your assembly with a strong name

  1. Generate a file containing a strong name:sn -k Testkey.snk
  2. Reference the file in your code:using System.Reflection;
    [assembly:AssemblyKeyFileAttribute("TestKey.snk")]

More Info: MSDN-Artikel

SharePoint-Bücher

Ich habe schon einige SharePoint-Bücher gesehen. Aber das einzige das bisher überzeugte war “Inside Microsoft SharePoint Services 3.0″ von Ted Pattison.

Mit dieser Kritik stimme ich überein:

Das ultimative Werk, das sich jeder WSS V3.0- und MOSS 2007 Entwickler zulegen sollte. Die Konzepte und Architektur werden anschaulich und nachvollziehbar erklärt. Auch die Tiefe passt und es wird nicht nur an der Oberfläche gekratzt. Zusätzlich sind viele nützliche Code-Beispiele anthalten (kann man herunterladen), die man für die eigenen Projekte immer wieder als Basis einsetzen kann.

ISBN-13: 978-0735623200

Link zur Amazon-Seite

The security validation for this page is invalid. Click Back in your Webbrowser, refresh the page, and try your operation again.

- just another SharePoint exception

Lösung: Auf dem SharePoint-Objekt bei dem der Fehler auftritt AllowUnsafeUpdate auf true setzen. Z.B.
web.AllowUnsafeUpdates = true;

System.Collections in .NET

Ever wondered where to find a good overview of the collections available in the System.Collections workspace, their advantages and disadvanteges?

Here is a good MSDN article: http://www.microsoft.com/belux/msdn/nl/community/columns/jtielens/collections1.mspx