Thursday, March 31, 2005

Solution for "Cannot start debugging on web server, Access is denied" error when trying to run Asp.net Application

You may receive an "Access is denied" error message when you try to debug a Web application, and you have administrative permissions in Visual Studio .NET
Article ID
:
894433
Last Review
:
March 25, 2005
Revision
:
2.0
On this page

SYMPTOMS

CAUSE

RESOLUTION


MORE INFORMATION


REFERENCES
SYMPTOMS
You may receive the following error message when you try to debug a Web application:
Access is DeniedThe problem occurs when the following conditions are true:

You are logged on to your computer with administrative permissions.

You are debugging a Web application in Microsoft Visual Studio .NET.

The operating system that you are using is Microsoft Windows XP Service Pack 2.

The Microsoft ASP.NET worker process account is not a member of the Administrators group.
CAUSE
The problem occurs because the ASP.NET worker process does not have the Impersonate a client after authentication user right. If the worker process account does not have this right, the debugger cannot attach to the process. The worker process account is configured by using the processModel element in the Machine.config file.
RESOLUTION
To give the worker process account the Impersonate a client after authentication user right, follow these steps:
1.
Click Start, point to Settings, and then click Control Panel.
2.
Double-click Administrative Tools.
3.
Double-click Local Security Policy.
4.
Expand Security Setting, expand Local Policies, and then click User Rights Assignment.
5.
In the Policy pane, right-click Impersonate a client after authentication, and then click Properties.
6.
Click Add User or Group.
7.
Add the worker process account that is configured in the processModel element in the Machine.config file.
8.
Click OK two times.
9.
Click Start, click Run, type iisreset, and then click OK.
10.
At a command prompt, type the following command to refresh policies on the computer:
gpupdate /forceMORE INFORMATION
Steps to reproduce the problem
1.
Open the Machine.config file. Locate the processModel element.
2.
Replace the username attribute and the password attribute as a non-administrative user.
3.
Restart Internet Information Services (IIS).
4.
Log off your computer. Log on your computer so that you have administrative permissions.
5.
Start Visual Studio .NET.
6.
Create a new Web application.When you try to debug the Web application, you may receive the following error message:
Error while trying to run project: Unable to start debugging on the web server. Access is denied.REFERENCESFor more information about developing software in Visual Studio .NET that has non-administrative permissions, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/tchDevelopingSoftwareInVisualStudioNETWithNon-AdministrativePrivileges.asp

Wednesday, March 16, 2005

Code to Open an IE Window from a Windows Form in C#

Process p = new Process();
p.StartInfo.FileName = "iexplore.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
p.StartInfo.Arguments = www.google.com
p.Start();

Tuesday, March 01, 2005

A code snippet in C# to get the installed path for MS Office using Registry Keys

