Creating a Oracle Linked Server in Sql Server

1.    Make sure oracle client is installed on SQL Server machine
2.    How to test it is installed

image

3.    Make sure OraOLEDB.Oracle is listed under Server Objects\ Linked Servers\Provider

4.    Execute command EXEC sp_addlinkedserver ‘TEST_XYZ’, ‘Oracle’, ‘OraOLEDB.Oracle’, ‘XYZ_TCP’

a.    ‘TEST_XYZ’ – Name you give to the Linked Server
b.    ‘Oracle’ – Optional, just mention it
c.    ‘OraOLEDB.Oracle’ – Provider
d.    ‘XYZ_TCP’ is the name of the oracle database found in your tnsnames.ora  file

5.    After you create the linked server you need to associate a sql server login to a oracle login.

6.    Use EXEC sp_addlinkedsrvlogin ‘TEST_XYZ’, ‘FALSE’,’SqlServerLogin’, ‘OracleUserId’, ‘OraclePassword’
a.    ‘TEST_XYZ’ – Name of the Linked Server for which you want to create a remote login
b.    2nd Parameter I have mentioned as ‘FALSE’ since I did not want the current logged in user to be associated with the remote login, but wanted to have a different user in this case ‘SqlServerLogin’ to be associated. I had currently logged in using NT authentication which had amin privilages.
c.    ‘SqlServerLogin’ – SQL server login (Note: if you mention NULL then all sql server user will get access)
d.    ‘OracleUserId’ – Oracle UserId which is used to connect to oracle database
e.    ‘OraclePassword’ – Password for Oracle User

7.    How to query oracle database – select * from TEST_XYZ..OracleUserId.TABLE_NAME

8.    To disassociate the sql server user to a oracle user use EXEC sp_droplinkedsrvlogin ‘TEST_DDWT’, ‘SqlServerLogin’ (Local Login when you execute sp_helplinkedsrvlogin)

9.    To get a list of user access to linked server, use sp_helplinkedsrvlogin

Accessing File Resource on a UNC share from IIS7 running .Net 4.0 win 2008

Today we had a situation where a page was trying to load a string from another file in the UNC share.

The asp.net page looked like this

<%@ Page EnableSessionState=”False”%>

 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”  “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>

 <html xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head runat=”server”>

    <title></title>

</head>

<body>

    <form runat=”server”>

<div>

                 <asp:PlaceHolder runat=”server” Visible=”true”>

                    <%Response.WriteFile(“/Common/breadcrumb.htm”)%>

                </asp:PlaceHolder>

            </div>

    <div>

    My Test Page

    </div><asp:Literal runat=”server”></asp:Literal>

    <asp:Button runat=”server” Text=”test”/>

    </form>

</body>

</html>

Breadcrum.htm file just as a string. When this is executed on IIS7 in Asp.Net v2 works fine. But when run 0n IIS7 and Asp.Net v4 this generates System.UnauthorizedAccessException: Access to the path “\\unshare\common\breadcrumb.htm” is denied

Fix

<%@ Page EnableSessionState=”False”%>

<%@ Import Namespace=”System.IO” %>

<%@ Import Namespace=”System.Security.Permissions” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<script runat=”server”>

    Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim oFp As FileIOPermission = New  _

        FileIOPermission(FileIOPermissionAccess.Read, Server.MapPath(“/Common/breadcrumb.htm”))

        oFp.Assert()

        Dim data As String = File.ReadAllText(Server.MapPath(“/Common/breadcrumb.htm”))

        Literal1.Text = data

    End Sub

</script>

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head runat=”server”>

    <title></title>

</head>

<body>

    <form runat=”server”>

    <div>

    My Test Page

    </div><asp:Literal runat=”server”></asp:Literal>

 <asp:Button ID=”Button1″ runat=”server” Text=”test” OnClick=”Button1_Click”/>

    </form>

</body>

</html>

My application pool was running under Network Services. I could have either changed the identity of the pool to use a user that had access to unc share or I could just programmatically give permission to file.  I used the FileIOPermission to grant access to the file and then read it.

