ORA-12154: TNS:could not resolve the connect identifier specified for asp.net application to oracle

18. November 2010 16:57 by Mrojas in General  //  Tags: , , , , ,   //   Comments (0)

I had a Windows Server 2003 and I was trying to connect to Oracle with the System.Data.OracleClient provider.

I was able to connect from a console application but not from ASP.NET.
From ASP.NET I only got ORA-12154 errors.

I found that on Windows 2003 Server, ASP.NET applications run in the
security context of the “Network Service” user.

So I tried these two  things:

I first started following these steps:
1. Log on to Windows as a user with Administrator privileges.
2. Launch Windows Explorer from the Start Menu and and navigate to the
ORACLE_HOME folder. It is usually under the oracle instalation folder.
In my case that is C:\oracle\product\10.2.0\client_1
3. Right-click on the ORACLE_HOME folder and choose the "Properties" option
from the drop down list. A "Properties" window should appear.
4. Click on the "Security" tab of the "Properties" window.
5. Click on "Authenticated Users" item in the "Name" list (on Windows XP
the "Name" list is called "Group or user names").
6. Uncheck the "Read and Execute" box in the "Permissions" list under the
"Allow" column (on Windows XP the "Permissions" list is called
"Permissions for Authenticated Users").
7. Re-check the "Read and Execute" box under the "Allow" column (this is
the box you just unchecked).
8. Click the "Advanced" button and in the "Permission Entries" list make
sure you see the "Authenticated Users" listed there with:
Permission = Read & Execute
Apply To = This folder, subfolders and files
If this is NOT the case, edit that line and make sure the "Apply onto"
drop-down box is set to "This folder, subfolders and files". This
should already be set properly but it is important that you verify this.
9. Click the "Ok" button until you close out all of the security properties
windows. The cursor may present the hour glass for a few seconds as it
applies the permissions you just changed to all subfolders and files.
10. Reboot your computer to assure that these changes have taken effect.
(I thought that rebooting was not that important but it seems that you have to reboot to make changes effective)

It sometimes happens that it is not enough, because it seems that some oracle installations need the
the ASP.NET process to run with an account with sufficient privileges.

The second thing you can do in that case is.

1. First open the machine.config file. That will be usually in %windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config

2. Look for something like:

    <processModel autoConfig="true" />

3. Add the userName=”System” attribute. For example

<processModel autoConfig="true" userName="System" />

4. Restart the IIS.

IIS 6 Metabase and IIS 6 Configuration Compatibility

11. November 2010 04:38 by Mrojas in General  //  Tags: , , , ,   //   Comments (0)


I have a silverlight application that I was trying to publish from Visual Studio to my local IIS and I got this problem:

For the record I have Windows 7.



So you can write on the Search program and Files “ Turn Windows Features on or off”




And then select



Set Fixed port for ASP.NET project. Good for Silverlight and Azure projects

11. November 2010 02:57 by Mrojas in General  //  Tags: , , , ,   //   Comments (0)

If you are doing Silverlight development, one thing that can be cumbersome is keeping in sync
your development and production settings. Specially if you are using WCF services because you have
to make sure that your ServiceClient.config file has the right values.

What I usually do is this.

1. First set fixed ports for my application. See http://blogs.msdn.com/b/webdevelopertips/archive/2008/11/07/tip-21-did-you-know-how-to-set-a-fixed-port-for-the-developer-web-server.aspx

2. Modify my hosts file in C:\Windows\System32\drivers\etc adding an entry like:

# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
#     rhino.acme.com          # source server
#     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.       localhost       productionserver.cloudapp.net  

 In this way all you have to change is your hosts file and you keep the same settings for development and for production

Handling Orientation in Silverlight for Symbian

2. November 2010 05:10 by Mrojas in General  //  Tags: , ,   //   Comments (0)


One obvious thing in modern symbian mobiles, is how to detect orientation.
I am currently porting some Silverlight 1.0 samples like GrandPiano to Silverlight for Symbian and I was wondering
how can I detect the phone orientation. Well I just analysed the Bing demo and find out that is kind of simple.

What you need is something like this:

