Sladescross's Blog

Blogging about Sharepoint related stuff

Sharepoint 2010 Disabling List View Threshold April 25, 2010

Filed under: .NET,List View Threshold — sladescross @ 3:59 pm


http://blogs.msdn.com/sharepoint/archive/2010/04/23/temporarily-disabling-list-view-threshold-on-a-large-list.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+sharepointteamblog+%28Microsoft+SharePoint+Products+and+Technologies+Team+Blog%29

 

PDB Files March 12, 2010

Filed under: .NET,Debugging,PDB,Symbols — sladescross @ 12:14 am


http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/05/11/pdb-files-what-every-developer-must-know.aspx

As John Cunningham, the development manager for all things diagnostics on Visual Studio, said at the 2008 PDC, “Love, hold, and protect your PDBs.” At a minimum, every development shop must set up a Symbol Server. I’ve written about Symbol Servers in MSDN Magazine and more extensively in my book, Debugging .NET 2.0 Applications. You can also read the Symbol Server documentation itself in the Debugging Tools for Windows help file. Look at those resources to learn more about the details. Briefly, a Symbol Server stores the PDBs and binaries for all your public builds. That way no matter what build someone reports a crash or problem, you have the exact matching PDB file for that public build the debugger can access. Both Visual Studio and WinDBG know how to access Symbol Servers and if the binary is from a public build, the debugger will get the matching PDB file automatically.

On the other machine, what I’ve seen numerous developers do after using GACUTIL to put the assembly into the GAC is to open up a command window and dig around in C:\WINDOWS\ASSEMBLY\ to look for the physical location of the assembly on disk. While it is subject to change in the future, an assembly compiled for Any CPU is actually in a directory like the following:

C:\Windows\assembly\GAC_MSIL\Example\1.0.0.0__682bc775ff82796a

Example is the name of the assembly, 1.0.0.0 is the version number, and 682bc775ff82796a is the public key token value. Once you’ve deduced the actual directory, you can copy the PDB file to that directory and the debugger will load it.

If you’re feeling a little queasy right now about digging through the GAC like this, you should, as it is unsupported and fragile. There’s a better way that seems like almost no one knows about, DEVPATH. The idea is that you can set a couple of settings in .NET and it will add a directory you specify to the GAC so you just need to toss the assembly and it’s PDB file into that directory so debugging is far easier. Only set up DEVPATH on development machines because any files stored in the specified directory are not version checked as they are in the real GAC.

 

Class Master March 10, 2010

Filed under: .NET,Tool — sladescross @ 9:25 pm


http://www.topshareware.com/ClassMaster-download-43449.htm

 

Non-Compliant CLS Types In Powershell March 1, 2010

Filed under: .NET,CLS,Non-Compliant,Powershell — sladescross @ 3:49 pm


http://www.nivot.org/2007/10/24/NonCLSCompliantTypesInPowerShell.aspx

One of the rules of a so-called “CLS compliant type” (cls = common lanaguage specification) is that you should not expose any public members that only differ in casing. The SPContentDatabase type has two properties, “Id” and “ID.” This is perfectly legal in C# since case in important in that language and the compiler sees them as different as chalk and cheese. However, in VB.NET, case is not important and as such it [vb] has no native mechanism to differentiate between the two. The same goes for PowerShell’s grammar. So, how do we get around this?

First, you grab a handle to the method directly by asking for it from the Type itself:

PS> $idMethod1 = [Microsoft.SharePoint.Administration.SPContentDatabase].getmethod(“get_ID”)

and for the second version,

PS> $idMethod2 = [Microsoft.SharePoint.Administration.SPContentDatabase].getmethod(“get_Id”)

Note the differing case for get_Id and get_ID. Btw, Properties like ID in .NET are actually served by special accessor methods prefixed with get_ and set_, hence the prefixes. Next, you need a way to invoke those methods on the instance itself: this is done by using the Invoke method on the MethodInfo object representing the method itself. You pass the instance to the Invoke method telling it that the method is “instance” (e.g. not static/shared) and “public” and it will call that method for you on the instance, returning the value, if any.

PS> $result = $idMethod1.Invoke($site.ContentDatabase, “instance,public”, $null, $null, $null)


http://blogs.msdn.com/carloshm/archive/2009/06/05/how-to-programmatically-read-the-changelog-in-powershell.aspx

Call overloaded non-compliant method in Powershell. GetChanges.