Setting up Virtual Machine with Loopback Adapter

For instruction on how to install Loopback adapter check my previous post

I already had virtual hard drive, so I reattached it to create a new VM, in order to do setting

Select the VM and click settings

  • My hard drive

  • Memory

  • Networking, on the second adapter I selected Microsoft Loopback Adapter

  • I need to be able to move files between Host and VM and between VMs for that I need a Shared Folders, I also need to be able to copy past between the same. To get these things working I need first install VM Additions

  • To Install VM Additionsà start the VM in my case AD-DNS

On Action Click Install or Update Virtual Machine Additions

  • Click Continue
  • To Login into VM click the right Alt + Delete
  • Logged into VM, opened notepad typed in hello world
  • Back in the host opened Notepad and paste, hello world so copy paste was working
  • I need to set up Shared Folder
  • On the VM click

  • Click OK, Click Share Folder…
  • And select the folder on the host which you want to access and share

  • Check the Internet, click on the internet explorer in the VM, it should not work
  • Setting the loopback adapter properties in the VM
  • Open the network connection the VM

  • Check on the TCP4 properties on the Loopback adapter

  • This is because I am moving this VM from one machine to another, in order to get this to work with my Host Loopback adapter I first check my host loopback adapter.

  • So I am going to modify my VM loopback adapter to

I gave it a specific IP, and the default gateway I changed it to my Host Loopback adapter IP

  • Since this Virtual MC is my DNS I have to set the preferred DNs server to local, so it will complain when I click OK, You will not have to do this if it was a standalone no AD VM

  • Click OK
  • I went back and looked at the TCP property, preferred DNS server was blank I changed it to local host

  • Changed my other VM network adapter (LAC) properties to

  • Check the Internet, it started to work

Installing Microsoft Loopback Adapter on Windows7

  • Start -> search CMD-> right run as administrator
  • Type hdwwiz.exe

     

 

 

 

  • Under Microsoft choose Microsoft loopback adapter

 

  • After Installation my Network Connections2 looks like below

  • My LAC3 is my Loopback Adapter, I just going to rename it to Loopback

    LoopBack Adapter is used to communicate between virtual machines and in order to get internet to VM’s, you have to make internet available to Loopback adapter. So here are the set to do that

  • On my wireless Network connection, right click properties, select Sharing

  • Check “Allow other network users to connect through this computer’s Internet connection”
  • From the dropdown choose LoopBack
  • Uncheck Allow other network users to control or disable the shared internet connection

 

  • Now if you look at the TCP4 properties of the LoopBack adapter it would have got the IP address, by default it was Obtain an IP address, now

 

SSRS Warm Up Script

In SSRS 2005, after a period of inactivity (no calls to Reporting services), the first call to RS is very slow. This is more of an IIS issue than reporting services. The app pool generally winds down if there is no activity for a certain period of time. When the subsequent (first) request comes into reporting services, it has to restart everything hence the slowness.

In order to overcome this issue I wrote a SSRS Warm Up script. This is a windows service which executes at regular intervals, on the time elapse event I call the SSRS web service which executes and retrieves the PDF for a dummy report. This way if the app pool recycles, the warm up services will kick in and keep the server ready for subsequent requests.

I tested this by recycling the app pool to simulate cold start.

Test Result :  Executing my dummy report on cold start took almost 20 sec. After Warm up took 6 sec

Code

Windows Service

Imports SsrsWarmUp.Core
Imports System.Timers
Imports System.Configuration