public static readonly DependencyProperty OrientationProperty = 
DependencyProperty.Register("Orientation", typeof(Orientation), typeof(Page),
new PropertyMetadata((Orientation)0, new PropertyChangedCallback(OrientationPropertyChanged))); private static void OrientationPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { (sender as GrandPiano).UpdateOrientation(); } private void UpdateOrientation() { base.Width = (this.Orientation == Orientation.Vertical) ? DeviceVerticalSize.Width : DeviceVerticalSize.Height; base.Height = (this.Orientation == Orientation.Vertical) ? DeviceVerticalSize.Height : DeviceVerticalSize.Width; base.Clip = new RectangleGeometry { Rect = new Rect(new Point(), new Size(base.Width, base.Height)) }; } // Properties public Orientation Orientation { get { return (Orientation)base.GetValue(OrientationProperty); } set { base.SetValue(OrientationProperty, value); } }

Silverlight Symbian: Silverlight Content on this website cannot be displayed on this device

1. November 2010 06:10 by Mrojas in General  //  Tags: , ,   //   Comments (0)

When I wrote my first application for Silverlight on Symbian, I kept getting this annoying
message I really didnt get why was it.

Finally I downloaded the Bing Xap file and looked at it. And it seams it was just something simple.

<?xml version="1.0" encoding="utf-8"?>


    <AssemblyPart x:Name="BingNokia" Source="BingNokia.dll" />
    <AssemblyPart x:Name="Microsoft.Windows.Controls.WatermarkedTextBox" Source="Microsoft.Windows.Controls.WatermarkedTextBox.dll" />
    <AssemblyPart x:Name="Mvc" Source="Mvc.dll" />
    <AssemblyPart x:Name="System.Xml.Linq" Source="System.Xml.Linq.dll" />

My runtime version was wrong.

RuntimeVersion="3.0.40818.0"> <Deployment.Parts> <AssemblyPart x:Name="NokiaTest1" Source="NokiaTest1.dll" /> </Deployment.Parts> </Deployment>

I still dont how to customize my AppManifest file
I suppose that behaviour is due to the fact that I have Silverlight 3 installed in my machine.
So what I did is that I compiled my application. Then renamed my .xap for .zip. Extracted my AppManifest.xml and modified it
changing the runtime version and copied it back to my .xap file. And voila!

Starting a Project for the Cloud

27. October 2010 08:43 by Mrojas in General  //  Tags: , , , , ,   //   Comments (0)


If you dont have Windows Azure Tools installed

1. Open Visual Studio 2010

2. On the File Menu, Click new, and then click Project. This opens the New Project dialog

3. In the New Project dialog under Installed Templates, expand the Visual C# node

4. In project type click Cloud. A project that says Enable Windows Azure Tools appears

5. In Name type for example EnableTools and click OK

6. A project with a web page will appear. Click the Download Windows Azure Tools button. Close Visual Studio. Download and installed them.


Once you have Windows Azure Toolsl installed


1. Open Visual Studio 2010

2. On the File Menu, Click new, and then click Project. This opens the New Project dialog

3. In the New Project dialog under Installed Templates, expand the Visual C# node

4. In project type click Cloud. A project that says Windows Azure Cloud Service appears


5. In Name Type for example Phonebook  and click ok. The New Cloud Service Project is shown


If you are developing a Silverlight application with some services select the WCF Service Web Role. Rename it to something appropriate. In this example will be Phonebook.Web and Press OK


Your solution explorer will look like this:


Now you can developing your application. We already have an Silverlight application (that was migrated from VB6 to Silverlight) and some existing Silverlight Class libraries and Server Class Libraries (Class Libraries compiled with the full 4.0 Framework that will be used in the Server Project Phonebook.Web).

To add your Silverlight app. Right Click your server project (Phonebook.Web), then Properties and in Properties go to Silverlight Application and add Phonebook_Silverlight

When everything compiles Go to the Visual Studio Menu Bar, then Debug and then Start Without Debugging. That starts the local development environment on your computer.


You can now start testing and finish development of your application.

There is something you myst notice. Everytime you start the Cloud Service, the Azure test environment starts. By default it will start in http:\\localhost:81 but there was a previous Development Fabric it will start in http:\\localhost:81. This is important for Silverlight applications because you must configure your service end point to a particular port. Make sure that your ServiceReferences.ClientConfig file is in sync with the port that your DevelopmentFabric is using