function Display_ChangeTokens_For_ContentDatabase([string] $ServerName, [string] $SiteCollectionName, [string] $ChangeCSVFile)
{

 $spsite = new-object Microsoft.Sharepoint.SPSite($ServerName + $SiteCollectionName);

 $spcontentdatabaseidmethod =  [Microsoft.SharePoint.Administration.SPContentDatabase].getmethod(“get_ID”);
 $spcontentdatabaseguid = $spcontentdatabaseidmethod.Invoke($spsite.ContentDatabase, “instance,public”, $null, $null, $null);

 $spcontentdatabaseguid.ToString() | select;

 $spcontentdatabasemethods = [Microsoft.SharePoint.Administration.SPContentDatabase].GetMethods(“instance,public”);

 $spcontentdatabasemethods | foreach-object {

  if ($_.name -eq “GetChanges”)
  {

   $parameters = @($_.GetParameters())

   # Call Overloaded GetChanges Without Parameters

   if($parameters.Count -eq 0)
   {

    $spcontentdatabasechanges = $_.Invoke($spsite.ContentDatabase, “instance,public”, $null, $null, $null);
    #$spcontentdatabasechanges | select;

    $spcontentdatabasechanges | foreach-object {

     #$spcontentdatabasechanges.Id + ” ” + ” ” + $spcontentdatabasechanges.ChangeType + ” ” + $spcontentdatabasechanges.SiteId + ” ” + $spcontentdatabasechanges.Time.ToString() + ” ” + $spcontentdatabasechanges.ChangeToken.ToString() | add-content -encoding ascii  $ChangeCSVFile;
     $spcontentdatabasechanges.Id | add-content -encoding ascii  $ChangeCSVFile;

    }
    
   }
  
  }
 
 }

 # Dispose of Site
 $spsite.Dispose();

}

and to get all the changes back use this.

function Send_ChangeTokens_All__For_ContentDatabase([string] $ServerName, [string] $SiteCollectionName, [string] $ChangeCSVFile)
{

 $spsite = new-object Microsoft.Sharepoint.SPSite($ServerName + $SiteCollectionName);

 $spcontentdatabaseidmethod =  [Microsoft.SharePoint.Administration.SPContentDatabase].getmethod(“get_ID”);
 $spcontentdatabaseguid = $spcontentdatabaseidmethod.Invoke($spsite.ContentDatabase, “instance,public”, $null, $null, $null);

 ”Content Database is ” + $spcontentdatabaseguid.ToString() | select;

 $spcontentdatabasegetchangesmethod =  [Microsoft.SharePoint.Administration.SPContentDatabase].getmethod(“GetChanges”,[Microsoft.SharePoint.SPChangeToken]);
 $targetparameters = @($null);
 $total = 0;

 do
        {

  $spcontentdatabasechanges = $spcontentdatabasegetchangesmethod.Invoke($spsite.ContentDatabase, “instance,public”, $null, $targetparameters, $null);
  $total += $spcontentdatabasechanges.Count;

  $spcontentdatabasechanges | foreach-object {

    $_.ChangeToken.ToString() + ” ” + $_.ChangeType.ToString() + ” ” + $_.SiteId.ToString() + ” ” + $_.Time.ToString()  | add-content -encoding ascii  $ChangeCSVFile;

  }

  $targetparameters[0] = $spcontentdatabasechanges.LastChangeToken;

  if($targetparameters[0] -ne $null) { 
   ”Change Token ” + $targetparameters[0].ToString() | select; }

 } while ($spcontentdatabasechanges.Count -gt 0)

 ”Total ” + $total | select;

 # Dispose of Site
 $spsite.Dispose();

}


http://santoshbenjamin.wordpress.com/category/powershell/

Notice that the “Invoke” is different in the PS and the C#. Also notice how convoluted the PS is when trying to do a simple object.GetType() , but i guess PS wasnt meant for this sort of thing anyway, so we cant complain.


http://www.mohundro.com/blog/2008/05/07/ReflectionByExampleWithPowershell.aspx

Powershell for Reflection.

 

net command February 15, 2010

Filed under: .NET,Tool — sladescross @ 3:38 pm


http://www.computerhope.com/nethlp.htm#04

net view \\hope

View the available computers and their shared resources you may use either of the below commands. The first example displays available computers. The last command would display the shared resources on the hope computer.

net use z: \\computer\folder

Map the Z: drive to the network path //computer/folder.

 

Exception In Constructor February 1, 2010

Filed under: .NET,Constructor,Exception — sladescross @ 11:26 pm


http://www.dev102.com/2008/12/03/throwing-exceptions-from-constructors/

 