Public Class SsrsWarmUpService
    Private _warmUpTimer As Timer = Nothing
    Private _warmUpCore As WarmUpCore
    Private warmUpLock As New Object

    Public Sub New()
        InitializeComponent()
        _warmUpCore = New WarmUpCore
        _warmUpTimer = New Timer()
        _warmUpTimer.Interval = Convert.ToDouble(ConfigurationManager.AppSettings(“ExecuteInterval”))
        AddHandler _warmUpTimer.Elapsed, New System.Timers.ElapsedEventHandler(AddressOf Me.warmUpTimer_Elapsed)

    End Sub

    Protected Overrides Sub OnStart(ByVal args() As String)
        Try
            _warmUpTimer.Start()
        Catch ex As Exception
            EventLog.WriteEntry(“SsrsWarmUp Service”, ex.Message)
        End Try
    End Sub

    Protected Overrides Sub OnStop()
        Try
            _warmUpTimer.Stop()
        Catch ex As Exception
            EventLog.WriteEntry(“SsrsWarmUp Service”, ex.Message)
        End Try
    End Sub
    Protected Sub warmUpTimer_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs)
        SyncLock warmUpLock
            _warmUpCore.ExecuteReport()
        End SyncLock
    End Sub

End Class

WarmupCore Class

Imports System.Configuration
Imports System.IO

Public Class WarmUpCore

    Public Sub ExecuteReport()
        Dim rs As New ssrs.ReportingService()
        rs.Credentials = New MyICredentials()
        Dim ResultStream() As Byte = Nothing
        Dim OptionalParam As String = Nothing
        Dim optionalParams As ssrs.ParameterValue() = Nothing
        Dim optionalWarnings As ssrs.Warning() = Nothing
        Dim StreamIdentifiers() As String = Nothing
        ResultStream = rs.Render(ConfigurationManager.AppSettings(“ExecuteReport”), “PDF”, Nothing, “<DeviceInfo><StreamRoot>/RSWebServiceXS/</StreamRoot></DeviceInfo>”, Nothing, Nothing, Nothing, OptionalParam, OptionalParam, optionalParams, optionalWarnings, StreamIdentifiers)
        WritePdfBytes(ResultStream)
    End Sub
    Private Sub WritePdfBytes(ByVal pdfBytes As System.Byte())
        Dim filePath = “c:\ssrsWarmUp.Pdf”
        Dim theFile As FileStream
        If File.Exists(filePath) Then
            File.Delete(filePath)
        End If
        theFile = File.Create(filePath)
        GetStreamFromByte(theFile, pdfBytes)
        theFile.Flush()
        theFile.Close()

    End Sub
    Private Sub GetStreamFromByte(ByRef theFile As FileStream, ByVal docData As Byte())
        theFile.Position = 0
        theFile.Write(docData, 0, docData.Length)
    End Sub
End Class

Note: In Sql Server 2008 this issue may not exist as there is no IIS to control.

SSRS Explorer

Installing SSRS Explorer

image

image

 image

image

image

To Start SSRS Explorer go to Program Files –> SSRS Manager

image

In order to connect to any existing SSRS server we need to first configure the server settings

Click Application–> Servers

image

I generally remove all the default servers that show up and click add

image

Enter the server URL. For SSRS 2005 the url will be http://<<servername>>/reportServer/ReportService2005.asmx

If you’re current windows login id has access to SSRS server then check the windows authentication check box, else enters the credentials for SSRS

image

Click Save –> Close

To Connect to Devl SSRS server, click connect –> devl.

image

At this point the explorer queries the SSRS web service and constructs the tree view structure

image

How to move report from one folder to another on the same server

Right click on the report and select move

image

Select the destination folder

image 

Click Ok

image

To move multiple files select all of them and click move

image

Moving Reports or objects from one server to another (Typically moving from devl to test or Prod)

Here I am moving the reports from my localhost to the development server. I want to move the all the files in My Reports folder to devl server

Step 1: Download the files you want to deploy to devl server from localhost, to your local drive.

Step 2: Connect to the destination server which is devl here

Step 3: Upload them

Downloading files

image

image

You may want to preserve folder structure if you are downloading folder with subfolders

To upload the files to the development server connect to the Devl server as we did earlier, then select the destination folder and upload all the files or the entire folder

image

image

If you do not want to overwrite existing files on the destination server choose no, most of the times you want to overwrite the old versions with the new on.

image

 

image

Associate Data Source for the Report

image

 

Select a single report or multiple reports right click and select set data source

image

From the list of available data source select the one