Notes for Azure development:

Sometimes during development it might happen that you get more than one instance of the Development Fabric. This will affect your silverlight apps that rely on WFC services because each new instance starts on a new port. You can use the CSRun tool to stop all instances.

If you have installed the Windows® Azure™ SDK to the default location, the CSRun tool can be found at C:\Program Files\Windows Azure SDK\v1.0\bin\csrun.exe.Then run C:\Program Files\Windows Azure SDK\v1.2\bin\csrun.exe /devfabric:shutdown


Publishing your Application

1. Navigate to Azure : https://windows.azure.com/Cloud/Provisioning/Default.aspx

2. On the page that says My Projects. When you are starting you will only see one project line. Click on it


3. Click on New Service


4. Click on Hosted Services


5. In the Create Service page, specify the service properties. In this example we will use Phonebook.Web for service label and a short description and press next.


6. Now your hosted service needs a public url. You must check availability. In this example we will use phonebook. Hosted Affinity tries to group your services and storages in the same area. We have a SQL Azure database that is hosted in North Central US, so we will create a new AffinityGroup and call it PhonebookGroup. Press Create


7. After Creation your Service is ready, and you can start the deployment.



8. In Visual Studio 2010 Right click your Cloud Service. And Select Publish…



9. The Publish Cloud Service Dialog appears. From the Credentials drop down list select <Add>


10. From the Create or select an existing certificate select <Create>.
10.1 In our example we will enter a FriendlyName for the new certificate of PhoneBook.


10.2 Click the “Copy the full path” link in the dialog. Then Open your browser and navigate to https://windows.azure.com/cloud/provisioning/ and click on your project



10.3 Now click on account.And in the Account page click on Manage My API Certificates


10.4 Click the Choose file and paste the full path you had copied before and then click upload


the installed certificate will be shown below.


10.5 Now navigate to AppFabric by clicking AppFabric on the left hand side. This will show your subscription ID. Select it and copy it. You have to pasted on the dialog box in Visual Studio on the textbox that says above it “Copy the subscription ID”


and name those Credentials PhonebookAccount and press  OK










11 You need a storage account. If you have not created one. Then you have to follow these steps:

11.1 Open your browser and navigate to https://windows.azure.com/cloud/provisioning/ and click on your project.



11.2 Now click on New Service


11.3 Now click on Storage Account


11.4 The Create Service Page is show. Enter a Service label and Description and Click Next





11.5 Select a name for the public URL, check its availability. And select Affinity.And press Create


12. Press OK on the Publish Cloud Service Dialog



13. Visual studio will upload your application to the cloud


While your application is in staging the only problem might be that the published URL changed and that might be conflictive for your ServiceReferences.ClientConfig.

Once your application is on Staging you can switch it to Production and your are ready for business.

Create a Database in SQL Azure

26. October 2010 06:28 by Mrojas in General  //  Tags: , , , , , ,   //   Comments (0)

One of the first steps to put your database in Windows Azure is to put your data on the cloud.

1. The first step is to log in to Azure

1.a) Go to https://windows.azure.com/Cloud/Provisioning/Default.aspx 

1.b)Type your user name and password.

1.c) When your are logged in go to SQL Azure option on the left hand menu.

1.d) You will see a list of your projects. Click on the project.


2. You must accept Azure Terms of Use


3. Now create a server. You must indicate an administrator username and password. Azure will set the server name.
Press the Create Server button and continue.


4. Now let’s create a new database.Press the Create Database Button


5. Just type your database name, edition and size. Editions can be Web or Business.
At this moment Size for Web Edition is 1GB or 5GB and for Business is 10GB, 20GB, 30GB, 40GB and 50GB.
Prices varies according to the options that you select.
For my purposes I will select a Web Edition of 1GB


6. You should be able to see your new database in the Databases list.


7. Configure Firewall settings so you can connect to the new database.


7.1 Press the Allow Microsoft Services access to this server checkbox.
That will add a Rule Name that allows access from to
Select the rule and press Edit. You must can type something like to to allow access to all IP Address.

Moving your data to SQL Azure