Fusion Logging January 29, 2010

Filed under: .NET,Fusion,Logging,Timer — sladescross @ 12:34 pm


http://soerennielsen.wordpress.com/2009/01/14/fixing-the-timer-service-when-everything-breaks-down/


http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx

For BadImageFormatException:
Try running peverify.exe on the file. That will give a more specific description about why it s considered a bad image. Keep in mind that modules built against v2 can not be loaded by a pre-v2 CLR.

For SecurityException:
You need Execute permission for loading any assembly. Also, if a codebase was used to load this file, you would need both FileIOPermission.Read and FileIOPermission.PathDiscovery or else WebPermission to the location (depending on whether this is a local file or a URL). Try caspol.exe to check your managed security settings.

For FileLoadException:

For an “Access is denied” message (for hresult E_ACCESSDENIED, 0×80070005):
Run tlist -m on the file to see if another process has the file locked and without share-read access. If not, check the ACLs for the file and its dependencies (especially if you’re using impersonation).

For a “The located assembly’s manifest definition with name [yourAssembly] does not match the assembly reference” message (for hresult FUSION_E_REF_DEF_MISMATCH, 0×80131040):
The Fusion log will say which part of the assembly reference failed to match what was found. It will be the assembly name, culture, public key (or token) or version (if the found assembly was strongly-named).

For “Unverifiable image [yourAssembly] can not be run” or “Can not run executable [yourAssembly] because it contains relocations” messages (for hresult COR_E_FIXUPSINEXE, 0×80131019):
That image must be run as the process exe or else be compiled as a dll. This is because MC++ has made optimizations for you in your image, based on the assumption that it will be the process exe. If it’s not the process exe, it won t be loaded at the expected location, so the assumed offsets will be incorrect. When the CLR sees such a file loaded as a non-process exe, it will reject the load.


http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx

fuslogvw.exe

 

.NET Assembly Version and Assembly File Version December 30, 2009

Filed under: .NET,Assembly,Versioning — sladescross @ 3:28 pm


http://support.microsoft.com/kb/556041

 

.NET Naming Standards December 27, 2009

Filed under: .NET,Naming Standards — sladescross @ 3:56 pm


http://www.irritatedvowel.com/Programming/Standards.aspx

http://10rem.net/articles/net-naming-conventions-and-programming-standards—best-practices.aspx

Standard Based Upon Microsoft .NET Library Standards
Pascal Case, no underscores. Try to avoid abbreviations. Members must differ by more than case to be usable from case-insensitive languages like Visual Basic .NET.
Why: This convention is consistent with the .NET Framework and is easy to read.

 

.NET Custom Configuration Settings December 25, 2009

Filed under: .NET,Configuration,Custom,Settings — sladescross @ 11:53 pm


http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration.aspx


http://haacked.com/archive/2007/03/12/custom-configuration-sections-in-3-easy-steps.aspx


http://msdn.microsoft.com/en-us/magazine/cc163591.aspx

<configuration>
  <configSections>
    <sectionGroup name=”userSettings”
        type=”System.Configuration.UserSettingsGroup, System,
              Version=2.0.0.0, Culture=neutral,
              PublicKeyToken=b77a5c561934e089″>
      <section name=”MSDNSampleSettings.My.MySettings”
        type=”System.Configuration.ClientSettingsSection, System,
             Version=2.0.0.0, Culture=neutral,
             PublicKeyToken=b77a5c561934e089″
        allowExeDefinition=”MachineToLocalUser”
        requirePermission=”false” />
    </sectionGroup>
  </configSections>
  …
  <userSettings>
    <MSDNSampleSettings.My.MySettings>
      <setting name=”Setting” serializeAs=”String”>
        <value>SomeDefaultValue</value>
      </setting>
    </MSDNSampleSettings.My.MySettings>
  </userSettings>
</configuration>


http://www.nerdymusings.com/LPMArticle.asp?ID=33

A few things in the above code deserve special mention:

  • The CollectionType property specifies AddRemoveClearMap, which is what gives your collection the standard behavior of an element collection in the configuration file.
  • If you specify a key, you’ll need to override GetElementKey to return the value of the appropriate property. Note that your key property doesn’t have to be a string. I could have used my Identifier property as the key.
  • Some of the methods provide a familiar name to access corresponding base class operations. For example, the Clear method executes BaseClear.


http://www.4guysfromrolla.com/articles/032807-1.aspx

 

 
Follow

Get every new post delivered to your Inbox.

Join 28 other followers