Feeds:
Posts
Comments

Archive for the ‘Snippet’ Category

UPDATED: Find the new Youtube Link below!

Dear all,

episode 4 of SP5 is ready! This time it is dealing with the topic of moving site collections from one content database to another. Click below to watch the video (UPDATED):

Remark: If you want to create a new site collection using a specific content database, you need to use PowerShell, specifically the New-SPSite cmdlet:

New-SPSite –ContentDatabase <DBName>

This cannot be done from within Central Administration.

The involved cmdlets are:

Get-SPSite (lists site collections)
Get-SPContentDatabase (list content databases)
Move-SPSite (list content databases)
New-SPSite (create new site collection, specify content DB)

Important: After moving a site collection from one content DB to another, an iisreset is required. Be aware that this will cause a service disruption for some time (depending on your server’s configuration). Be sure to execute this only if you are fully aware that this will cause all websites to be inaccessible for some time.

Disclaimer: All tutorials are provided as is. You are responsible for any changes undergoing your system that derive from following this tutorial. It is hence recommended to consult your administrators and verify that the changes cannot harm your IT environment in any way.

Stay tuned till the next time!

Martin

Advertisements

Read Full Post »

Dear all,

 

Shallow Copy is one of the new features added by the SharePoint Server 2010 SP1. Citing Microsoft, it does the following:

 

Shallow copy is a migration technique in which structured site collection data is moved across content databases while the unstructured data remains untouched in its originally configured BLOB store.

 

Sounds good, doesn’t it? In other words: The effort to migrate RBS-enabled site collections is greatly reduced – because we don’t have to consider the moving of the BLOB content anymore. Good!

 

The shallow copy can be performed using the Move-SPSite cmdlet, by simply specifying the RbsProviderMapping parameter. Here is an example:

 

Move-SPSite -Identity <Url> -DestinationDatabase <DB> 
–RbsProviderMapping @{"sourceProvider1"="targetProvider1",
"sourceProvider2"="targetProvider2"}

 

As stated before, only the structured content database is copied, while the unstructured content, such as BLOB files lying on file systems, remains untouched. Only the ownership information for the BLOB content is copied to the destination database.

 

Stay tuned till the next time!

Best regards,

Martin

Read Full Post »

Howdy there,

Now it’s around a month, that Microsoft released the .NET framework 4 to the public – so I wanted to take the occasion to give you a quick view on two nice new features:

1. Optional parameters:

You can specify any parameters to be optional by assigning it a default value directly in the list of parameters (using the assignment operator). It is quite straight-forward:

 

   1: public static void DoSomething(Int32 count = 10)

   2: {

   3:     for (int i = 0; i < count; i++)

   4:     {

   5:         Console.WriteLine(i);

   6:     }

   7:     Console.ReadLine();

   8: }

Snippet 1: The DoSomething method, specifying the count parameter as optional

This changes also the way such a method can be called, i.e. by omitting the parameter it still works fine – it just assigns the default value (in our case 10), and the code can perfectly run like that. Hence, a call to the method may look like in the following example:

   1: static void Main(string[] args)

   2: {

   3:     DoSomething();

   4: }

Snippet 2: Call to DoSomething , omitting the parameter

Even IntelliSense takes notice of the optional parameters, displaying them in square brackets, along with its default value:

image

Figure 1: IntelliSense displaying an optional parameter

Straightforward so far, isn’t it?

2. Named parameters

