Change the Office 2010 product key

A few days ago I received Office 2010 from work.

I installed it with the provided product key, and tried to activate it:

image

image

Unfortunately, the product key has been already activated for the maximum number of times permitted.

image

So I asked for a new key, I received it and I tried to change the key

image

After several researches, I couldn’t find an option to change this key.

I finally tried to repair the installation, so I start the office installer

and  the wanted option was here :

image

Choose “Enter a product key” then click on Continue

image

Enter your product key and click on “Continue”.

Then you cant choose if you want to install additional office options

Now it’s activated !

image

Incoming search terms:

  • product key office 2010
  • office 2010 activate key
  • office 2010 activation by telephone
  • office 2010 activation telephone
  • office 2010 product key has been activated maximum times
  • office 2010key
  • your product key

The IX509CertificateRequestPkcs10 InitializeFromTemplateName adventure

This week has been researches, tests and headaches to be able to make request on a Certificate Authority server from a web application.

My client has a Win server 2008 CA server for my developments

On this server I have a certificate template named “User Template”

Certificate_server_templates

My assignment was to request a certificate via an ASP.NET application.

After researches on how to do that, I found this blog post that helped me a lot : http://blogs.msdn.com/alejacma/archive/2008/09/05/how-to-create-a-certificate-request-with-certenroll-and-net-c.aspx

In my development environment, I create a request for a certificate by using  this code

 CERTENROLLLib.CX509CertificateRequestPkcs10Class request = new CERTENROLLLib.CX509CertificateRequestPkcs10Class();
 string templateName = "User Template";
 try
 {
    request.InitializeFromTemplateName(CERTENROLLLib.X509CertificateEnrollmentContext.ContextUser, templateName);
 }
 catch (Exception ex)
 {
   log.DebugFormat("Error InitializeFromTemplateName : message {0}, inner : {1}, stack : {2}, source : {3}, target : {4} ",
    ex.Message,
    ex.InnerException,
    ex.StackTrace,
    ex.Source,
    ex.TargetSite);
 }

And it worked just fine !

Then we moved the published solution to the staging environment, and the problems arrived . . .

It didn’t worked !

The error message said:

“CertEnroll::CX509CertificateRequestPkcs10::InitializeFromTemplateName: The requested certificate template is not supported by this CA. 0×80094800 (-2146875392)”

stack :

“at CERTENROLLLib.CX509CertificateRequestPkcs10Class.InitializeFromTemplateName(X509CertificateEnrollmentContext Context, String strTemplateName)”

cererror

We checked the security everywhere ( CA server, Certificate templates, IIS Account, …), give access to everyone on the CA, on the template, … without any success

Then, after days and hours of search and tests, I decided to re-read the method documentation : http://msdn.microsoft.com/en-us/library/aa377533%28v=VS.85%29.aspx

And I noticed the second parameter description:

strTemplateName [in]
Pointer to a BSTR variable that contains the Common Name (CN) of the template as it appears in Active Directory or the dotted decimal object identifier.

I had never tried using the dotted decimal object identifier, so i give it a shot.

I retrieved the object identifier on a certificate previously created with the “User Template”

On the CA server, I had a certificate request with the template “User Template”, so I right-click on it, go to All Tasks and click on the “View attributes/Extensions. . .” menu item.

image

image

A property windows opened, I go to the Extensions tab and click on the “Certificate Template Information” item.

image

In the information panel, I can see the famous dotted decimal object identifier between brackets.

I copy-paste this identifier in my code :

 CERTENROLLLib.CX509CertificateRequestPkcs10Class request = new CERTENROLLLib.CX509CertificateRequestPkcs10Class();
 string templateName = "1.3.6.1.4.1.311.21.8.3531346.8488945.6374567.164989.5001604.52.12582268.10747996";
 try
 {
    request.InitializeFromTemplateName(CERTENROLLLib.X509CertificateEnrollmentContext.ContextUser, templateName);
 }
 catch (Exception ex)
 {
    log.DebugFormat("Error InitializeFromTemplateName : message {0}, inner : {1}, stack : {2}, source : {3}, target : {4} ",
      ex.Message,
      ex.InnerException,
      ex.StackTrace,
      ex.Source,
      ex.TargetSite);
 }

I compiled, I tried in the development environment and it worked !!

(note: there is just a minimal change in my code since I put the “templateName” in a configuration file in order to be able to modify it)

So we moved the published solution to the staging environment,

retrieve the dotted decimal object identifier corresponding to the “User Template” on the staging CA server,