You can do almost all the admin activities using the ssrs explorer. Like adding a data source, modifying a data source. You would even administer security from the explorer. But I prefer to do security related stuff from report manager website

WCF In Action

1.    Create a blank solution

image

2.    Add new class library project to the solution
image
3.    Rename Class1.vb as IPerson.vb, edit the file, and change class to an interface

Public Interface IPerson

End Interface

4.    To WcfIn3Tiers.Service.Contracts add reference to System.ServiceModel
image

5.    Change IPerson file to look like below

Imports System.ServiceModel
<ServiceContract()> _
Public Interface IPerson

End Interface

6.    Add new class library project WcfIn3Tiers.Entities to the solution
image

7.    Rename Class1 to Person.
8.    To WcfIn3Tiers.Entities add reference to System.Runtime.Serialization
9.    Edit person class to look like below

Imports System.Runtime.Serialization
<DataContract()> _
Public Class Person
<DataMember()> _
Public personId As String
<DataMember()> _
Public firstName As String
<DataMember()> _
Public lastName As String
End Class

10.    To WcfIn3Tiers.Service.Contracts add reference to WcfIn3Tiers.Entities project
image

11.    Edit IPerson, the code should like shown below

Imports System.ServiceModel
Imports WcfIn3Tiers.Entities
<ServiceContract()> _
Public Interface IPerson
<OperationContract()> _
Sub addPerson(ByVal personEntity As Person)
<OperationContract()> _
Function getPeople() As List(Of Person)
<OperationContract()> _
Sub removePerson(ByVal pId As String)
End Interface
12.    Add a new class library WcfIn3Tiers.Service
image

13.    To this project add reference to System.ServiceModel, WcfIn3Tiers.Entities, WcfIn3Tiers.Service.Contracts
14.    Rename Class1 to PersonService and edit it to look like below
Imports WcfIn3Tiers.Entities
Imports WcfIn3Tiers.Service.Contracts
Imports System.ServiceModel
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.Single)> _
Public Class PersonService
Implements IPerson

Private _listOfPeople As New List(Of Person)

Public Sub addPerson(ByVal personEntity As Entities.Person) Implements Contracts.IPerson.addPerson
personEntity.personId = Guid.NewGuid.ToString
_listOfPeople.Add(personEntity)
End Sub
Public Function getPeople() As System.Collections.Generic.List(Of Entities.Person) Implements Contracts.IPerson.getPeople
Return _listOfPeople
End Function

Public Sub removePerson(ByVal pId As String) Implements Contracts.IPerson.removePerson
_listOfPeople.Remove(_listOfPeople.Find(Function(e) e.personId.Equals(pId)))
End Sub
End Class
15.    Now we have defined the service contract, data contract and the service. Which in the remoting world we used to call Interface. Entities and Core.

Hosting this Service in a Console Application
16.    Add a console application to the solution call it WcfIn3Tiers.ConsoleHost
image

17.    To WcfIn3Tiers.ConsoleHost add reference to WcfIn3Tiers.Service project and System.ServiceModel
18.    Edit model1.vb file to look like below

Imports WcfIn3Tiers.Service
Imports System.ServiceModel
Module Module1

Sub Main()
Dim myWcfHost As ServiceHost = New ServiceHost(GetType(PersonService))
myWcfHost.Open()
Console.WriteLine(“Service is up and running…………”)
Console.ReadLine()
myWcfHost.Close()
End Sub

End Module

19.    Build the solution
20.    Configure the end points
21.    Add new item in general section pick app.config

22.    App.config file contains some extras which we will not need just delete the <system.diagnostics> tag
23.    Right click app.config file and select open with .. if you have not already associated SvcConfigEditor.exe to open with, click add
image

24.    Click browse
25.    Browse to C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ SvcConfigEditor.exe
26.    In Win7 I found it here “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\SvcConfigEditor.exe”
27.    Friendly Name: WCF Configuration Editor

image

image

28.    Click OK
image
29.    Click Create a New Service
image
30.    Browse to bin\debug folder in the console application and select WcfIn3Tiers.service.dll.

image
31.    Then Select WcfIn3Tiers.Service.PersonService click open
image