The easiest way to upload a SQL Server database to SQL Azure is to use
the SQL Azure Migration Wizard this is a great tool that you can download from
CodePlex http://sqlazuremw.codeplex.com/

1. Download the tool. In my case I installed it in D:\SQLAzureTools. Run SQLAzureMW.exe


2. Select SQL Database and press Next


3. Select your database and press connect. That will add your database to a list. Click on your database name and press Next


4. Select the tables and other object that you will move to your SQL Azure database


5. Press Next a Summary is presented with all options





6. The wizard will generate a BCP file and a script for your tables.


You can connect to run your scripts with the following command:

> sqlcmd -S tcp:<servername>.database.windows.net -U <username>@<servername> -P <password> –d <database>

Depending on your configuration you might have problems with BCP. In general you need something like:

To export data:

bcp PhoneBook out c:\temp\Phonebook-c.dat –S <Server> –T –c

-T  means a trusted connection and native format

To import data

bcp Phonebook.dbo.Phonebook in c:\temp\Phonebook-c.dat -c -U <username>@<servername> -P <Password> -S tcp:<servername>.database.windows.net -c







After importing your data, you are set to keep on developing your applications on Azure


If you dont know the schema name connect to your database and run something like:

SELECT '['+SCHEMA_NAME(schema_id)+'].['+name+']' AS SchemaTable FROM sys.tables

Silverlight for Nokia!! WOW! Just about time

25. October 2010 03:45 by Mrojas in General  //  Tags: , ,   //   Comments (0)

I am a big fan of mobile applications and recently due to our migration activities
(we now offer migrations from VB6 and WinForms to Silverlight)
have been involved with Silverlight programming.

I have done some mobile application development activities
in J2EE and flash and I am now very happy with Silverlight.

What makes me even happier is that I am a Symbian fan and I can now
start developing applications for my Nokia phone with silverlight.

Dont miss it!: http://www.silverlight.net/getstarted/devices/symbian/



How to restore SQLSERVER .bak file to .mdf

22. October 2010 06:51 by Mrojas in General  //  Tags: , , ,   //   Comments (0)

If you have a .bak file, and all you want is to restore that file to a mdf. Then this is what you can do.

First you need an empty .mdf and .ldf files. The easier way to do that is to create a WebProject in Visual Studio and then In the App_Data folder right click and add new database. That will create an mdf and a .ldf.

Now copy those files to the data directory of your SQLSERVER Express. If it usually under the C:\Program Files\Microsoft SQL Server. In my case it is in C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\

So if your database is PhoneBook just copy:

copy PhoneBook.mdf “C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\PhoneBook.mdf”
copy PhoneBook_log.ldf “C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\PhoneBook_log.ldf”

Now attach your database:

open a Visual Studio 2008 Command Prompt or other prompt (Remember to right click the Run as Administrator, specially if it is Vista)

in the command prompt run:

sqlcmd –S ./SQLEXPRESS

and run the following commands:

( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Phonebook.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Phonebook_log.ldf' )

copy your .BAK file to the data directory.

copy PhoneBook.bak “C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\PhoneBook.bak”

NOTE: Why the data directory: It seams that in some installation you can have permitions issues

FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\PhoneBook2.BAK'
WITH MOVE 'Phonebook' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Phonebook.mdf',
MOVE 'Phonebook_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Phonebook_log.ldf',

After that if everything runs ok then you can detach your database:

1> exec sp_detach_db 'Phonebook'

Now you can copy your mdf files back to where you wanted them

NOTE: If you dont know the name you have to put for Data and Log then Run commands like

RESTORE HEADERONLY FROM DISK ='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\PhoneBook2.BAK'

RESTORE FILELISTONLY FROM DISK ='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\PhoneBook2.BAK'

In my case it gives something like:


How to create an adding that add context menu for certain files types in Visual Studio

21. October 2010 03:29 by Mrojas in Visual Studio  //  Tags: , , , , , , , , ,   //   Comments (0)

Recently I was looking for a way to create an Adding that will add a Context Menu only when I Right Click on .xaml files.

I know there a many ways now, but I still love using VS studio addins for some simple tasks.

In case you are wondering how to do that 

I found this great article: http://davedewinter.com/2008/03/22/dynamic-menu-commands-in-visual-studio-packages-part-2/