Saturday, March 31, 2012
System.FormatException
When I trying to execute this code,
insGrupo = Nothing
insGrupo = New Grupo(Short.Parse(0), TxtGrCoCodi.Text)
occurs the following error
System.FormatException: Sequence of entrance was not in a incorrect format.
Somebody knows what it can be this error?
---------------
Marcus Vincius M. Montezanodid you get help with this?
--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Marcus Vincius" <marc.marcus@.bol.com.br> wrote in message
news:%23M9qgFe1DHA.4032@.tk2msftngp13.phx.gbl...
> Hi Guys,
> When I trying to execute this code,
> insGrupo = Nothing
> insGrupo = New Grupo(Short.Parse(0), TxtGrCoCodi.Text)
>
> occurs the following error
> System.FormatException: Sequence of entrance was not in a incorrect
format.
>
> Somebody knows what it can be this error?
>
> ---------------
> Marcus Vincius M. Montezano
System.IndexOutOfRangeException
Public Sub SelectPieceByProductID()
Try
Dim arParams(0) As SqlParameter
arParams(0) = New SqlParameter("@dotnet.itags.org.lProductID", lProductID)
Dim oDR As SqlDataReader =
oData.ExecuteReader(sConnectionString, CommandType.StoredProcedure,
"spSelectPieceByProductID", arParams)
If oDR.HasRows Then
Do While oDR.Read()
sPieceNumber = CType(oDR.Item("PieceNumber"),
String)
lMetalID = CType(oDR.Item("MetalID"), Long)
lTotalCount = CType(oDR.Item("TotalCount"), Long)
dTotalWeight = CType(oDR.Item("TotalWeight"),
Double)
--> lNonCenterCount =
CType(oDR.Item("NonCenterCount "), Long)
dNonCenterWeight =
CType(oDR.Item("NonCenterWeight"), Double)
dPrice = CType(oDR.Item("Price"), Double)
lMarkup = CType(oDR.Item("Markup"), Long)
bActive = CType(oDR.Item("Active"), Boolean)
bDeleted = CType(oDR.Item("Deleted"), Boolean)
Loop
End If
oDR.Close()
oDR = Nothing
oData = Nothing
Catch ex As Exception
End Try
End Sub
I am getting an "System.IndexOutOfRangeException" exception on the
marked line. All values prior to this line are being set correctly.
Anyone see the issue here? I run the query in query analyzer with the
appropriate id and it works fine.
I'm clueless.
Thanks.It seems that the NonCenterCount column does not exist. Perhaps the column
name is mispelled either here, or in the table definition.
"Ratman" <jake@.attis.org> wrote in message
news:df331d52.0406210944.2c966e3c@.posting.google.c om...
> I have the following code...
> Public Sub SelectPieceByProductID()
> Try
> Dim arParams(0) As SqlParameter
> arParams(0) = New SqlParameter("@.lProductID", lProductID)
> Dim oDR As SqlDataReader =
> oData.ExecuteReader(sConnectionString, CommandType.StoredProcedure,
> "spSelectPieceByProductID", arParams)
> If oDR.HasRows Then
> Do While oDR.Read()
> sPieceNumber = CType(oDR.Item("PieceNumber"),
> String)
> lMetalID = CType(oDR.Item("MetalID"), Long)
> lTotalCount = CType(oDR.Item("TotalCount"), Long)
> dTotalWeight = CType(oDR.Item("TotalWeight"),
> Double)
> --> lNonCenterCount =
> CType(oDR.Item("NonCenterCount "), Long)
> dNonCenterWeight =
> CType(oDR.Item("NonCenterWeight"), Double)
> dPrice = CType(oDR.Item("Price"), Double)
> lMarkup = CType(oDR.Item("Markup"), Long)
> bActive = CType(oDR.Item("Active"), Boolean)
> bDeleted = CType(oDR.Item("Deleted"), Boolean)
> Loop
> End If
> oDR.Close()
> oDR = Nothing
> oData = Nothing
> Catch ex As Exception
> End Try
> End Sub
> I am getting an "System.IndexOutOfRangeException" exception on the
> marked line. All values prior to this line are being set correctly.
> Anyone see the issue here? I run the query in query analyzer with the
> appropriate id and it works fine.
> I'm clueless.
> Thanks.
System.IndexOutOfRangeException
Public Sub SelectPieceByProductID()
Try
Dim arParams(0) As SqlParameter
arParams(0) = New SqlParameter("@dotnet.itags.org.lProductID", lProductID)
Dim oDR As SqlDataReader =
oData.ExecuteReader(sConnectionString, CommandType.StoredProcedure,
"spSelectPieceByProductID", arParams)
If oDR.HasRows Then
Do While oDR.Read()
sPieceNumber = CType(oDR.Item("PieceNumber"),
String)
lMetalID = CType(oDR.Item("MetalID"), Long)
lTotalCount = CType(oDR.Item("TotalCount"), Long)
dTotalWeight = CType(oDR.Item("TotalWeight"),
Double)
--> lNonCenterCount =
CType(oDR.Item("NonCenterCount "), Long)
dNonCenterWeight =
CType(oDR.Item("NonCenterWeight"), Double)
dPrice = CType(oDR.Item("Price"), Double)
lMarkup = CType(oDR.Item("Markup"), Long)
bActive = CType(oDR.Item("Active"), Boolean)
bDeleted = CType(oDR.Item("Deleted"), Boolean)
Loop
End If
oDR.Close()
oDR = Nothing
oData = Nothing
Catch ex As Exception
End Try
End Sub
I am getting an "System.IndexOutOfRangeException" exception on the
marked line. All values prior to this line are being set correctly.
Anyone see the issue here? I run the query in query analyzer with the
appropriate id and it works fine.
I'm clueless.
Thanks.It seems that the NonCenterCount column does not exist. Perhaps the column
name is mispelled either here, or in the table definition.
"Ratman" <jake@.attis.org> wrote in message
news:df331d52.0406210944.2c966e3c@.posting.google.com...
> I have the following code...
> Public Sub SelectPieceByProductID()
> Try
> Dim arParams(0) As SqlParameter
> arParams(0) = New SqlParameter("@.lProductID", lProductID)
> Dim oDR As SqlDataReader =
> oData.ExecuteReader(sConnectionString, CommandType.StoredProcedure,
> "spSelectPieceByProductID", arParams)
> If oDR.HasRows Then
> Do While oDR.Read()
> sPieceNumber = CType(oDR.Item("PieceNumber"),
> String)
> lMetalID = CType(oDR.Item("MetalID"), Long)
> lTotalCount = CType(oDR.Item("TotalCount"), Long)
> dTotalWeight = CType(oDR.Item("TotalWeight"),
> Double)
> --> lNonCenterCount =
> CType(oDR.Item("NonCenterCount "), Long)
> dNonCenterWeight =
> CType(oDR.Item("NonCenterWeight"), Double)
> dPrice = CType(oDR.Item("Price"), Double)
> lMarkup = CType(oDR.Item("Markup"), Long)
> bActive = CType(oDR.Item("Active"), Boolean)
> bDeleted = CType(oDR.Item("Deleted"), Boolean)
> Loop
> End If
> oDR.Close()
> oDR = Nothing
> oData = Nothing
> Catch ex As Exception
> End Try
> End Sub
> I am getting an "System.IndexOutOfRangeException" exception on the
> marked line. All values prior to this line are being set correctly.
> Anyone see the issue here? I run the query in query analyzer with the
> appropriate id and it works fine.
> I'm clueless.
> Thanks.
System.IndexOutOfRangeException
I have the following code where all the used variable are declared to their respective types:
insertSql = "SELECT Max([Customer ID]) AS CustID FROM [Registration Info]"
objCommand = New OleDbCommand(insertSql, objConn)
objConn.Open()
objDR = objCommand.ExecuteReader()
While objDR.Read()
CustID=objDR("Cust ID") '********** (1.)
End While
I am getting an error on (1.). its says "System.IndexOutOfRangeException: Cust ID" why is this happening? Can comeone help me whith this problem?
Thanks,
~sIf the code enters the while loop then tere are values within objDR so why not add a watch to this and check the value of objDr(0) and then objDR(1)
Hope that helps
Cheers
Gregor Suttie
I would say it is happening because there is no field in the result called "Cust ID", though there is one called "CustID"
Yes i know thats a silly mistake on my part. very silly... i wish i could delete this post. :) thanks very much. now i am doing it like objDR(0)
Regards.
System.IndexOutOfRangeException: Index was outside the bounds of the array
Hi i am getting the following error "System.IndexOutOfRangeException: Index was outside the bounds of the array". it is coming from this line of code ;
Line 595: // Build Column Name PartLine 596: strPart1 = strPart1 + "`" + strData[lngIter, 0] + "`,";Line 597:
It may have been caused by the following code;
staticpublicstring buildQuery(string strAction,string strTableName,string[,] strData,string[,] strWhere,string strWhereOverride,string strLimit,string strOffset,string strOrderBy){
// Array Definitions
//strData(x,0)=ColumnName
//strData(x,1)=ColumnData
You will get this if you use an index that is higher than the number of items in the array. So check if the lngIter is within the index range of the array so you don't pass an index which is higher than the total amount of items in the array.
Hi, i am quite new to programming, so i am unsure if i have declared the arrays properly, however i will show you some code and if you could tell me if you can identify where i have to declare the array.;
The following code is in the page calling up a method;
clsOBJ objDHOC =newclsOBJ();Pmillio.clsOBJ.buildQuery("INSERT","tblProperty", strData, strWhere,"","1","1","strData");
string[,] strData =newstring[11, 2];string[,] strWhere =newstring[11, 3];
strData[0, 0] ="StatutoryDate";strData[0, 1] = txtDate.Text;
The following code is what in the DAL which the one above is referencing;
staticpublicstring buildQuery(string strAction,string strTableName,string[,] strData,string[,] strWhere,string strWhereOverride,string strLimit,string strOffset,string strOrderBy){
// Array Definitions
//strData(x,0)=ColumnName
//strData(x,1)=ColumnData
// Ucase
strAction = (strAction);
// Dimension
string strSQL;int lngIter;
string strPart1 =null;string strPart2 =null;
System.InvalidCastException:
I get a System.InvalidCastException on the following code.
ObjtInterestLadder.dblPrinCcyAmt = (double) dsRecs.Tables["DetailData"].Rows[iSub]["Prin_Ccy_Amt"];
Why is this.
When I retrieve the data to a string it is OK
sData = (string) dsRecs.Tables["DetailData"].Rows[iSub]["Prin_Ccy_Amt"].ToString();
have you checked for NULL values?
franklb wrote:
Why is this.
When I retrieve the data to a string it is OK
sData = (string) dsRecs.Tables["DetailData"].Rows[iSub]["Prin_Ccy_Amt"].ToString();
What is it showing when you do that ? If it is null or blank it will show exception.
System.InvalidCastException: Specified cast is not valid.
Please help. I get the following error from my webpage:
System.InvalidCastException: Specified cast is not valid.
at Time.MaintAtRiskProjects.UpdateProject(String Project, String
AtRiskCode, String Comment)
Code for UpdateProject(String Project, String AtRiskCode, String Comment)
is:
Private Sub UpdateProject(ByVal Project As String, ByVal AtRiskCode As
String, ByVal Comment As String)
Try
Dim strProject As String = Trim(Project)
Dim strAtRiskCode As String = Trim(AtRiskCode)
Dim strComment As String = Trim(Comment)
Dim r As AtRiskProjectsDS.AtRiskProjectsRow
Dim rows() As AtRiskProjectsDS.AtRiskProjectsRow =
AtRiskProjDS.AtRiskProjects.Select(AtRiskProjDS.AtRiskProjects.ProjectColumn
.ColumnName
& "= '" & strProject & "' AND " &
AtRiskProjDS.AtRiskProjects.AtRiskCodeColumn.ColumnName & "= '" &
strAtRiskCode & "' ")
If rows.Length <> 0 Then
r = rows(0)
If r.Comment <> strComment Then
r.Comment = strComment
End If
End If
Catch ex As Exception
Trace.Write(ex.ToString)
End Try
End Sub
UpdateProject(ByVal Project As String, ByVal AtRiskCode As String, ByVal
Comment As String) is being called from an update button I have in the page.
The code for Update click is as follows:
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Try
Dim strProject As String = Trim(lblProject.Text)
AtRiskProjDS.Clear()
AtRiskProjDS = LoadAtRiskProjDS(strProject)
For Each item As DataGridItem In dgAtRiskInfo.Items
If item.ItemType = ListItemType.Item Or item.ItemType =
ListItemType.AlternatingItem Then
Dim RiskCodeOld As CheckBox = CType(item.FindControl("chkCodeOld"),
CheckBox)
Dim RiskCodeNew As CheckBox = CType(item.FindControl("chkCodeNew"),
CheckBox)
Dim AtRiskCode As TextBox = CType(item.FindControl("txtAtRiskCode"),
TextBox)
Dim Description As Label = CType(item.FindControl("lblDescription"), Label)
Dim Comment As TextBox = CType(item.FindControl("txtComment"), TextBox)
Dim strAtRiskCode As String = Trim(AtRiskCode.Text)
Dim strDescription As String = Trim(Description.Text)
Dim strComment As String = Trim(Comment.Text)
If RiskCodeOld.Checked = False And RiskCodeNew.Checked = True Then
InsertProject(RiskCodeNew.Checked, strProject, strAtRiskCode,
strDescription, strComment)
RiskCodeOld.Checked = RiskCodeNew.Checked
ElseIf RiskCodeOld.Checked = True And RiskCodeNew.Checked = False Then
DeleteProject(strProject, strAtRiskCode)
RiskCodeOld.Checked = RiskCodeNew.Checked
Else
UpdateProject(strProject, strAtRiskCode, strComment)
End If
End If
Next
SubmitChanges(strProject)
Catch ex As Exception
Trace.Write(ex.ToString)
End Try
End Sub
Here is what the code for ASPX page looks like:
<%@dotnet.itags.org. Import namespace="Time" %>
<%@dotnet.itags.org. Import namespace="System.Data" %>
<%@dotnet.itags.org. Register TagPrefix="uc1" TagName="footer" src="http://pics.10026.com/?src=../footer.ascx" %>
<%@dotnet.itags.org. Register TagPrefix="uc1" TagName="header" src="http://pics.10026.com/?src=../header.ascx" %>
<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false"
Codebehind="MaintAtRiskProjects.aspx.vb"
Inherits="Time.MaintAtRiskProjects"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>MaintAtRiskProjects</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="http://links.10026.com/?link=../master.css" type="text/css" rel="stylesheet">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="MaintAtRiskProjectsFrm" method="post" runat="server">
<uc1:header id="PageHeader" runat="server"></uc1:header>
<P><asp:dropdownlist id="ddlProject" style="Z-INDEX: 101; LEFT: 16px;
POSITION: absolute; TOP: 72px"
runat="server" OnSelectedIndexChanged="DisplayAtRiskProjInfo"
Font-Names="Lucida Console, Courier New"
Width="168px" autopostback="True"></asp:dropdownlist></P>
<hr style="Z-INDEX: 102; LEFT: 8px; POSITION: absolute; TOP: 104px">
<asp:Button id="btnReport" style="Z-INDEX: 106; LEFT: 504px; POSITION:
absolute; TOP: 64px"
runat="server" Width="97px" Text="View Report"></asp:Button>
<asp:Button id="btnUpdate" style="Z-INDEX: 105; LEFT: 280px; POSITION:
absolute; TOP: 64px"
runat="server" Width="72px" Height="24px"
Text="Update"></asp:Button><asp:label id="lblProject" style="Z-INDEX: 104;
LEFT: 8px; POSITION: absolute; TOP: 128px"
runat="server" Width="160px" ForeColor="#CC0000"
Height="24px"></asp:label><asp:datagrid id="dgAtRiskInfo" style="Z-INDEX:
103; LEFT: 184px; POSITION: absolute; TOP: 128px"
runat="server" Width="385px" Height="160px" ShowFooter="False"
AutoGenerateColumns="False">
<AlternatingItemStyle BackColor="MistyRose"></AlternatingItemStyle>
<ItemStyle HorizontalAlign="Right"></ItemStyle>
<HeaderStyle ForeColor="#CC0000" BackColor="Silver"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:TextBox ID="txtAtRiskCode" Text='<%
#Container.DataItem("AtRiskCode") %>' Runat=server Visible=False>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox ID="chkCodeOld" Checked='<%
#Container.DataItem("RiskCodeFlag") %>' Runat="server" Visible=False>
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Check/Uncheck">
<ItemTemplate>
<asp:CheckBox ID="chkCodeNew" Checked='<%
#Container.DataItem("RiskCodeFlag") %>' Width="15px" Runat=server>
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Description">
<ItemTemplate>
<asp:Label ID="lblDescription" text='<%
#Container.DataItem("Description") %>' width="250px" runat=server>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Comment">
<ItemTemplate>
<asp:TextBox ID="txtComment" Text='<% #Container.DataItem("Comment")
%>' Width="400px" Runat=server>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></form>
</body>
</HTML>
Please help.. Can't figure out what is going on.
Thanks,
Biva
----
--
----
--"Biva" <biva.yauchler@.redprairie.com> wrote in message
news:41dac14e$0$82454$39cecf19@.news.twtelecom.net...
> Hello All,
> Please help. I get the following error from my webpage:
> System.InvalidCastException: Specified cast is not valid.
> at Time.MaintAtRiskProjects.UpdateProject(String Project, String
> AtRiskCode, String Comment)
> Code for UpdateProject(String Project, String AtRiskCode, String Comment)
> is:
...
> Please help.. Can't figure out what is going on.
>
I can't figure out what's going on either, since you did not tell us which
line was causing the error.
This sort of thing happens frequently when a database column contains NULL.
NULL is not a value, so if you try to treat it as a string, you'll get the
invalid cast exception.
John Saunders
John,
My frustration is that it works on my PC that has Framework 1.1.
But when I move it to production that has framework 1.0, it does not
work.
I have the backward compatibility turned on, so it should work.
Since it is on production, i don't have an easy way to debug.
All I could do was set debug=true on web.config and look at the
trace.axd to get that error.
Is there an easy way for me to find out what line is actually giving me
that error?
thanks...
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
"sqlgirl" <sqlgirl@.devdex.com> wrote in message
news:ur12b9n8EHA.1396@.tk2msftngp13.phx.gbl...
>
> John,
> My frustration is that it works on my PC that has Framework 1.1.
> But when I move it to production that has framework 1.0, it does not
> work.
> I have the backward compatibility turned on, so it should work.
> Since it is on production, i don't have an easy way to debug.
> All I could do was set debug=true on web.config and look at the
> trace.axd to get that error.
> Is there an easy way for me to find out what line is actually giving me
> that error?
I don't know, but this kind of thing is a reason to develop on the platform
you're going to use in production.
John Saunders
Here is my DeleteProject method.
Dim rows() As AtRiskProjectsDS.AtRiskProjectsRow =
AtRiskProjDS.AtRiskProjects.Select(AtRiskProjDS.AtRiskProjects.ProjectCo
lumn.ColumnName & "= '" & strProject & "' AND " &
AtRiskProjDS.AtRiskProjects.AtRiskCodeColumn.ColumnName & "= '" &
strAtRiskCode & "' ")
is the statement that is not being liked for some reason.
Sub DeleteProject(ByVal Project As String, ByVal AtRiskCode As String)
Try
Dim strProject As String = Project
Dim strAtRiskCode As String = AtRiskCode
Dim rows() As AtRiskProjectsDS.AtRiskProjectsRow =
AtRiskProjDS.AtRiskProjects.Select(AtRiskProjDS.AtRiskProjects.ProjectCo
lumn.ColumnName & "= '" & strProject & "' AND " &
AtRiskProjDS.AtRiskProjects.AtRiskCodeColumn.ColumnName & "= '" &
strAtRiskCode & "' ")
Trace.Write("proj1: " & strProject & ", code1: " &
strAtRiskCode)
Dim r As AtRiskProjectsDS.AtRiskProjectsRow
If rows.Length <> 0 Then
r = rows(0)
r.Delete()
End If
Catch ex As Exception
Trace.Write(ex.ToString)
End Try
End Sub
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
"sqlgirl" <sqlgirl@.devdex.com> wrote in message
news:OuhDdyo8EHA.3592@.TK2MSFTNGP09.phx.gbl...
> Here is my DeleteProject method.
> Dim rows() As AtRiskProjectsDS.AtRiskProjectsRow =
> AtRiskProjDS.AtRiskProjects.Select(AtRiskProjDS.AtRiskProjects.ProjectCo
> lumn.ColumnName & "= '" & strProject & "' AND " &
> AtRiskProjDS.AtRiskProjects.AtRiskCodeColumn.ColumnName & "= '" &
> strAtRiskCode & "' ")
Ok, if there's something on that line that ASP.NET doesn't like, then
simplify it:
Dim projectColumnName as String =
AtRiskProjDS.AtRiskProjects.ProjectColumn.ColumnName
Dim atRiskCodeColumnName As String =
AtRiskProjDS.AtRiskProjects.AtRiskCodeColumn.ColumnName
Dim query As String = projectColumnName & "= '" & strProject & "' AND " &
atRiskCodeColumnName & "= '" & strAtRiskCode & "' "
Dim rows() As AtRiskProjectsDS.AtRiskProjectsRow =
AtRiskProjDS.AtRiskProjects.Select(query)
Try that and tell us which line has the problem.
John Saunders
I had defined rows() variable as my dataset.datatablerowtype.
eg.
Dim rows() As AtRiskProjectsDS.AtRiskProjectsRow
Framework 1.0 did not like it.
After I changed the rows() variable to simple datarow type as shown
below, it worked fine.
Dim rows() As datarow
Just so if anyone has this problem in the future.
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
System.InvalidCastException: Specified cast is not valid.
Please help. I get the following error from my webpage:
System.InvalidCastException: Specified cast is not valid.
at Time.MaintAtRiskProjects.UpdateProject(String Project, String
AtRiskCode, String Comment)
Code for UpdateProject(String Project, String AtRiskCode, String Comment)
is:
Private Sub UpdateProject(ByVal Project As String, ByVal AtRiskCode As
String, ByVal Comment As String)
Try
Dim strProject As String = Trim(Project)
Dim strAtRiskCode As String = Trim(AtRiskCode)
Dim strComment As String = Trim(Comment)
Dim r As AtRiskProjectsDS.AtRiskProjectsRow
Dim rows() As AtRiskProjectsDS.AtRiskProjectsRow =
AtRiskProjDS.AtRiskProjects.Select(AtRiskProjDS.At RiskProjects.ProjectColumn.ColumnName
& "= '" & strProject & "' AND " &
AtRiskProjDS.AtRiskProjects.AtRiskCodeColumn.Colum nName & "= '" &
strAtRiskCode & "' ")
If rows.Length <> 0 Then
r = rows(0)
If r.Comment <> strComment Then
r.Comment = strComment
End If
End If
Catch ex As Exception
Trace.Write(ex.ToString)
End Try
End Sub
UpdateProject(ByVal Project As String, ByVal AtRiskCode As String, ByVal
Comment As String) is being called from an update button I have in the page.
The code for Update click is as follows:
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Try
Dim strProject As String = Trim(lblProject.Text)
AtRiskProjDS.Clear()
AtRiskProjDS = LoadAtRiskProjDS(strProject)
For Each item As DataGridItem In dgAtRiskInfo.Items
If item.ItemType = ListItemType.Item Or item.ItemType =
ListItemType.AlternatingItem Then
Dim RiskCodeOld As CheckBox = CType(item.FindControl("chkCodeOld"),
CheckBox)
Dim RiskCodeNew As CheckBox = CType(item.FindControl("chkCodeNew"),
CheckBox)
Dim AtRiskCode As TextBox = CType(item.FindControl("txtAtRiskCode"),
TextBox)
Dim Description As Label = CType(item.FindControl("lblDescription"), Label)
Dim Comment As TextBox = CType(item.FindControl("txtComment"), TextBox)
Dim strAtRiskCode As String = Trim(AtRiskCode.Text)
Dim strDescription As String = Trim(Description.Text)
Dim strComment As String = Trim(Comment.Text)
If RiskCodeOld.Checked = False And RiskCodeNew.Checked = True Then
InsertProject(RiskCodeNew.Checked, strProject, strAtRiskCode,
strDescription, strComment)
RiskCodeOld.Checked = RiskCodeNew.Checked
ElseIf RiskCodeOld.Checked = True And RiskCodeNew.Checked = False Then
DeleteProject(strProject, strAtRiskCode)
RiskCodeOld.Checked = RiskCodeNew.Checked
Else
UpdateProject(strProject, strAtRiskCode, strComment)
End If
End If
Next
SubmitChanges(strProject)
Catch ex As Exception
Trace.Write(ex.ToString)
End Try
End Sub
Here is what the code for ASPX page looks like:
<%@dotnet.itags.org. Import namespace="Time" %>
<%@dotnet.itags.org. Import namespace="System.Data" %>
<%@dotnet.itags.org. Register TagPrefix="uc1" TagName="footer" src="http://pics.10026.com/?src=../footer.ascx" %>
<%@dotnet.itags.org. Register TagPrefix="uc1" TagName="header" src="http://pics.10026.com/?src=../header.ascx" %>
<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false"
Codebehind="MaintAtRiskProjects.aspx.vb"
Inherits="Time.MaintAtRiskProjects"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>MaintAtRiskProjects</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="http://links.10026.com/?link=../master.css" type="text/css" rel="stylesheet">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="MaintAtRiskProjectsFrm" method="post" runat="server">
<uc1:header id="PageHeader" runat="server"></uc1:header>
<P><asp:dropdownlist id="ddlProject" style="Z-INDEX: 101; LEFT: 16px;
POSITION: absolute; TOP: 72px"
runat="server" OnSelectedIndexChanged="DisplayAtRiskProjInfo"
Font-Names="Lucida Console, Courier New"
Width="168px" autopostback="True"></asp:dropdownlist></P>
<hr style="Z-INDEX: 102; LEFT: 8px; POSITION: absolute; TOP: 104px">
<asp:Button id="btnReport" style="Z-INDEX: 106; LEFT: 504px; POSITION:
absolute; TOP: 64px"
runat="server" Width="97px" Text="View Report"></asp:Button>
<asp:Button id="btnUpdate" style="Z-INDEX: 105; LEFT: 280px; POSITION:
absolute; TOP: 64px"
runat="server" Width="72px" Height="24px"
Text="Update"></asp:Button><asp:label id="lblProject" style="Z-INDEX: 104;
LEFT: 8px; POSITION: absolute; TOP: 128px"
runat="server" Width="160px" ForeColor="#CC0000"
Height="24px"></asp:label><asp:datagrid id="dgAtRiskInfo" style="Z-INDEX:
103; LEFT: 184px; POSITION: absolute; TOP: 128px"
runat="server" Width="385px" Height="160px" ShowFooter="False"
AutoGenerateColumns="False">
<AlternatingItemStyle BackColor="MistyRose"></AlternatingItemStyle>
<ItemStyle HorizontalAlign="Right"></ItemStyle>
<HeaderStyle ForeColor="#CC0000" BackColor="Silver"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:TextBox ID="txtAtRiskCode" Text='<%
#Container.DataItem("AtRiskCode") %>' Runat=server Visible=False>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox ID="chkCodeOld" Checked='<%
#Container.DataItem("RiskCodeFlag") %>' Runat="server" Visible=False>
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Check/Uncheck">
<ItemTemplate>
<asp:CheckBox ID="chkCodeNew" Checked='<%
#Container.DataItem("RiskCodeFlag") %>' Width="15px" Runat=server>
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Description">
<ItemTemplate>
<asp:Label ID="lblDescription" text='<%
#Container.DataItem("Description") %>' width="250px" runat=server>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Comment">
<ItemTemplate>
<asp:TextBox ID="txtComment" Text='<% #Container.DataItem("Comment")
%>' Width="400px" Runat=server>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></form>
</body>
</HTML
Please help.. Can't figure out what is going on.
Thanks,
Biva
------------------------
------------------------"Biva" <biva.yauchler@.redprairie.com> wrote in message
news:41dac14e$0$82454$39cecf19@.news.twtelecom.net. ..
> Hello All,
> Please help. I get the following error from my webpage:
> System.InvalidCastException: Specified cast is not valid.
> at Time.MaintAtRiskProjects.UpdateProject(String Project, String
> AtRiskCode, String Comment)
> Code for UpdateProject(String Project, String AtRiskCode, String Comment)
> is:
...
> Please help.. Can't figure out what is going on.
I can't figure out what's going on either, since you did not tell us which
line was causing the error.
This sort of thing happens frequently when a database column contains NULL.
NULL is not a value, so if you try to treat it as a string, you'll get the
invalid cast exception.
John Saunders
John,
My frustration is that it works on my PC that has Framework 1.1.
But when I move it to production that has framework 1.0, it does not
work.
I have the backward compatibility turned on, so it should work.
Since it is on production, i don't have an easy way to debug.
All I could do was set debug=true on web.config and look at the
trace.axd to get that error.
Is there an easy way for me to find out what line is actually giving me
that error?
thanks...
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
"sqlgirl" <sqlgirl@.devdex.com> wrote in message
news:ur12b9n8EHA.1396@.tk2msftngp13.phx.gbl...
>
> John,
> My frustration is that it works on my PC that has Framework 1.1.
> But when I move it to production that has framework 1.0, it does not
> work.
> I have the backward compatibility turned on, so it should work.
> Since it is on production, i don't have an easy way to debug.
> All I could do was set debug=true on web.config and look at the
> trace.axd to get that error.
> Is there an easy way for me to find out what line is actually giving me
> that error?
I don't know, but this kind of thing is a reason to develop on the platform
you're going to use in production.
John Saunders
Here is my DeleteProject method.
Dim rows() As AtRiskProjectsDS.AtRiskProjectsRow =
AtRiskProjDS.AtRiskProjects.Select(AtRiskProjDS.At RiskProjects.ProjectCo
lumn.ColumnName & "= '" & strProject & "' AND " &
AtRiskProjDS.AtRiskProjects.AtRiskCodeColumn.Colum nName & "= '" &
strAtRiskCode & "' ")
is the statement that is not being liked for some reason.
Sub DeleteProject(ByVal Project As String, ByVal AtRiskCode As String)
Try
Dim strProject As String = Project
Dim strAtRiskCode As String = AtRiskCode
Dim rows() As AtRiskProjectsDS.AtRiskProjectsRow =
AtRiskProjDS.AtRiskProjects.Select(AtRiskProjDS.At RiskProjects.ProjectCo
lumn.ColumnName & "= '" & strProject & "' AND " &
AtRiskProjDS.AtRiskProjects.AtRiskCodeColumn.Colum nName & "= '" &
strAtRiskCode & "' ")
Trace.Write("proj1: " & strProject & ", code1: " &
strAtRiskCode)
Dim r As AtRiskProjectsDS.AtRiskProjectsRow
If rows.Length <> 0 Then
r = rows(0)
r.Delete()
End If
Catch ex As Exception
Trace.Write(ex.ToString)
End Try
End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
"sqlgirl" <sqlgirl@.devdex.com> wrote in message
news:OuhDdyo8EHA.3592@.TK2MSFTNGP09.phx.gbl...
> Here is my DeleteProject method.
> Dim rows() As AtRiskProjectsDS.AtRiskProjectsRow =
> AtRiskProjDS.AtRiskProjects.Select(AtRiskProjDS.At RiskProjects.ProjectCo
> lumn.ColumnName & "= '" & strProject & "' AND " &
> AtRiskProjDS.AtRiskProjects.AtRiskCodeColumn.Colum nName & "= '" &
> strAtRiskCode & "' ")
Ok, if there's something on that line that ASP.NET doesn't like, then
simplify it:
Dim projectColumnName as String =
AtRiskProjDS.AtRiskProjects.ProjectColumn.ColumnNa me
Dim atRiskCodeColumnName As String =
AtRiskProjDS.AtRiskProjects.AtRiskCodeColumn.Colum nName
Dim query As String = projectColumnName & "= '" & strProject & "' AND " &
atRiskCodeColumnName & "= '" & strAtRiskCode & "' "
Dim rows() As AtRiskProjectsDS.AtRiskProjectsRow =
AtRiskProjDS.AtRiskProjects.Select(query)
Try that and tell us which line has the problem.
John Saunders
I had defined rows() variable as my dataset.datatablerowtype.
eg.
Dim rows() As AtRiskProjectsDS.AtRiskProjectsRow
Framework 1.0 did not like it.
After I changed the rows() variable to simple datarow type as shown
below, it worked fine.
Dim rows() As datarow
Just so if anyone has this problem in the future.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Wednesday, March 28, 2012
System.InvalidCastException: Specified cast is not valid.
I have an table with a field of bit. the fields name is Active.
When trying to add that field to a label it gives me the following.
It all works when not using this field.
Error : System.InvalidCastException: Specified cast is not valid.
get {
Line 2057: try {
Line 2058: return ((bool)(this[this.tableJob_Posts.ActiveColumn]));
Line 2059: }
Line 2060: catch (System.InvalidCastException e) {
jpDT = jpTA.GetJob_PostsByJobID(jid);
foreach (DataSet1.Job_PostsRow jprin jpDT){
if (jpr.Active !=null){
this.ActiveLabel.Text = jpr.Active.ToString();}
Is this field nullable in the database, and are you using TableAdapters? If so, can't simply check for null. You need to instead call the method IsActiveNull() which will be auto-generated by your row class if the field is nullable. This will then check for DbNull instead of null.
System.InvalidOperationException: Collection was modified; enumeration operation may not e
hi all,
i am getting the following error when i am trying to move the ltems form listbox1 to listbox2
"System.InvalidOperationException: Collection was modified; enumeration operation may not execute"
ForEach itemAs ListItemIn Listbox1.ItemsIf item.SelectedAndNot Listbox2.Items.Contains(item)Then
Dim newItemAsNew ListItem(item.Text, item.Value)Listbox2.Items.Add(newItem)
listbox1.Remove(newitem)
EndIf
Next
thanks.
You can't modify the listbox1 item collection while you are iterating over it using "for each". Wait until you add everything to listbox2, and then call Clear() on listbox1.System.InvalidOperationException: Application is restarting
I am getting the following exception in an ASP.NET
application.
Exception Details: System.InvalidOperationException:
Application is restarting.
I have been to the following Support page
http://support.microsoft.com/default.aspx?kbid=312592
and disabled the Realtime monitoring. But, I was not able
to solve the issue.
Any suggestions are greatly appreciated.
Thanks a lot in advance,
Regards
HariHi,
There are vast spectrums of situations that can cause application
restarting. I suggest that you find first the line that causes
application to restart. Start with simple application to check out if
this problem is application specific. If this is the case and other
application doesnt cause recycling you should find the application line
that cause recycling.
Natty Gur[MVP]
blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Thanks Natty for your prompt reply. Unfortunately I don't
have the real access to the code at the moment and I am
kind of new to ASP.NET. But, I understand the technology
well.
The following is the exception I was getting when this
error occurs: Please have a look if it makes sense. Any
advice from your side is greatly respected.
************************************************** *******
Source=System.Web
Message=Application is
restarting.
StackTrace= at
System.Web.Compilation.CompilationMutex.WaitOne()
+282
at System.Web.Compilation.CompilationLock.GetLock()
+13
at System.Web.UI.TemplateParser.GetParserCacheItem()
+64
at
System.Web.UI.TemplateControlParser.CompileAndGetP arserCac
heItem(String
virtualPath, String inputFile, HttpContext context)
+115
at
System.Web.UI.TemplateControlParser.GetCompiledIns tance
(String
virtualPath, String inputFile, HttpContext context)
+36
at System.Web.UI.PageParser.GetCompiledPageInstance
(String
virtualPath, String inputFile, HttpContext context) +43
at System.Web.UI.PageHandlerFactory.GetHandler
(HttpContext context,
String requestType, String url, String path) +14
at System.Web.HttpApplication.MapHttpHandler
(HttpContext context,
String requestType, String path, String pathTranslated,
Boolean
useAppConfig)
at System.Web.MapHandlerExecutionStep.Execute()
+78
at System.Web.HttpApplication.ExecuteStep
(IExecutionStep step,
Boolean& completedSynchronously) +173
AllException=System.InvalidOperationException:
Application is
restarting.
at System.Web.Compilation.CompilationMutex.WaitOne
()
at System.Web.Compilation.CompilationLock.GetLock
()
at System.Web.UI.TemplateParser.GetParserCacheItem
()
at
System.Web.UI.TemplateControlParser.CompileAndGetP arserCac
heItem(String
virtualPath, String inputFile, HttpContext
context)
at
System.Web.UI.TemplateControlParser.GetCompiledIns tance
(String
virtualPath, String inputFile, HttpContext
context)
at System.Web.UI.PageParser.GetCompiledPageInstance
(String
virtualPath, String inputFile, HttpContext
context)
at System.Web.UI.PageHandlerFactory.GetHandler
(HttpContext context,
String requestType, String url, String
path)
at System.Web.HttpApplication.MapHttpHandler
(HttpContext context,
String requestType, String path, String pathTranslated,
Boolean
useAppConfig)
at System.Web.MapHandlerExecutionStep.Execute
()
at System.Web.HttpApplication.ExecuteStep
(IExecutionStep step,
Boolean&
completedSynchronously)
************************************************** *******
Any advice on this is greatly appreciated
Thanks you very much
Best Regards
Hari
>--Original Message--
>Hi,
>There are vast spectrums of situations that can cause
application
>restarting. I suggest that you find first the line that
causes
>application to restart. Start with simple application to
check out if
>this problem is application specific. If this is the
case and other
>application doesn't cause recycling you should find the
application line
>that cause recycling.
>Natty Gur[MVP]
>blog : http://weblogs.asp.net/ngur
>Mobile: +972-(0)58-888377
>
>*** Sent via Developersdex http://www.developersdex.com
***
>Don't just participate in USENET...get rewarded for it!
>.
Hi,
Nothing special with excaption stuck. it's regular operations that
called while loading a page. try to delete the temporary directory of
your application under
""C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\Tempo rary ASP.NET
Files\YourApplicationName".
Natty Gur[MVP]
blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Hi,
Nothing special with excaption stuck. it's regular operations that
called while loading a page. try to delete the temporary directory of
your application under
""C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\Tempo rary ASP.NET
Files\YourApplicationName".
Natty Gur[MVP]
blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
System.IO.IOException: Cannot create a file when that file already exists.
or not:
"System.IO.IOException: Cannot create a file when that file already exists."
Here's the code generating the error (seems to be happening when I try
creating a directory)
If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
lblerror.Text = lblerror.Text & "Unable to build physical path. " &
txt_name.Text & " & Contact Dev Team.<BR>"
Else
dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
This code runs fine on my development server (only the path is c:\blah\blah
instead of S). Also, my production server has failover cluser, and the s
drive is the failover drive. I can't imagine that could be a problem, but
thought I would mention it.
Asside from that, the only other thing I can think of is that the framework
version on my dev box says 1.1, and the one on my production server says:
1.0.37 - surely that's not the cause is it? Permissions shouldn't be an
issue (i've even tried as domain admin)
I would appreciate any help on this, as I'm out of ideas, and can find no
other documentation on this.
- ChadHi,
the default user that runs web application (system) dont has rights to
access network resources.
Natty Gur, CTO
Dao2Com Ltd.
34th Elkalay st. Raanana
Israel , 43000
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
I agree with Natty. The problem you are having is most likely caused by
having no right to access network resources. Willy address a similar
problem before. See
http://groups.google.com/groups?q=S...et&start=10&hl=
en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.
HTH,
-Allen
Disclaimer:
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com
-------
| From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
| Subject: System.IO.IOException: Cannot create a file when that file
already exists.
| Date: Wed, 6 Aug 2003 17:08:27 -0400
| Lines: 29
|
| Getting the following error on my production server whether the file
exists
| or not:
|
| "System.IO.IOException: Cannot create a file when that file already
exists."
|
| Here's the code generating the error (seems to be happening when I try
| creating a directory)
|
| If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
| lblerror.Text = lblerror.Text & "Unable to build physical path. "
&
| txt_name.Text & " & Contact Dev Team.<BR>"
| Else
| dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
|
| This code runs fine on my development server (only the path is
c:\blah\blah
| instead of S). Also, my production server has failover cluser, and the s
| drive is the failover drive. I can't imagine that could be a problem, but
| thought I would mention it.
|
| Asside from that, the only other thing I can think of is that the
framework
| version on my dev box says 1.1, and the one on my production server says:
| 1.0.37 - surely that's not the cause is it? Permissions shouldn't be an
| issue (i've even tried as domain admin)
|
| I would appreciate any help on this, as I'm out of ideas, and can find no
| other documentation on this.
| - Chad
|
|
|
Thanks for the response.
I understand that, but I'm trying to create a directory on the local drive.
This isn't a mapped share. The drive is physically present on the web
server, and if that web server fails, the other system physically takes over
the drive (ie, a cluster). I've also added the local ASPNET account to the
NTFS permissions on the folder, and it still fails.
- Chad
"[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
news:j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl...
> I agree with Natty. The problem you are having is most likely caused by
> having no right to access network resources. Willy address a similar
> problem before. See
http://groups.google.com/groups?q=S...et&start=10&hl=
> en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.
> HTH,
> -Allen
> Disclaimer:
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Got .Net? http://www.gotdotnet.com
> -------
> | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | Subject: System.IO.IOException: Cannot create a file when that file
> already exists.
> | Date: Wed, 6 Aug 2003 17:08:27 -0400
> | Lines: 29
> |
> | Getting the following error on my production server whether the file
> exists
> | or not:
> |
> | "System.IO.IOException: Cannot create a file when that file already
> exists."
> |
> | Here's the code generating the error (seems to be happening when I try
> | creating a directory)
> |
> | If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
> | lblerror.Text = lblerror.Text & "Unable to build physical path.
"
> &
> | txt_name.Text & " & Contact Dev Team.<BR>"
> | Else
> | dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
> |
> | This code runs fine on my development server (only the path is
> c:\blah\blah
> | instead of S). Also, my production server has failover cluser, and the
s
> | drive is the failover drive. I can't imagine that could be a problem,
but
> | thought I would mention it.
> |
> | Asside from that, the only other thing I can think of is that the
> framework
> | version on my dev box says 1.1, and the one on my production server
says:
> | 1.0.37 - surely that's not the cause is it? Permissions shouldn't be an
> | issue (i've even tried as domain admin)
> |
> | I would appreciate any help on this, as I'm out of ideas, and can find
no
> | other documentation on this.
> | - Chad
> |
> |
> |
It doesn't work creating folders under the same directory as the web
application... same issue.
I'm going to try figuring out why that server is showing that it's running
version 1.03 of the dotnet framework. It shows that v1.1 was installed.
Thanks,
Chad
"[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
news:RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl...
> Try creating a directory in your code under the folder where your web
> application resides. Does it works? In addition, you may want to verify
the
> account your web application is running under. Please download tokedump
> written by Keith Brown from
> http://msdn.microsoft.com/msdnmag/i...ty/default.aspx. It
> would show you what account the application is running under.
> -Allen
> Disclaimer:
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Got .Net? http://www.gotdotnet.com
> -------
> | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
> <j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
> | Subject: Re: System.IO.IOException: Cannot create a file when that file
> already exists.
> | Date: Thu, 7 Aug 2003 08:11:44 -0400
> | Lines: 78
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | Message-ID: <exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
> | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | NNTP-Posting-Host: 12.108.244.117
> | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
> | Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet:165699
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> |
> | Thanks for the response.
> |
> | I understand that, but I'm trying to create a directory on the local
> drive.
> | This isn't a mapped share. The drive is physically present on the web
> | server, and if that web server fails, the other system physically takes
> over
> | the drive (ie, a cluster). I've also added the local ASPNET account to
> the
> | NTFS permissions on the folder, and it still fails.
> |
> | - Chad
> |
> |
> | "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
> | news:j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl...
> | > I agree with Natty. The problem you are having is most likely caused
by
> | > having no right to access network resources. Willy address a similar
> | > problem before. See
> | >
> |
http://groups.google.com/groups?q=S...et&start=10&hl=
> | > en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.
> | >
> | > HTH,
> | > -Allen
> | >
> | > Disclaimer:
> | > This posting is provided "AS IS" with no warranties, and confers no
> | rights.
> | > Got .Net? http://www.gotdotnet.com
> | >
> | > -------
> | > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | > | Subject: System.IO.IOException: Cannot create a file when that file
> | > already exists.
> | > | Date: Wed, 6 Aug 2003 17:08:27 -0400
> | > | Lines: 29
> | > |
> | > | Getting the following error on my production server whether the file
> | > exists
> | > | or not:
> | > |
> | > | "System.IO.IOException: Cannot create a file when that file already
> | > exists."
> | > |
> | > | Here's the code generating the error (seems to be happening when I
try
> | > | creating a directory)
> | > |
> | > | If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
> | > | lblerror.Text = lblerror.Text & "Unable to build physical
> path.
> | "
> | > &
> | > | txt_name.Text & " & Contact Dev Team.<BR>"
> | > | Else
> | > | dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
> | > |
> | > | This code runs fine on my development server (only the path is
> | > c:\blah\blah
> | > | instead of S). Also, my production server has failover cluser, and
> the
> | s
> | > | drive is the failover drive. I can't imagine that could be a
problem,
> | but
> | > | thought I would mention it.
> | > |
> | > | Asside from that, the only other thing I can think of is that the
> | > framework
> | > | version on my dev box says 1.1, and the one on my production server
> | says:
> | > | 1.0.37 - surely that's not the cause is it? Permissions shouldn't
be
> an
> | > | issue (i've even tried as domain admin)
> | > |
> | > | I would appreciate any help on this, as I'm out of ideas, and can
find
> | no
> | > | other documentation on this.
> | > | - Chad
> | > |
> | > |
> | > |
> | >
> |
> |
> |
Chad, was the problem resolved? It seems that you installed both v1.03 and
v1.1 on the same web server. If so, it might be helpful to look at the
article "Compatibility Considerations and Version Changes" on
http://www.gotdotnet.com/team/changeinfo/default.aspx. Try configuring your
web application to run V1.03 and V1.1 specifically to see how it works.
-Allen
Disclaimer:
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com
-------
| From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
| References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
<j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
<exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
<RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl>
| Subject: Re: System.IO.IOException: Cannot create a file when that file
already exists.
| Date: Mon, 11 Aug 2003 01:16:22 -0400
| Lines: 141
|
|
| It doesn't work creating folders under the same directory as the web
| application... same issue.
|
| I'm going to try figuring out why that server is showing that it's running
| version 1.03 of the dotnet framework. It shows that v1.1 was installed.
|
| Thanks,
| Chad
|
| "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
| news:RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl...
| > Try creating a directory in your code under the folder where your web
| > application resides. Does it works? In addition, you may want to verify
| the
| > account your web application is running under. Please download tokedump
| > written by Keith Brown from
| > http://msdn.microsoft.com/msdnmag/i...ty/default.aspx. It
| > would show you what account the application is running under.
| >
| > -Allen
| >
| > Disclaimer:
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| > Got .Net? http://www.gotdotnet.com
| >
| > -------
| > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
| > | References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
| > <j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
| > | Subject: Re: System.IO.IOException: Cannot create a file when that
file
| > already exists.
| > | Date: Thu, 7 Aug 2003 08:11:44 -0400
| > | Lines: 78
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: 12.108.244.117
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.aspnet:165699
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | Thanks for the response.
| > |
| > | I understand that, but I'm trying to create a directory on the local
| > drive.
| > | This isn't a mapped share. The drive is physically present on the
web
| > | server, and if that web server fails, the other system physically
takes
| > over
| > | the drive (ie, a cluster). I've also added the local ASPNET account
to
| > the
| > | NTFS permissions on the folder, and it still fails.
| > |
| > | - Chad
| > |
| > |
| > | "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
| > | news:j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl...
| > | > I agree with Natty. The problem you are having is most likely caused
| by
| > | > having no right to access network resources. Willy address a similar
| > | > problem before. See
| > | >
| > |
| >
|
http://groups.google.com/groups?q=S...et&start=10&hl=
| > | >
en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.
| > | >
| > | > HTH,
| > | > -Allen
| > | >
| > | > Disclaimer:
| > | > This posting is provided "AS IS" with no warranties, and confers no
| > | rights.
| > | > Got .Net? http://www.gotdotnet.com
| > | >
| > | > -------
| > | > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
| > | > | Subject: System.IO.IOException: Cannot create a file when that
file
| > | > already exists.
| > | > | Date: Wed, 6 Aug 2003 17:08:27 -0400
| > | > | Lines: 29
| > | > |
| > | > | Getting the following error on my production server whether the
file
| > | > exists
| > | > | or not:
| > | > |
| > | > | "System.IO.IOException: Cannot create a file when that file
already
| > | > exists."
| > | > |
| > | > | Here's the code generating the error (seems to be happening when I
| try
| > | > | creating a directory)
| > | > |
| > | > | If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
| > | > | lblerror.Text = lblerror.Text & "Unable to build physical
| > path.
| > | "
| > | > &
| > | > | txt_name.Text & " & Contact Dev Team.<BR>"
| > | > | Else
| > | > | dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
| > | > |
| > | > | This code runs fine on my development server (only the path is
| > | > c:\blah\blah
| > | > | instead of S). Also, my production server has failover cluser,
and
| > the
| > | s
| > | > | drive is the failover drive. I can't imagine that could be a
| problem,
| > | but
| > | > | thought I would mention it.
| > | > |
| > | > | Asside from that, the only other thing I can think of is that the
| > | > framework
| > | > | version on my dev box says 1.1, and the one on my production
server
| > | says:
| > | > | 1.0.37 - surely that's not the cause is it? Permissions shouldn't
| be
| > an
| > | > | issue (i've even tried as domain admin)
| > | > |
| > | > | I would appreciate any help on this, as I'm out of ideas, and can
| find
| > | no
| > | > | other documentation on this.
| > | > | - Chad
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|
Allen,
Thanks for the followup. I actually got my program working late last night.
The problem was the framework version.
I tried simply configuring the web application to use version 1.1, but that
didn't help. I also tried uninstalling then reinstalling framework version
1.1, but that also didn't get IIS to start using version 1.1 by default. I
consequently uninstalled versions 1.1 *and* version 1.03, then only
reinstalled version 1.1 again, and this took care of the problem.
Thanks again for all the help everyone!
- Chad
"[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
news:hNsBh8sYDHA.2352@.cpmsftngxa06.phx.gbl...
> Chad, was the problem resolved? It seems that you installed both v1.03 and
> v1.1 on the same web server. If so, it might be helpful to look at the
> article "Compatibility Considerations and Version Changes" on
> http://www.gotdotnet.com/team/changeinfo/default.aspx. Try configuring
your
> web application to run V1.03 and V1.1 specifically to see how it works.
> -Allen
> Disclaimer:
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Got .Net? http://www.gotdotnet.com
> -------
> | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
> <j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
> <exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
> <RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl>
> | Subject: Re: System.IO.IOException: Cannot create a file when that file
> already exists.
> | Date: Mon, 11 Aug 2003 01:16:22 -0400
> | Lines: 141
> |
> |
> | It doesn't work creating folders under the same directory as the web
> | application... same issue.
> |
> | I'm going to try figuring out why that server is showing that it's
running
> | version 1.03 of the dotnet framework. It shows that v1.1 was installed.
> |
> | Thanks,
> | Chad
> |
> | "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
> | news:RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl...
> | > Try creating a directory in your code under the folder where your web
> | > application resides. Does it works? In addition, you may want to
verify
> | the
> | > account your web application is running under. Please download
tokedump
> | > written by Keith Brown from
> | > http://msdn.microsoft.com/msdnmag/i...ty/default.aspx.
It
> | > would show you what account the application is running under.
> | >
> | > -Allen
> | >
> | > Disclaimer:
> | > This posting is provided "AS IS" with no warranties, and confers no
> | rights.
> | > Got .Net? http://www.gotdotnet.com
> | >
> | > -------
> | > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | > | References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
> | > <j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
> | > | Subject: Re: System.IO.IOException: Cannot create a file when that
> file
> | > already exists.
> | > | Date: Thu, 7 Aug 2003 08:11:44 -0400
> | > | Lines: 78
> | > | X-Priority: 3
> | > | X-MSMail-Priority: Normal
> | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | > | Message-ID: <exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | > | NNTP-Posting-Host: 12.108.244.117
> | > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
> | > | Xref: cpmsftngxa06.phx.gbl
> | microsoft.public.dotnet.framework.aspnet:165699
> | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> | > |
> | > | Thanks for the response.
> | > |
> | > | I understand that, but I'm trying to create a directory on the local
> | > drive.
> | > | This isn't a mapped share. The drive is physically present on the
> web
> | > | server, and if that web server fails, the other system physically
> takes
> | > over
> | > | the drive (ie, a cluster). I've also added the local ASPNET account
> to
> | > the
> | > | NTFS permissions on the folder, and it still fails.
> | > |
> | > | - Chad
> | > |
> | > |
> | > | "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
> | > | news:j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl...
> | > | > I agree with Natty. The problem you are having is most likely
caused
> | by
> | > | > having no right to access network resources. Willy address a
similar
> | > | > problem before. See
> | > | >
> | > |
> | >
> |
http://groups.google.com/groups?q=S...et&start=10&hl=
> | > | >
> en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.
> | > | >
> | > | > HTH,
> | > | > -Allen
> | > | >
> | > | > Disclaimer:
> | > | > This posting is provided "AS IS" with no warranties, and confers
no
> | > | rights.
> | > | > Got .Net? http://www.gotdotnet.com
> | > | >
> | > | > -------
> | > | > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | > | > | Subject: System.IO.IOException: Cannot create a file when that
> file
> | > | > already exists.
> | > | > | Date: Wed, 6 Aug 2003 17:08:27 -0400
> | > | > | Lines: 29
> | > | > |
> | > | > | Getting the following error on my production server whether the
> file
> | > | > exists
> | > | > | or not:
> | > | > |
> | > | > | "System.IO.IOException: Cannot create a file when that file
> already
> | > | > exists."
> | > | > |
> | > | > | Here's the code generating the error (seems to be happening when
I
> | try
> | > | > | creating a directory)
> | > | > |
> | > | > | If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
> | > | > | lblerror.Text = lblerror.Text & "Unable to build
physical
> | > path.
> | > | "
> | > | > &
> | > | > | txt_name.Text & " & Contact Dev Team.<BR>"
> | > | > | Else
> | > | > | dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
> | > | > |
> | > | > | This code runs fine on my development server (only the path is
> | > | > c:\blah\blah
> | > | > | instead of S). Also, my production server has failover cluser,
> and
> | > the
> | > | s
> | > | > | drive is the failover drive. I can't imagine that could be a
> | problem,
> | > | but
> | > | > | thought I would mention it.
> | > | > |
> | > | > | Asside from that, the only other thing I can think of is that
the
> | > | > framework
> | > | > | version on my dev box says 1.1, and the one on my production
> server
> | > | says:
> | > | > | 1.0.37 - surely that's not the cause is it? Permissions
shouldn't
> | be
> | > an
> | > | > | issue (i've even tried as domain admin)
> | > | > |
> | > | > | I would appreciate any help on this, as I'm out of ideas, and
can
> | find
> | > | no
> | > | > | other documentation on this.
> | > | > | - Chad
> | > | > |
> | > | > |
> | > | > |
> | > | >
> | > |
> | > |
> | > |
> | >
> |
> |
> |
System.IO?
imported in all ASP.NET page automatically but in the following code:
<%@dotnet.itags.org. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>
if I get rid of the <%@dotnet.itags.org. Import....%line, then ASP.NET generates the
following error:
Type 'FileInfo' is not defined.
pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).
Why?
Please correct me if I am wrong.
Thanks,
Arpanre:
Quote:
Originally Posted by
If I am not wrong, System.IO is one of the seven namespaces
that get imported in all ASP.NET page automatically
You are wrong.
If you wish to use System.IO, you must import it explicitly.
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...
Quote:
Originally Posted by
If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:
>
<%@. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>
lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>
>
if I get rid of the <%@. Import....%line, then ASP.NET generates the
following error:
>
Type 'FileInfo' is not defined.
>
pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).
>
Why?
>
Please correct me if I am wrong.
>
Thanks,
>
Arpan
>
Thanks Juan for pointing out my mistake. Actually the ASP.NET book I am
referring to learn ASP.NET states that System.IO is one of the seven
namespaces that get imported automatically by all ASP.NET pages - the
remaining 6 being
System
System.Collections
System.Web
System.Web.UI
System.Web.UI.HtmlControls
System.Web.UI.WebControls
I hope the above 6 namespaces "do" get imported automatically by all
ASP.NET pages. If not, then please let me know. God knows what all I
must have learnt wrong from that ASP.NET book!
BTW, are there any additional namespaces apart from the above 6 that
all ASP.NET pages import automatically?
Thanks once again,
Regards,
Arpan
Juan T. Llibre wrote:
Quote:
Originally Posted by
re:
Quote:
Originally Posted by
If I am not wrong, System.IO is one of the seven namespaces
that get imported in all ASP.NET page automatically
>
You are wrong.
>
If you wish to use System.IO, you must import it explicitly.
>
>
>
>
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...
Quote:
Originally Posted by
If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:
<%@. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>
if I get rid of the <%@. Import....%line, then ASP.NET generates the
following error:
Type 'FileInfo' is not defined.
pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).
Why?
Please correct me if I am wrong.
Thanks,
Arpan
Arpan,
If you do not see it in the using .. list (or "Import" in VB.NET) when you
create a class or web page, then you need to explicitly add it an ensure that
the project has a reference to the namespace assembly. If it isn't there, you
will find out about it very quickly!
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Arpan" wrote:
Quote:
Originally Posted by
Thanks Juan for pointing out my mistake. Actually the ASP.NET book I am
referring to learn ASP.NET states that System.IO is one of the seven
namespaces that get imported automatically by all ASP.NET pages - the
remaining 6 being
>
System
System.Collections
System.Web
System.Web.UI
System.Web.UI.HtmlControls
System.Web.UI.WebControls
>
I hope the above 6 namespaces "do" get imported automatically by all
ASP.NET pages. If not, then please let me know. God knows what all I
must have learnt wrong from that ASP.NET book!
>
BTW, are there any additional namespaces apart from the above 6 that
all ASP.NET pages import automatically?
>
Thanks once again,
>
Regards,
>
Arpan
>
>
Juan T. Llibre wrote:
Quote:
Originally Posted by
re:
Quote:
Originally Posted by
If I am not wrong, System.IO is one of the seven namespaces
that get imported in all ASP.NET page automatically
You are wrong.
If you wish to use System.IO, you must import it explicitly.
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...
Quote:
Originally Posted by
If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:
>
<%@. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>
lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>
>
if I get rid of the <%@. Import....%line, then ASP.NET generates the
following error:
>
Type 'FileInfo' is not defined.
>
pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).
>
Why?
>
Please correct me if I am wrong.
>
Thanks,
>
Arpan
>
>
>
In ASP.NET 2.0, you can control which namespaces are
imported automatically by configuring them in web.config.
Any namespace you define in web.config will be automatically imported,
and you will not have to import it specifically.
See :
http://msdn2.microsoft.com/en-us/li...collection.aspx
and
http://msdn2.microsoft.com/en-us/li...gessection.aspx
re:
Quote:
Originally Posted by
I hope the above 6 namespaces "do" get imported automatically by all ASP.NET pages.
If not, then please let me know.
BTW, are there any additional namespaces apart from the above 6 that
all ASP.NET pages import automatically?
In ASP.NET 2.0, the default namespaces are defined in the default web.config, located in :
Drive:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ CONFIG
Here they are :
<pages>
<namespaces>
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
</pages>
You could add System.IO, so it's automatically imported, by adding :
<add namespace="System.IO" />
to the <namespacessection of web.config.
Of course, any other namespace you want to import automatically can also be added.
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156710516.410124.90070@.m79g2000cwm.googlegro ups.com...
Thanks Juan for pointing out my mistake. Actually the ASP.NET book I am
referring to learn ASP.NET states that System.IO is one of the seven
namespaces that get imported automatically by all ASP.NET pages - the
remaining 6 being
System
System.Collections
System.Web
System.Web.UI
System.Web.UI.HtmlControls
System.Web.UI.WebControls
I hope the above 6 namespaces "do" get imported automatically by all
ASP.NET pages. If not, then please let me know. God knows what all I
must have learnt wrong from that ASP.NET book!
BTW, are there any additional namespaces apart from the above 6 that
all ASP.NET pages import automatically?
Thanks once again,
Regards,
Arpan
Juan T. Llibre wrote:
Quote:
Originally Posted by
re:
Quote:
Originally Posted by
If I am not wrong, System.IO is one of the seven namespaces
that get imported in all ASP.NET page automatically
>
You are wrong.
>
If you wish to use System.IO, you must import it explicitly.
>
>
>
>
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...
Quote:
Originally Posted by
If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:
<%@. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>
if I get rid of the <%@. Import....%line, then ASP.NET generates the
following error:
Type 'FileInfo' is not defined.
pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).
Why?
Please correct me if I am wrong.
Thanks,
Arpan
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...
Quote:
Originally Posted by
Please correct me if I am wrong.
You are wrong.
Thanks all of you for your helpful inputs.
Regards,
Arpan
Mark Rae wrote:
Quote:
Originally Posted by
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...
>
Quote:
Originally Posted by
Please correct me if I am wrong.
>
You are wrong.
Juan T. Llibre wrote:
Quote:
Originally Posted by
re:
Quote:
Originally Posted by
>If I am not wrong, System.IO is one of the seven namespaces
>that get imported in all ASP.NET page automatically
>
You are wrong.
>
If you wish to use System.IO, you must import it explicitly.
>
>
>
>
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...
Quote:
Originally Posted by
>If I am not wrong, System.IO is one of the seven namespaces that get
>imported in all ASP.NET page automatically but in the following code:
>>
><%@. Import Namespace="System.IO" %>
><script runat="server">
> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
> Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>>
> lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
> lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
> lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
>& "<br>"
> lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
>"<br>"
> lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
> End Sub
></script>
><form runat="server">
><asp:Label ID="lblOutput" runat="server">
></form>
>>
>if I get rid of the <%@. Import....%line, then ASP.NET generates the
>following error:
>>
>Type 'FileInfo' is not defined.
>>
>pointing to the very first line within the Page_Load sub (Dim
>ioFileInfo As New FileInfo...).
>>
>Why?
>>
>Please correct me if I am wrong.
>>
>Thanks,
>>
>Arpan
>>
>
>
Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the
compilation section to see the default imports (there are nine).
For 1.1 look in <framework dir>\v1.1.4322\CONFIG\machine.config. There
are eight listed there. The new one in 2.0 is System.Configuration.
Kevin Jones
re:
Quote:
Originally Posted by
Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the compilation section to see
the default imports (there are nine).
Kevin,
don't you consider mscorlib to be one of them ?
<add assembly="mscorlib" />
Also, doesn't the vbc compiler automatically import Microsoft.VisualBasic ?
Also, isn't the list supplied in the default web.config's pages element accurate ?
<pages>
<namespaces>
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
</pages>
Won't any namespace defined in web.config be automatically imported,
and you will not have to import it specifically ?
See :
http://msdn2.microsoft.com/en-us/li...collection.aspx
and
http://msdn2.microsoft.com/en-us/li...gessection.aspx
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Kevin Jones" <kjonesNOSPAM@.develop.comwrote in message
news:O6w44soyGHA.1252@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
Juan T. Llibre wrote:
Quote:
Originally Posted by
>re:
Quote:
Originally Posted by
>>If I am not wrong, System.IO is one of the seven namespaces
>>that get imported in all ASP.NET page automatically
>>
>You are wrong.
>>
>If you wish to use System.IO, you must import it explicitly.
>>
>>
>>
>>
>Juan T. Llibre, asp.net MVP
>aspnetfaq.com : http://www.aspnetfaq.com/
>asp.net faq : http://asp.net.do/faq/
>foros de asp.net, en espaol : http://asp.net.do/foros/
>===================================
>"Arpan" <arpan_de@.hotmail.comwrote in message
>news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...
Quote:
Originally Posted by
>>If I am not wrong, System.IO is one of the seven namespaces that get
>>imported in all ASP.NET page automatically but in the following code:
>>>
>><%@. Import Namespace="System.IO" %>
>><script runat="server">
>> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
>> Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>>>
>> lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
>> lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
>> lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
>>& "<br>"
>> lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
>>"<br>"
>> lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
>> End Sub
>></script>
>><form runat="server">
>><asp:Label ID="lblOutput" runat="server">
>></form>
>>>
>>if I get rid of the <%@. Import....%line, then ASP.NET generates the
>>following error:
>>>
>>Type 'FileInfo' is not defined.
>>>
>>pointing to the very first line within the Page_Load sub (Dim
>>ioFileInfo As New FileInfo...).
>>>
>>Why?
>>>
>>Please correct me if I am wrong.
>>>
>>Thanks,
>>>
>>Arpan
>>>
>>
>>
Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the compilation section to see
the default imports (there are nine).
>
For 1.1 look in <framework dir>\v1.1.4322\CONFIG\machine.config. There are eight listed there. The
new one in 2.0 is System.Configuration.
>
Kevin Jones
don't you consider mscorlib to be one of them ?
Quote:
Originally Posted by
>
<add assembly="mscorlib" />
Oops, yep of course.
Quote:
Originally Posted by
Also, doesn't the vbc compiler automatically import
Microsoft.VisualBasic ?
Ah! I don't do VB, so I didn't look :)
Quote:
Originally Posted by
Also, isn't the list supplied in the default web.config's pages
element accurate ?
Quote:
Originally Posted by
>
<pages>
<namespaces>
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
</pages>
Yep, but I was listing the assemblies not the namespaces, which of
course I should have been.
Quote:
Originally Posted by
Won't any namespace defined in web.config be automatically imported,
and you will not have to import it specifically ?
>
See :
>
http://msdn2.microsoft.com/en-us/li...collection.aspx
Quote:
Originally Posted by
and
>
http://msdn2.microsoft.com/en-us/li...gessection.aspx
Quote:
Originally Posted by
>
Juan T. Llibre wrote:
Quote:
Originally Posted by
re:
Quote:
Originally Posted by
>Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the compilation section to see
>the default imports (there are nine).
>
Kevin,
>
>
>
>
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Kevin Jones" <kjonesNOSPAM@.develop.comwrote in message
news:O6w44soyGHA.1252@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
>Juan T. Llibre wrote:
Quote:
Originally Posted by
>>re:
>>>If I am not wrong, System.IO is one of the seven namespaces
>>>that get imported in all ASP.NET page automatically
>>You are wrong.
>>>
>>If you wish to use System.IO, you must import it explicitly.
>>>
>>>
>>>
>>>
>>Juan T. Llibre, asp.net MVP
>>aspnetfaq.com : http://www.aspnetfaq.com/
>>asp.net faq : http://asp.net.do/faq/
>>foros de asp.net, en espaol : http://asp.net.do/foros/
>>===================================
>>"Arpan" <arpan_de@.hotmail.comwrote in message
>>news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...
>>>If I am not wrong, System.IO is one of the seven namespaces that get
>>>imported in all ASP.NET page automatically but in the following code:
>>>>
>>><%@. Import Namespace="System.IO" %>
>>><script runat="server">
>>> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
>>> Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>>>>
>>> lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
>>> lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
>>> lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
>>>& "<br>"
>>> lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
>>>"<br>"
>>> lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
>>> End Sub
>>></script>
>>><form runat="server">
>>><asp:Label ID="lblOutput" runat="server">
>>></form>
>>>>
>>>if I get rid of the <%@. Import....%line, then ASP.NET generates the
>>>following error:
>>>>
>>>Type 'FileInfo' is not defined.
>>>>
>>>pointing to the very first line within the Page_Load sub (Dim
>>>ioFileInfo As New FileInfo...).
>>>>
>>>Why?
>>>>
>>>Please correct me if I am wrong.
>>>>
>>>Thanks,
>>>>
>>>Arpan
>>>>
>>>
>Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the compilation section to see
>the default imports (there are nine).
>>
>For 1.1 look in <framework dir>\v1.1.4322\CONFIG\machine.config. There are eight listed there. The
>new one in 2.0 is System.Configuration.
>>
>Kevin Jones
>
>