32.    Click Next
image
33.    Click Next
image
34.    Click Next
image
35.    Next
image

36.    In the address type basic this a relative address. We will add the base address later
37.    Click on the Host and in the base Address section click new
image
38.    Click on
39.    Open the Endpoints, we have the basicHttpBinding we configured earlier. Let us now configure the metadata endpoint
40.    Open Advanced—> Service Behaviors
image
41.    Click New Service Behavior Configuration
image
42.    Click Add
image
43.    Select serviceMetadata
44.    Now select the actual service right on the top and configure the behavior
image
45.    Click  in the behaviorConfiguration dropdown and select NewBehavior
46.    Configure the metadata endpoint
47.    Right click Endpoints and select New Service Endpoints
image

48.    For the Contract click on the browse .. button
image

49.    Click GAC and select System.ServiceModel click open
image

50.    Select IMetadataExchange
51.    Close the editor save the changes
52.    The app.config will look like below
<?xml version=”1.0″ encoding=”utf-8″ ?>
<configuration>

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name=”NewBehavior”>
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration=”NewBehavior” name=”WcfIn3Tiers.Service.PersonService”>
<endpoint address=”basic” binding=”basicHttpBinding” bindingConfiguration=””
contract=”WcfIn3Tiers.Service.Contracts.IPerson” />
<endpoint address=”mex” binding=”mexHttpBinding” bindingConfiguration=””
contract=”IMetadataExchange” />
<host>
<baseAddresses>
<add baseAddress=”http://localhost:8899/WcfIn3Tiers” />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>

53.    Set WcfIn3Tiers.ConsoleHost as startup project and run the solution
image

54.    To test service
55.    Open VS command prompt, type in
wcftestclient http://localhost:8899/WcfIn3Tiers
56.    The test client opens up and display service for testing
image
57.    Double click on addPerson, punch in the firstName and lastName and click Invoke
image
58.    You will get a null response
59.    To test getPeople double click it and hot invoke
image
60.    You should see person you just added
61.    To test removePerson copy the PersonId from getPerson and punch it into the value column and hit invoke
image
62.    This concludes testing the service

Hosting the service in IIS
63.    We will create a new folder in C:\Temp\WcfIn3Tiers call it web
image
64.    Create new Virtual directory call it WcfIn3TierSite and map it C:\Temp\WcfIn3Tiers\Web
image

image
65.    Finish
66.    Add a new website project to the solution, select WCF Service
image

67.    Location HTTP and point to the newly created VD
68.    When the new project is created, under the app_code you will have 2 file IService.vb and Service.Vb, we will not need them just delete.
69.    Add reference to WcfIn3Tier.Service project
70.    The important file we will be working on is Service.svc file, double click it. The file will have code as shown below
<%@ ServiceHost Language=”VB” Debug=”true” Service=”Service” CodeBehind=”~/App_Code/Service.vb” %>
71.    Modify it to look like below
<%@ ServiceHost Language=”VB” Debug=”true” Service=”WcfIn3Tiers.Service.PersonService” %>
72.    Open the web.config with WCF Configuration Editor as we did earlier
image

73.    Click on the service and change the service name by click on the browse button
image

74.    In the bin directory select WcfIn3Tiers.Service.dll, then select the PersonService
image
75.    Click open
76.    Don’t worry about the Host. We will configure the end point. This project template already come configured with 2 endpoints we will just reuse them, but point to our person service contract
77.    Click on the 1st end point, in the address textbox add ws as the relative address. Then click on the contract textbox’s browse button
image
78.    Change the contact to IPerson by browsing to WcfIn3Tiers.Service.Contracts.dll
image
79.    Click Open, select WcfIn3Tiers.service.Contracts.IPerson
image
80.    We will leave mex endpoint as it is
81.    Save the file and exit
82.    To Test this, point the browser url to http://localhost/WcfIn3TierSite/Service.svc
image
83.    This is give WSDL url and how you can consume the service
84.    Open the WCFTestClient and point to the wsdl
image

