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();
}