Now, imagine a case where we have a method that defines two required parameters, followed by an optional parameter and then again followed by another requited parameter. Let’s change the DoSomething method so it looks like in snippet 3:

   1: public static void DoSomething(String name, String surname, String city = "Munich", Int32 age)

   2: {            

   3:     Console.WriteLine(name + " " + surname + " lives in: " + city + " / age:" + age;

   4: }

Snippet 3: The changed DoSomething  method

Now it is basically possible to change the order of the parameter calling by specfying the correct names followed by a colon and again followed by the value. That’s it!

 

   1: DoSomething(surname: "Miller", name: "John", age: 32);

   2: DoSomething(age:32, surname: "Miller", name: "John", city:"Berlin");

Snippet 4: Two ways of calling DoSomething, using named parameters

This feature is especially useful if you use optional parameters, since it may not become clear which parameter is called next if you omit an optional parameter. Again, IntelliSense gives useful hints when calling a named parameter.

Enjoy!

Best regards,

Martin

Read Full Post »

Howdy folks,

Here we are back again with an introduction of the new features of the upcoming Visual Studio 2010. Its release has been postponed to the 12th of April, so in the meantime we’ll have to stick to the Beta 2, which is pretty stable already. There are so many improvements that we’ll have to divide it into multiple parts. Let’s dive right in!

1. UI: WPF-Based

The UI is now WPF based, which means a better usability and more extensibility options for us developers. Clearly, introducing VS2010 as a WPF-based application is a big push in the direction of visualization and diagramming. We’ll see later how this can be performed using the new IDE.

The editor, for example, is now WPF-based. Cool, but what does that mean for us? Here are the advantages:

Change font size w/ mouse only, or better: No more Options->Change font size during presentations!

Extension Manager allows easy-to-install-and-use add-ins: Also from online galleries – Single click install and enabling!

Highlighting of related variable/method names (Figure 1)

clip_image002

Figure 1: Highlighting related variable. Note that the highlighter correctly references only the name variable passed as a parameter

You can navigate between the highlighted elements using CTRL + SHIFT and the ARROW keys!

2. Intellisense – Improvements:

Method Matching: When VS2010 brings up the list of available methods (after you typed something), it performs not a simple .StartsWith name comparison, but a .Contains. This leads to the results shown on the next screenshots:

Filtered list is gone: When typing letters, the auto completion list that pops up won’t give you all objects/methods/variables that start with the same letter, but only those who are truly related. Consider Figure 3: We typed IF. In the old version, VS would have brought up not only the items shown in the completion list, but possibly many many more, all starting with I (but not containing or continuing with F). Now the IntelliSense search is narrowed, which makes it a lot easier for the developer to select the correct entry.

clip_image004

Figure 2: Highlighting the related object/variable/method.

Case sensitivity: Another nice feature highlighted in figure 2 is the Pascal-Case typing of the capital letters IF, which brings correctly up our method, since its signature contains both I and F as of the method name. Try typing If (f is lowercase), and you won’t find the IsFasterThan method in the auto completion list anymore.

3. References dialog improvements

Remember the Add References dialog in figure 3?

clip_image006

Figure 3: Add references underwent some perception changes.

First of all, Microsoft realized that most people are using it to reference other projects, so they brought up the Projects tab by default. But that’s not all: We all LOVED to wait 30 seconds for the list of .NET or COM objects to appear, right? Because of that, while we are browsing by default the projects, VS2010 is asynchronously loading the available assemblies already. Saves time and nerves.

4. Search and Navigation

Let’s press CTRL + , anywhere in the editor. The window Navigate To will appear, providing us a very powerful search across the entire solution. The search results are updated as we type. From here, we can navigate directly to the found item. Figure 4 shows the dialog.

clip_image008

Figure 4: The Navigate To dialog is a powerful search and navigation mechanism, providing also essential information about the found items. Big improvement over the VS2008 style’s CTRL+SHIFT+F (and subsequent find results crawling without navigation to the desired item)!

5. Call Hierarchy

Remember the Find All References option in the editor’s context menu? It provided us information about where a method/variable has been used. Tell you what. We have a much more powerful way of doing this now: The Call Hierarchy option (Figure 5).

clip_image010

Figure 5: Context menu for the IsFasterThan method, highlighting the new View Call Hierarchy option.

This is the result: A list of all callers (“Calls To”) and callees (“Calls From”) of IsFasterThan (Figure 6). Every caller/callee can be expanded into its own callers/callees. As of figure 6, e.g. Main. This is a really expressive feature which outperforms Find All References by far. However, a possible drawback might be that you could expand the list to infinity by alternating the caller/callee relationship. Figure 6 shows the resulting

image

Figure 6: The View Call Hierarchy window, showing callers/callees of IsFasterThan.

6. Project dialog with search and .NET version selection

Figure 7 shows the improved New Project dialog.

clip_image012

Figure 7: The NewProject dialog. Please note the search field in the right upper corner and the .NET framework dropdown list (center), where now also version 4 of the .NET framework is available.

7. Code Snippets

The code snippets are accessible via the Tools menu, or by pressing the shortcut CTRL + K, CTRL + B

Additional snippets are now available also for HTML, JavaScript and SQL. In sub-categories you can find the different snippets already provided by VS2010. Moreover, you can add your own snippets (as we already know from previous VS versions), as well as remove and import snippets. Figure 8 shows the Code Snippets dialog.

clip_image002[1]

Figure 8: The Code Snippets dialog, showing the newly available languages, as well as subcategories in the Code Snippets Manager.

8. Environment settings: Code Optimized

One more newly available feature is a new default environment setting (remember you had to choose which default settings you wanted to use when starting VS2010 for the first time?). There is one newly available feature which will simply allow you to reduce your viewport to only the code when developing (hence removing the designer). If you have already chosen your first-time-startup environment settings: Don’t worry! The next screenshot explain how you can access the new Web Development (Code Optimized) default environment setting. First, choose Tools –> Import and Export Settings.

image

Figure 9: Import and Export Settings wizard. Choose Reset all settings here. Then you will be prompted whether or not you want to save your current settings. Choose as you wish there. Then proceed.

image

Figure 10: Default environment settings. Note the Web Development (Code Optimized) option, which is new to VS2010. Choose it and VS will immediately switch to those settings, removing e.g. the designer buttons and providing you with a much more lightweight code editor window. Very handy for developers who want to only focus on the code.

9. Conclusion

So I’d say this is about it for this time. Of course there are a lot more features which need to be covered.

The next lessons will deal with creating customized startup pages for VS2010, and introduce the new language features and tools of Visual Studio 2010.

In the meantime, enjoy exploring VS’ new capabilities and features, and hang on till the next time!

Best regards,

Martin

Read Full Post »