Friday, December 12, 2008

Cant hit breakpoints in sharepoint debugging?

You are trying to debug some sharepoint code and when attaching the debugger you cant get the breakpoints to hit? Most important, recheck everything you have done...if in gac the path is c:\windows\assembly\gac_msil\assmblyname\version__pubkeytoken\

1.0.0.0 is not 1.0.0.0.0 ...this can make you loose some time...right? ;)

still, here are some sort of checklist and some last resort tactics, 'taken' from this post.

  • Did the solution really compile? I see sometimes developers causing a large amount of warnings causing not to see if there were any errors present. Then they copy the old assemblies to the bin folder or install them to the GAC causing this problem.
  • Are you connecting to the right w3wp.exe process? Is it not a non-closed browser instance?
  • Use IISRESET or better Recycle the Application Pool of your Web Application
  • Check if the compiled assemblies are the same one placed in the bin folder or the GAC. Even if there is nothing changed between compiled versions of assemblies it could cause problems with debugging.
  • It could be that the instance of the browser is using a cached assembly version. As you know when starting ASP.NET applications it caches the runtime versions of the assemblies. Clear the .NET Framework temporarily internet folder and subfolders. This folder is:
    "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files". If you are not able to clear this make sure that you did an IISRESET, closed all browser instances and closed Visual Studio.
  • If you are developing by putting the assembly into the bin folder, make sure that the instance of the browser is not using a GAC deployed version of the solution. I have seen this happening with collegaes which by accident used the wrong batch file for deployment on their development machine. The GAC version was accessed instead of the assembly in the bin folder.
  • Finally if you are working in a VPC or VMWare environment it could be that by using the debugger too often the whole environment is messed up. In that case do a restart of the environment and walk through the all the above points again

More on debugging here, and this very masoquist guy even goes to assembly level on sharepoint debugging(?!?!?!?)...i read it diagonally but theres asm on the post :-O


Thursday, October 9, 2008

Imagine

Imagine you create a incremental deployment job that runs every 15min. Imagine after a while something is going wrong...you look and the sql server and it has 0 bytes free :o

You start browsing the files and the wss_content_log has 10Gb... wtf?!?

change the recovery model to simple and then use this sql to trunk the db

BACKUP LOG wss_content WITH TRUNCATE_ONLY
DBCC SHRINKFILE(wss_content_log,2)


this worked out for me hope it helps, tks ricardo :D

Sunday, October 5, 2008

Fábrica Braço de Prata

I was browsing http://www.bracodeprata.org/, a nice library with good concerts here in Lisbon, when i got this nice page on my browser, bad bad practice..you can see the VB (uhhhh) code...custom errors going public? ...someone should be fired :P

Thursday, September 18, 2008

Dates and FullTextSqlQuery

When comparing dates in a FullTextSqlQuery remember the date literal must be surrounded by single quotes and formatted in YYYY-MM-DD format.

Example: 

SELECT Title,FileExtension,ContentType,Path FROM SCOPE() WHERE  owsStartDate > '2003-12-01'

Trying to use an SPWeb object that has been closed or disposed and is no longer valid

This is one is an olddie but it's never too much, when using SPWeb and SPSite, you should remember the Context, so when doing

using (SPWeb web = SPContext.Current.Web)
{
...
}

You will get a nice "Trying to use an SPWeb object that has been closed or disposed and is no longer valid" because you are disposing an object you really didnt create.

Best practices here.

An unexpected error has occurred

I was tired of looking into my mail for this, so i guess that putting in my blog was a easy way to get this info... How to show debug messagens in MOSS. Basically if have to change the web.config of the Web Application in question:

1.     Change CallStack="false" to   CallStack="true"

2.     Change customerrors mode="On"  to   customerrors mode="Off" 

3.     Change compilation batch="false" debug="false"  to   compilation batch="false" debug="true"

Full Articles here, and here.

Tuesday, September 2, 2008

Setting Current Navigation programatically

In the MOSS UI you can set Current Navigation to any of these options:

  • Display the same navigation items as the parent site
  • Display the current site, the navigation items below the current site, and the current site's siblings
  • Display only the navigation items below the current site
But if you wantto do it programatically how can you?

The default is "Display the current site, the navigation items below the current site, and the current site's siblings" so you dont need to care, when adding a web.

Hope this helps for other options, and you dont need to loose time looking and testing.

//Sets Current Navigation to Display the same navigation items as the parent site
pubWeb.InheritCurrentNavigation = true;
pubWeb.NavigationShowSiblings = false;
pubWeb.Update();