copy-pasted this identifier in the configuration file,

executed a “IISRESET” command and try to execute the application.

And it worked !

We can’t figured out why it worked in the development environment but not in the staging one while both are equals. So If anyone knows about it, please let me know.

So, don’t trust the template name and use the object identifier !

Incoming search terms:

  • CX509CertificateRequestPkcs10Class
  • ix509
  • InitializeFromTemplateName
  • ix509certificaterequestpkcs10 c#
  • Certenrolllib Template
  • CX509CertificateRequestCmcClass
  • TheIX509CertificateRequestPkcs10InitializeFromTemplateNameadventure
  • cx509certificaterequestpkcs10class msdn
  • CERTENROLLLib X509CertificateEnrollmentContext ContextUser
  • InitializeFromTemplateName certenroll

Visual Studio Default Key binding posters

Update 2015 : if you are looking for the 2012, 2013 or 2015 version : you can check this site : http://visualstudioshortcuts.com/

The visual studio 2010 keybinding poster is available since a few weeks.

Visual C# 2010 default key bindings preview :

VS2010CsharpKeyBinding1

VS2010CsharpKeyBinding2

Shortcuts are grouped by category (debuging, refactoring, editing, navigation, …)

Here is the Visual Studio Keyboard shortcuts posters for C#:

Visual Studio 2010

Visual Studio  2008

Visual Studio 2005

Enjoy them !

Incoming search terms:

  • Visual Studio 2013 Keybinding Posters
  • Visual Studio 2012 Keybinding Posters
  • visual studio 2013 shortcuts poster
  • visual studio 2012 shortcuts
  • visual studio 2013 keybinding poster
  • visual c# 2013 keybinding reference poster
  • visual studio 2013 default key bindings
  • visual studio 2012 keybinding poster
  • microsoft visual 2012 c# default key bindings
  • microsoft visual 2103 c# default key bindings

Custom paging with Subsonic 3 and ObjectDataSource in ASP.NET

Here is how I created a paged items list in ASP.NET 3.5 using Subsonic for data access, and ASP.NET Controls for the display.

I use Subsonic 3.0.0.4 with ActiveRecord and ASP.NET 3.5 SP1 webforms.

For this example, we are creating a blog post list and that the DAL is created (the data class we use is “DAL.BlogPost”).

The DAL.BlogPost object has three properties we need : CreatedOn, Subject and Body.

First step : prepare your data manager class


namespace MyBlog.BLL
{
   public class PostManager
   {
     // ...
   }
}

(keep in mind the namespace and the class for the nexts steps)

In this class, two methods are required,

The first returns the total number of items


public int GetPostCount()
{
  return DAL.BlogPost.All().Count(x => x.IsDeleted != true);
}

The second one returns the items contained in a defined range (start index and then nomber of elements), so this method needs to know where to start and how many items to get.


public PagedList<DAL.BlogPost> GetLastestPosts(int startRowIndex, int maximumRows)
{
   if (startRowIndex != 0)
   {
     startRowIndex =(startRowIndex/maximumRows);
   }

    IOrderedQueryable<DAL.BlogPost> yourQuery = DAL.BlogPost.All().OrderByDescending(x => x.CreatedOn);
    return new PagedList<DAL.BlogPost>(yourQuery, startRowIndex, maximumRows);
}

One important part to remember when using Subsonic is


if (startRowIndex != 0)
{
   startRowIndex = startRowIndex / maximumRows;
}

This conversion is necessary because subsonic and the ObjectDataSource doesn’t share the same opinion about the paging method.
Subsonic says

“I want the third page containing five elements”

ObjectDataSource says

“I want the five elements following the third element”

So the conversion is mandatory if you want a correct paging.

Second step : create the aspx page.

Declare an ObjectDataSource:

<asp:ObjectDataSource runat="server" ID="postsDataSource"
 TypeName="Example.BLL.PostManager"
 SelectMethod="GetLastestPosts"
 EnablePaging="true"
 SelectCountMethod="GetPostCount" >
 </asp:ObjectDataSource>

Note the TypeName attribute : the value is the namespace + the class name of our datamanager class.
We set the EnablePaging attribute to true and we specify the SelectCountMethod and the SelectMethod.

We don’t need any parameters for the paging, by default the MaximumRowsParameterName and StartRowIndexParameterName are set to “maximumRows” and “startRowIndex”.
If we want other parameters names in our datamanager class, we can define them in the ObjectDataSource with these two parameters.

Add an asp ListView element