private string GetOfficeAppPath(string sProgId, string sEXE)
{
//Returns path of the Office application. e.g.
//GetOfficeAppPath("Access.Application", "msaccess.exe") returns
//full path to Microsoft Access. Approach based on Q240794.
//Returns null if path not found in registry.

// Enable exception handler:
try
{
Microsoft.Win32.RegistryKey oReg =
Microsoft.Win32.Registry.LocalMachine;
Microsoft.Win32.RegistryKey oKey = null;
string sCLSID = null;
string sPath = null;
int iPos = 0;

// First, get the clsid from the progid from the registry key
// HKEY_LOCAL_MACHINE\Software\Classes\\CLSID:
oKey = oReg.OpenSubKey(@"Software\Classes\" + sProgId + @"\CLSID");
sCLSID = oKey.GetValue("").ToString();
oKey.Close();

// Now that we have the CLSID, locate the server path at
// HKEY_LOCAL_MACHINE\Software\Classes\CLSID // {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx}\LocalServer32:
oKey = oReg.OpenSubKey(@"Software\Classes\CLSID\" + sCLSID +
@"\LocalServer32");
sPath = oKey.GetValue("").ToString();
oKey.Close();

// Remove any characters beyond the exe name:
iPos = sPath.ToUpper().IndexOf(sEXE.ToUpper()); // 0-based position
sPath = sPath.Substring(0, iPos + sEXE.Length);
return sPath.Trim();
}
catch
{
return null;
}
}

ONE BEDROOM FLAT... AN INDIAN SOFTWARE ENGINEER'S LIFE... - A Bitter Reality

As the dream of most parents I had acquired a degree in Software Engineer and joined a company based in USA, the land of braves and opportunity.When I arrived in the USA, it was as if a dream had come true.

Here at last I was in the place where I want to be. I decided I would be staying in this country for about Five years in which time I would have earned enough money to settle down in India.

My father was a government employee and after his retirement, the only asset he could acquire was a decent one bedroom flat. I wanted to do some thing more than him. I started feeling homesick and lonely as the time passed. I used to call home and speak to my parents every week using cheap international phone cards. Two years passed, two years of Burgers at McDonald's and pizzas and discos and 2 years watching the foreign exchange rate getting happy whenever the Rupeevalue went down.

Finally I decided to get married. Told my parents that I have only 10 days of holidays and everything must be done within these 10 days. I got my ticket booked in the cheapest flight. Was jubilant and was actually enjoying hopping for gifts for all my friends back home.If I miss anyone then there will be talks. After reaching home I spent home one week going through all the photographs of girls and as the time was getting shorter I was forced to select one candidate.

In-laws told me,to my surprise, that I would have to get married in 2-3 days, as I will not get anymore holidays. After the marriage, it was time to return to USA, after giving some money to my parents and telling the neighbors to look after them, we returned to USA.

My wife enjoyed this country for about two months and then she started feeling lonely. The frequency of calling India increased to twice in a week sometimes 3 times a week. Our savings started diminishing. After two more years we started to have kids. Two lovely kids, a boy and a girl,were gifted to us by the almighty. Every time I spoke to my parents, they asked me to come to India so that they can see their grand-children.

Every year I decide to go to India. But part work part monetary conditions prevented it. Years went by and visiting India was a distant dream. Then suddenly one day I got a message that my parents were seriously sick. I tried but I couldn't get any holidays and thus could not go to India. The next message I got was my parents had passed away and as there was no one to do the last rights the society members had done whatever they could. I was depressed. My parents had passed away
without seeing their grand children.

After couple more years passed away, much to my children's dislike and my wife's joy we returned to India to settle down. I started to look for a suitable property, but to my dismay my savings were short and the property prices had gone up during all these years. I had to return to the USA.

My wife refused to come back with me and my children refused to stay in India. My 2 children and I returned to USA after promising my wife I would be back for good after two years.

Time passed by, my daughter decided to get married to an American and my son was happy living in USA. I decided that had enough and wound-up every thing and returned to India. I had just enough money to buy a decent 02 bedroom flat in a well-developed locality. Now I am 60 years old and the only time I go out of the flat is for the routine visit to the nearby temple. My faithful wife has also left me and gone to the holy abode.

Sometimes I wondered was it worth all this? My father, even after staying in India, had a house to his name and I too have the same nothing more.

I lost my parents and children for just ONE EXTRA BEDROOM.

Looking out from the window I see a lot of children dancing. This damned cable TV has spoiled our new generation and these children are losing their values and culture because of it. I get occasional cards from my children asking I am alright. Well at least they remember me.

Now perhaps after I die it will be the neighbors again who will be performing my last rights, God Bless them. But the question still remains 'was all this worth it?'




I am still searching for an
answer................!!!!

By an Indian SE who was in US.

Develop Microsoft Office Solutions with Visual Studio .NET

This link is a wonderful link to almost all the requirements of working with office applications with DotNet,
As a hardcore dotnet developer I know the pains involved in interacting with office apps with DotNet,
but this site is a treasure hunt.

Searching for that piece of VBA code for access-Excel issues???

****This Sub writes the values form an XL sheet to an access table.****

Private Sub Command16_Click()

Dim lngColumn As Long
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set xlx = CreateObject("Excel.Application")
'xlx.Visible = True
Set xlw = xlx.Workbooks.Open("E:\csvfiles\test.xls")
Set xls = xlw.Worksheets(1)
Set xlc = xls.Range("A2")
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("testtable", dbOpenDynaset, dbAppendOnly)
Do While xlc.Value <> ""
rst.AddNew
For lngColumn = 0 To rst.Fields.Count - 1
rst.Fields(lngColumn).Value = xlc.Offset(0, lngColumn).Value
Next lngColumn
rst.Update
Set xlc = xlc.Offset(1, 0)
Loop
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
Set xlc = Nothing
Set xls = Nothing
xlw.Close False
Set xlw = Nothing
xlx.Quit
Set xlx = Nothing

MsgBox "Data Loaded"








'Dim db1 As DAO.Database
'Dim rs1 As DAO.Recordset
'Dim qdf1 As QueryDef
'Set db1 = CurrentDb()
'Set qdf1 = db1.CreateQueryDef("")
'qdf1.SQL = "SELECT * INTO testtable FROM [Excel 8.0;database=E:\csvfiles\test.xls;].[Sheet2$]"

'Dim SQL1 As String
'Dim qdef As QueryDef

'SQL1 = "SELECT * INTO testtable FROM [Excel 8.0;database=E:\csvfiles\test.xls;].[Sheet2$]"
'CurrentDb.Execute "qdf1"

'Set rs1 = qdf1.OpenRecordset()

'DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "testtable", "E:\csvfiles\test.xls", True, "myrange2"
End Sub

****This Sub writes the values form an access table to an XL sheet.****

Private Sub Command17_Click()
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
Dim db As Database, rs As Recordset
Dim intColIndex As Integer
Dim TargetRange As Range
Set xlx = CreateObject("Excel.Application")
xlx.Visible = True
Set xlw = xlx.Workbooks.Open("E:\csvfiles\test.xls", ReadOnly:=False)
Set xls = xlw.Worksheets(2)
Set TargetRange = xls.Range("A1")
Set TargetRange = TargetRange.Cells(1, 1)
Set db = CurrentDb()
Set rs = db.OpenRecordset("testtable", dbOpenTable) ' all records
'Set rs = db.OpenRecordset("SELECT * FROM " & TableName & _
" WHERE " & FieldName & _
" = 'MyCriteria'", dbReadOnly) ' filter records
' write field names
For intColIndex = 0 To rs.Fields.Count - 1
TargetRange.Offset(0, intColIndex).Value = rs.Fields(intColIndex).Name
Next
' write recordset
TargetRange.Offset(1, 0).CopyFromRecordset rs
Set rs = Nothing
db.Close
Set db = Nothing

End Sub