//Sets Current Navigation to Display only the navigation items below the current site
pubWeb.NavigationShowSiblings = false;
pubWeb.Update();
}

Monday, June 23, 2008

Event Handlers

If you are working with event handlers in sharepoint and having troubles updating, changing properties and roles plz remember:

in short: IF you're trying to impersonate using RunWithElevatedPrivileges, ALWAYS follow the practice of creating a NEW SPSite inside the RunWith... block. You can grab the current site ID from the event properties object, and then instantiate a new SPSite by e.g.:

using (SPSite theSite = new SPSite(properties.OpenWeb().Site.ID)) {...}


o after some research, here is my solution: item[fieldnamehere] = fieldvaluehere; this.DisableEventFiriing(); item.SystemUpdate(false); this.EnableEventFiring();

This piece of code updates the item without firing the current event handler events, and doing the update using the SystemUpdate(false) method ensures that version number doesnt increase and the update is considered as if it was part of the user's update.


found one thing about this code. You don't need to do the Item.Update() command when you change Roles atribute of the item.
This Prevents unexpected errors or strange behaviours when you attach this event handler to an Publishing pages Library or some list with version control and Check-in Check-out control to allow item changes.
It worked well to me this way.


these sentences saved my afternoon, read them in their respective blogs

EventHandler Impersonation

Preventing Event Handler Recursion

Uploading a file eventhandler

event handler to set permissions

great great resources

Monday, May 26, 2008

Free Enterprise Search Training

Microsoft is ofering free traning on Enterprise Search Solutions, with nice recorded presentations of a 3 day training session.

If you have the time check them out:

Module 1: Workshop Overview (http://go.microsoft.com/fwlink/?LinkId=115635&clcid=0x409)
Module 2: Enterprise Search Overview (http://go.microsoft.com/fwlink/?LinkId=115636&clcid=0x409)
Module 3: SharePoint Search 2007 Walkthrough (http://go.microsoft.com/fwlink/?LinkId=115637&clcid=0x409)
Module 4: Search Architecture and Deployment Scenarios (http://go.microsoft.com/fwlink/?LinkId=115638&clcid=0x409)
Module 5: Crawl and Query Processes (http://go.microsoft.com/fwlink/?LinkId=115639&clcid=0x409)
Module 6: Relevance Ranking (http://go.microsoft.com/fwlink/?LinkId=115640&clcid=0x409)
Module 7: Customizing the End-User Experience (http://go.microsoft.com/fwlink/?LinkId=115641&clcid=0x409)
Module 8: Developing Search Solutions (http://go.microsoft.com/fwlink/?LinkId=115642&clcid=0x409)
Module 9: Business Data Catalog Search (http://go.microsoft.com/fwlink/?LinkId=115643&clcid=0x409)
Module 10: Extensibility and Integration for Search (http://go.microsoft.com/fwlink/?LinkId=115644&clcid=0x409)
Module 11: Search Administration (http://go.microsoft.com/fwlink/?LinkId=115646&clcid=0x409)
Module 12: Security for Search (http://go.microsoft.com/fwlink/?LinkId=115647&clcid=0x409)
Module 13: Performance Scalability and Capacity Planning for Search (http://go.microsoft.com/fwlink/?LinkId=115648&clcid=0x409)
Module 14: Search Operations (http://go.microsoft.com/fwlink/?LinkId=115649&clcid=0x409)

Friday, April 18, 2008

Customizing Content Query Web Part

There are alot of places where it explains how to change the look of this great webpart, and well, i thk this[http://www.microsoft.com/belux/msdn/nl/community/columns/stevenvandecraen/contentquerywebpart.mspx]
is very well resumed, with almost everything you need

Wednesday, April 16, 2008

Publishing Sites

It has been said in other blogs but here it goes again:

Never use underscores "_" in the name of the server, if you do so you might have this bad bad message when Starting Workflows and submitting stuff to aproval:

"The form cannot be displayed in the browser because the use of session cookies has been disabled in the current browser settings. In order to load the form, session cookies must be allowed."

The good thing is that even you already have the underscore, you can still use Firefox he doesnt bother with the "_" and it works ok.

Monday, April 14, 2008

My first tip

Using ?contents=1 after an aspx page, it will send you to the web part maintenance web page, there you can find all WP in your page and those that arent displaying in your webpage, and might be in conflit with something.

something like this:

http://site/Pages/Default.aspx?contents=1

My first post

Hi, welcome to this blog. This is a way to give something in return for the help i have found in all the blogs and sites across the web about sharepoint. I hope it will help you.