Wednesday, 4 July 2012

Change registration info of VS2010

How to change registered owner and registered organization for Visual Studio 2008 and 2010

Here are steps to change registered owner and registered organization for Visual Studio 2008 and 2010.
  1. Open registry editor (type 'regedit' at Run command, clicks OK button, and select 'Yes' if you have UAC confirmation).
  2. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion (or HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Note\Microsoft\WindowsNT\CurrentVersion on Widows x64).
  3. Change 2 string values RegisteredOwner and RegisteredOrganization as you expected (create them if they don't exist).
  4. Restart Windows and open Visual Studio, you will see new registration info.


After doing above steps, if you still see old registration info, please add these steps:

For Visual Studio 2010:
  1. Delete vs000223.dat from C:\ProgramData\Microsoft\VisualStudio\10.0\. It's splash screen for Visual Studio 2010.
  2. Run Visual Studio 2010, now you should see a blank splash, there is no registration info, don't be worry.
  3. Close Visual Studio 2010, then open it again. Now you should see new registration info.

source for this article: how-to-change-registered-owner

Tuesday, 3 July 2012

How to use sdf database in project.

 Using Microsoft SQL Server Compact 4.0

SQL compact edition is ideal for secluded project where you are not worried about security of database, and is small application. I suppose its good to use as prototype version to display clients data based on database, but not too vital, where you can afford to use backup from whole system and is not crucial  for running 24/7.

You need to install 
Microsoft SQL Server Compact 4.0
http://www.microsoft.com/en-us/download/details.aspx?id=17876

This will give you all basic references and dll files you need to successfully use EF4.3 as I have done.

Sample of MEF composition factory

I have been introduced to MEF quite while ago, but For sample applications I always like to have small working code to use in order to make sure everything is working before I start on something more complex.

Here I have prepared small example of MEF composition with only one source.
The source is executing location in project.
Note: If you are using MEF in website, the code is on the same place where is your main web.config, unless you specified different location.

Eample:

This class will satisfy all dependencies for class "MyClass" using static composition factory.

  public static class Compose
    {
        /// <summary>
        /// Composes the factory.
        /// </summary>
        public static void ComposeFactory(object myObject)
        {
            var catalog = new AggregateCatalog(
                new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()),
                new DirectoryCatalog(@"."));

            foreach (var container in catalog.Parts.Select(part => new CompositionContainer(catalog)))
            {
                container.ComposeParts(myObject);
            }        }
    }


Where usage might be such as:

public class MyClass(){

public MyClass(){
   Compose.ComposeFactory(this);
}

[Import(typeof(ILogger))]
 public ILogger Logger{get;set;}

// some of your implementation
}


Point of interest.

MEF has two major import types: Import and ImportMany

[Import] or [Import(typeof(IMyInterface))]

Import is used where you want to import only one item.
Unless you specify the typeof MEF will inspect the object of its decoration and automatically try to satisfy the dependency from catalog.
My preference is the second option, which allows you to be specific which object is supposed to satisfy this injection.

Import can be null.


[ImportMany] or [ImportMany(typeof(IMyInterface))]

Import many has to have at least one item, otherwise you will receive an exception.
Again you can leave the satisfaction of the dependency on MEF or be specific.

What is Oracle version?

Oracle Version

 
Today I needed to get find out the version of oracle database using SQL command.



I have achieved it by running::
 
select *
from v$version; 
 
or
 
select *
from product_component_version;
 
 
 

Monday, 25 June 2012

Reading xml field in sql 2008

Reading XML in sql



XML data saved in database:


<ArrayOfCustomers xmlns:xsd="http://www.w3.org/2001/XMLSchema"        
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <Customer>
       <ItemId>1</ItemId>
       <Value>Mr Smith</Value>
   </Customer>
   <Customer>
      <ItemId>2</ItemId>
      <Value>Mr Bloggs</Value>
   </Customer>
</ArrayOfCustomers>



 You can read the fiels such as

SELECT
   Cust.value('(ItemId)[1]', 'int') AS 'ItemID',
   Cust.value('(Value)[1]', 'Varchar(50)') AS 'Customer Name'
FROM
   dbo.Sales.CustomerList.nodes('/ArrayOfCustomers/Customer') AS AOC(Cust)
 
 
This will return
 
ItemID  Customer Name
   1         Mr Smith
   2         Mr Bloggs