<asp:ListView runat="server" ID="postsListview"
     DataSourceID="postsDataSource">
 <LayoutTemplate>
    <asp:PlaceHolder ID="itemPlaceHolder"
         runat="server" />
 </LayoutTemplate>
 <ItemTemplate>
    <h2><%# Eval("CreatedOn","{0:d}")%> :
     <%# Eval("Subject") %></h2>
    <br />
    <p>
     <%# Eval("Body") %>
    </p>
    <hr />
 </ItemTemplate>
</asp:ListView>

Set the DataSourceID attribute to the ObjectDataSource ID parameter.

Define a LayoutTemplate and an ItemTemplate with the elements we want to display.

Then add an asp datapager control in the LayoutTemplate


<LayoutTemplate>

  <asp:DataPager ID="postsDataPager" runat="server"
       PageSize="3">
    <Fields>
      <asp:NextPreviousPagerField ButtonType="Link"
           FirstPageText="<<" PreviousPageText="<"
           ShowNextPageButton="false"
           ShowFirstPageButton="true" />
      <asp:NumericPagerField PreviousPageText="..."
           NextPageText="..." ButtonCount="10" />
      <asp:NextPreviousPagerField ButtonType="Link"
           LastPageText=">>" NextPageText=">"
           ShowPreviousPageButton="false"
           ShowLastPageButton="true" />
     </Fields>
   </asp:DataPager>

   <asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
 </LayoutTemplate>

Here is the result :
blogposts

Remark about the data access method

It’s possible to avoid the start index value conversion !

Check the PagedList first constructor code (code is available on the subsonic git repository)


public PagedList(IQueryable<T> source, int index, int pageSize)
{
   int total = source.Count();
   TotalCount = total;
   TotalPages = total / pageSize;

   if(total % pageSize > 0)
     TotalPages++;

   PageSize = pageSize;
   PageIndex = index;
   AddRange(source.Skip(index * pageSize).Take(pageSize).ToList());
}

As you can see, Subsonic use the Skip and the Take methods from Linq

So, you can modify the GetLastestPosts method to return a strongly typed List in place of the PagedList:


public List<DAL.BlogPost> GetLastestPosts(int startRowIndex, int maximumRows)
{
   return DAL.BlogPost.All().
          Skip(startRowIndex).
          Take(maximumRows).
          OrderByDescending(x => x.CreatedOn).
          ToList<DAL.BlogPost>();
}

With this method, no more conversion needed

Incoming search terms:

  • how to use subsonic in visual studio 2015

First use of Visual Studio 2010 : the installation

Yesterday I received a visual studio 2010 Ultimate edition from work.

I’ve already test the  express edition when it was in beta phase, but it’s not the same …

So, let’s install it !

I install it on a Fujitsu Siemens laptop with 4 GB Ram and a Intel Core 2 Duo processor (2,53 GHz) running  Windows 7 64 bit Ultimate edition.

image

 

Launch the auto run program

image

Loading screen

image

Click Next

image

Read and accept the license terms

image

Choose your installation mode : Full installation (takes more than 6 GB) or Custom installation

image

I choose Custom

image

Select the features you want :

image

(notice that “Microsoft SharePoint Developer Tools” are integrated)

I just don’t want Dotfuscator community to be installed, so I uncheck  it

I keep the rest because I want to test some features

image

Click Install

Installation running :

image

After less than 10 minutes, the installation asked me to restart my computer:

image

image

I click “Restart Now”

 

When restarting, a loading form is showing

image

Then the setup continue

image

After about 45 minutes, the setup is finished

image

You can choose to install the documentation, but I choose to click on the “Finish” button.

 

The installation windows appears :

image

I Click Exit

Visual Studio 2010 is now installed

 

The installation takes me about one hour, and no problem occurred.

Now I can launch the product

image

 

image

 

I choose my default environment settings (I used to choose Visual C# Development settings so I pick this one).

image

I Click on “Start Visual Studio”

First time loading form

image

 

Visual studio is up and running

image

 

Help and documentation are on the start page:

A What’s new section is available on the start page :

Some other links are available :

  • Creating application with Visual Studio
  • Extending Visual Studio
  • Community and Learning Resources

 

Some resources for Windows, Web, Cloud, Office,SharePoint and Data development are accessible too.

 

Next step : migration of a Visual studio 2008 solution !

Incoming search terms:

  • Choose Default Environment Settings
  • first developed Fujitsu Siemens laptops
  • first use of visual studio installing
  • ideal settings for visual studio 2010 on first use