Code Project

Link Unit

Monday, January 25, 2010

TNS-3505 Failed to resolve name

On the primary database the current tnsnames.ora config for the db in
question looks like this :

LIVE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = A.B.C.D)(PORT = 1521))
)
(CONNECT_DATA =
(SID = live)
)
)

This works ok - tnsping etc ...

now when I try to add an entry for <dbname>_PRIMARY or
<dbname>_STANDBY,

LIVE2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = X.Y.C.D)(PORT = 1521))
)
(CONNECT_DATA =
(SID = live)
)
)

I get a TNS-3505 Failed to resolve name.
I tried various combinations but none worked.

Solution:
After doing lot of comparsion with existing files TNSNAME.ORA , it appeared that nothing is wrong.
Giving the new entry a closer look revealed that minor difference ,a leading whitespace[space on left] exist . Removed that extra space , all worked fine.

Hope it helps

Tuesday, December 22, 2009

Bad Request (Invalid Hostname)

While trying to host a site on IIS /windows 2003 devleoped in ASP, we got the following error.
"Http Error 404 - Bad Request (Invalid Hostname)" .
Located the file C:\WINNT\system32\LogFiles\HTTPERR.log to see if the error could be diagnosed with error description. All the other websites were running fine.

Solution: In Web Site Advanced property Host Header value was specified. Removing the "Host Header Value" resulted in operating site.

refer the image as shown below

Wednesday, December 16, 2009

Windows 2003 /DC : Application Server Unavailable


While we were hosting an web application on IIS ,got this error
Application Server Unavailable
The web application you are attempting to access on this web server is currently unavailable.Please hit the "Refresh" button in your web browser to retry your request.

On inspecting further the event log has captured following
aspnet_wp.exe could not be launched because the username and/or password supplied in the processModel section of the config file are invalid.aspnet_wp.exe could not be started.HRESULT for the failure: 80004005

Explaination:
By default, ASP.NET runs its worker process (Aspnet_wp.exe) with a weak account (the local machine account, which is named ASPNET) to provide a more secure environment. On a domain controller or on a backup domain controller, all user accounts are domain accounts and are not local machine accounts. Therefore, Aspnet_wp.exe fails to start because it cannot find a local account named "localmachinename\ASPNET". To provide a valid user account on the domain controller, you must specify an explicit account in the section of the Machine.config file, or you must use the SYSTEM account.

To work around this problem, use one of the following methods:


  • Create a weak account that has the correct permissions, and then configure the section of the Machine.config file to use that account.
  • Set the userName attribute to SYSTEM in the section of the Machine.config file.
  • Configure the section of the Machine.config file to use an administrator account.

One other special value for userName is System, with the password AutoGenerate, which runs the process as an administrative account and allows all ASP.NET user code running under the process to have full administrative privileges.
For deployment on local development environment one can use 2nd option , for deployment on client side 1st option is the best.

System.InvalidOperationException: The control with ID requires a ScriptManager on the page. The ScriptManager must appear before any controls that

System.InvalidOperationException: The control with ID requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

We faced this error while working on one of our project's page. The error appear to be very silly as Scriptmanager was declared on the page; page worked fine on it's first load. After postback,it was giving the above error. On inspecting the page further it was found the culprit was "Page.Items.Clear()" . It was clearing all objects including Scriptmanager from Page's object list.
Rule of Thumb : donot use "Page.Items.Clear()" when using Ajax

Friday, October 30, 2009

How to find the current value of a sequence number

This seems to be a simple question , and the following error will appear if we try currval on a sequence.

Select s.currval from dual

ORA-08002: sequence S.CURRVAL is not yet defined in this session

CURRVAL doesn't represent anything global about the sequence number generator. It only represents the value returned to your session (the database session processing the current statements) the last time you called NEXTVAL for that sequence

Solutions :
#1 before using CURRVAL you should call NEXTVAL .
#2 You can get the current value of the Sequence by querying DBA_SEQUENCES , which is Last_number.

An attempt was made to load a program with an incorrect format (Exception from HRESULT:0X800700008)

This problem is for sure of 64bit machine.

If an add-on is set to run on a 64 bit environment ensure it is compiled with a 32 bit operating system. The reason is the current SAPbobsCOM.dll can not run with 64 bit compiled add-ons.