85.    You will again see the familiar test client interface, go ahead and test the service as mentioned earlier

Creating a client to consume the service
86.    Add a new window forms application project to the solution
image

87.    Add Service reference
88.    Point to wsdl file for the service we just hosted in iis, click go, put MyPersonWebService in the Namespace textbox
image
89.    Vs will create all the proxy classes need
90.    Create a couple of textboxs and button as shown
image
91.    In the code behind

Imports WcfIn3Tiers.Client.MyPersonWebService
Public Class Form1
Private client As PersonClient
Private Sub AddButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddButton.Click
Dim p As New Person
p.FirstName = FnTextBox.Text
p.LastName = LnTextBox.Text
client.addPerson(p)
End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
client.Close()
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
client = New PersonClient()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ps As Person()
ps = client.getPeople()
DataGridView1.DataSource = ps
End Sub
End Class

92.    Set your client project as startup and test it out

WCF Error : System.InvalidOperationException: Cannot load the X.509 certificate identity specified in the configuration.

After adding a new endpoint like TCP or Named Pipes when you try to run the application you get the below error

System.InvalidOperationException: Cannot load the X.509 certificate identity specified in the configuration.

at System.ServiceModel.Description.ConfigLoader.LoadIdentity(IdentityElement element)

at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress)

at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection)

at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, String configurationName)

at System.ServiceModel.ServiceHostBase.ApplyConfiguration()

at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)

at System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses)

at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)

at Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(Type type, ServiceKind kind)

at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)

 Check the app.config file the endpoint would be missing <dns > tag

Before : when the error occured

<endpoint address=”mex” binding=”mexHttpBinding” contract=”IMetadataExchange”

listenUriMode=”Explicit”>

<identity>

<certificateReference storeName=”My” storeLocation=”LocalMachine”

x509FindType=”FindBySubjectDistinguishedName” />

</identity>

</endpoint>

Corrected config file

<endpoint address=”mex” binding=”mexHttpBinding” contract=”IMetadataExchange”

listenUriMode=”Explicit”>

<identity>

<dns value=“localhost” />

<certificateReference storeName=”My” storeLocation=”LocalMachine”

x509FindType=”FindBySubjectDistinguishedName” />

</identity>

</endpoint>

Do this for all the end points. I have also heard removing the certificateReference  tag works but haven’t tried it.

VS2010 (.net framework 4.0) and XP SP3 Compile Error

When you compile the application you get

Error 5 The “GenerateResource” task failed unexpectedly.

System.DllNotFoundException: Unable to load DLL ‘FileTracker.dll’: A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)

Workaround

In C:\WINDOWS\Microsoft.NET\Framework\v4.0.30128 locate Microsoft.Common.targets open in notepad. Locate <GenerateResource tag, remove the attributes TrackFileAccess=”$(TrackFileAccess)” TrackerLogDirectory=”$(TrackerLogDirectory)”, save the file, Close and Re Open Visual Studio

Missing Target Branch while trying to merge in TFS (Baseless Merge)

Today one of my colleague was trying to merge parent branch changes to a child branch. When he was trying to do that, the parent branch appears in the source drop down, but the child branch does not show up in the target branch dropdown.

Scenario: Let us call the parent branch Dev_P and child branch Dev_C. Dev_C was created by branching Dev_P. Over a period of time something went wrong in Dev_C, making copy of it they were forced to delete it; Then created a new Dev_C. When you look at the properties –> branch tab on the Dev_P I could see there was branch Dev_C. But when I looked at Dev_C property for branches could not find none. But the situation was we had to merge Dev_P into Dev_C. So the only option I had was to do baseless merge.

For more info : http://msdn.microsoft.com/en-us/library/bb668976.aspx

I did

Tf merge /baseless c:\data\dev_P c:\data\dev_C /recursive but that would not work it was giving me error. “Exactly two items (source and target) are required. Either local or server paths may be used.” I think it is because of some workspace mapping. The way I got around this was to just change the source and target path to local to server.

Tf merge /baseless $TestTeam\dev_P $TestTeam\dev_C /recursive