You must compile your add-on and your installation program at 32 bit. You must force it because SAPBouiCom e SAPBobsCom are 32 bit component. A 64-bit program cannot call a 32-bit component.

Solution:When you create your application and when you are creating through your B1 installer. Go to the project properties-->select compile option and in that Advanced compile option-->change your target CPU to x86..rebuild your project again and create your refresh ard using these settings...

After doing above steps we faced following Error: "wrong digital signture for addon instller" Solution:The problem may be that rebuilding add-on project then generate ARD, while the old add-on executable is included in your add-on installer.
You should make sure it is the same executable of your add-on when generate the ARD and Installation. And you're recommended to do this with B1DE, it helps you to generate ARD and Installation once.
Actually, In ARD file it has unique digital signature for the add-on executable. The mismatch of the executable of add-on in ARD and Installer will lead to wrong digital signature error. Reason for Wrong digital signature:
1.You build the add-on project, then add-on executable is generated. e.g. MyAddOn.exe
2.You use this executable in the add-on installer (what ever InstallShield or other)
3.You rebuild the add-on project, then actually it is a different executable generated. Even its name is still MyAddOn.exe
4.You generate ARD on the basis of the second one. Then you will get the Wrong Digital Signature. Again, you should make sure it is the same executable file of your add-on that is used in ARD generation and included in your install shield. Meaning you shouldn't rebuild the add-on project when generate ARD or Installation, make sure ARD and Installer are referring to the same "version" of add-on executable

Every time you create an installer, you should create a new .ard file. This file contains an digital signature of your installer executable, and one digital signature of the main executable of your Add-on. (with digital signature SB1 means some kind of hash/checksum of the file)The notice you've get is because you don't have the correct signature in your .ard file for the Add-on executable. If you are creating it manually, select the correct Add-on Exe Full Path in the Add-On Registration Data Generator.
I hope this will help...as it solved my problem


Monday, September 07, 2009

DataBinding: 'Microsoft.SharePoint.SPListItem' does not contain a property with the name

When trying to bind the 'Extension' column of a custom Sharepoint List to the DropdownList , I was facing the error :

DataBinding: 'Microsoft.SharePoint.SPListItem' does not contain a property with the name 'Extension'

In case I tried the following it ran successfully

using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["Departments"];
cboDepartment.DataSource = list.Items;
cboDepartment.DataValueField = "Title"; // List field holding value
cboDepartment.DataTextField = "Title"; // List field holding name to be displayed on page
cboDepartment.DataBind();
}

So, I believe that whatever it is tryed to bind through DataTextField and DataValueField is supposed to be a property of the object we are binding to. For instance, SPListItem do have Title and ID properties, but it does not have 'Extension' property (in the meaning of the SPListItem class member).

So the following solutions were tried.

Solution #1

SPWeb site = SPContext.Current.Web;
DropDownList cboExtensions = new DropDownList();
SPList list = site.Lists["ImageExtensionList"];
SPListItemCollection lstCollection = list.Items;
cboExtensions.DataSource = lstCollection.GetDataTable();
cboExtensions.DataValueField = "Extension"; // List field holding value
cboExtensions.DataTextField = "Extension"; // List field holding name to be displayed on page
cboExtensions.DataBind();
this.Controls.Add(cboExtensions);


Solution #2

SPWeb site = SPContext.Current.Web;
DropDownList cboExtensions = new DropDownList();
SPList list = site.Lists["ImageExtensionList"];
foreach (SPListItem listRecords in list.Items)
{
//ListItem tempItem = listRecords["Extension"].ToString();
ListItem tempItem = new ListItem(listRecords["Extension"].ToString(), listRecords["Extension"].ToString());
cboExtensions.Items.Add(tempItem); //ddlFromSPList is the name of the dropdown list
}

Conclusion:
Whenever Title or ID is specified it will work without any issue. When the ListItemCollection is bounded to the DropDownList ,it is expecting Valuefield and TextField to be Properties. "Title" and "ID" are properties of List , hence it worked without any issue.

So the simple solution is to get the DataTable from the ListCollection or Get the items of the list , iterate the list and add the items to DropDownlist.

Hope it Helps
Jatinder Singh