Showing posts with label run. Show all posts
Showing posts with label run. Show all posts

Saturday, March 31, 2012

System.InvalidCastException: Specified cast is not valid.

Hi
I get the this error when i run my code:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
this.DataGrid1.DataSource= this.DataSource();
this.DataGrid1.DataBind();
}
private ICollection DataSource()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("kol0",typeof(Int16)));
for (int i=0;i<10;i++)
{
DataRow dr = dt.NewRow();
if (i%2==0)
{
dr[0]=1;
}
else
{
dr[0]=0;
}
dt.Rows.Add(dr);
}
DataView dv;
dv = new DataView(dt);
return dv;
}
private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
int i = e.Item.ItemIndex;
if(i==0)
{
((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
}
}
page:
one two
one two
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
absolute; TOP: 56px" runat="server"
Height="216px" Width="448px" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:DropDownList ID="dll" Runat="server">
<asp:ListItem Value="0">one</asp:ListItem>
<asp:ListItem Value="1">two</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
ch JIt would help if you told us the line #. Is it at:
((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
First of all, it looks like you are doing that when ItemIndex == 0
wouldn't that be ur HeaderTemplate in which case cell[0].Controls[0]. really
might not be what you expect. Secondly, you might prefer
e.Item.FindControl("dll") or e.Item.Cells[0].FindContorl("dll") (not sure
which will work, favor the first one if it'll work) over using indexes. It
makes your code more flexible and less likely to break. Sometimes literals
(like spaces and newlines) are converted to controls, so while you might
think it's Controls[0], it might really be Controls[1] 'cuz there was a
newline before it.
It should be pretty easy to step through your code and debug though...
Karl
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
"Jimmy" <beffer@.gmail.com> wrote in message
news:eX0b2r$yFHA.2556@.TK2MSFTNGP10.phx.gbl...
> Hi
> I get the this error when i run my code:
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> this.DataGrid1.DataSource= this.DataSource();
> this.DataGrid1.DataBind();
> }
> private ICollection DataSource()
> {
> DataTable dt = new DataTable();
>
> dt.Columns.Add(new DataColumn("kol0",typeof(Int16)));
>
> for (int i=0;i<10;i++)
> {
> DataRow dr = dt.NewRow();
> if (i%2==0)
> {
> dr[0]=1;
>
> }
> else
> {
> dr[0]=0;
>
> }
> dt.Rows.Add(dr);
> }
> DataView dv;
> dv = new DataView(dt);
> return dv;
> }
> private void DataGrid1_ItemDataBound(object sender,
> System.Web.UI.WebControls.DataGridItemEventArgs e)
> {
> int i = e.Item.ItemIndex;
> if(i==0)
> {
> ((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
> }
>
> }
>
> page:
>
> one two
> one two
> <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
> absolute; TOP: 56px" runat="server"
> Height="216px" Width="448px" AutoGenerateColumns="False">
> <Columns>
> <asp:TemplateColumn>
> <ItemTemplate>
> <asp:DropDownList ID="dll" Runat="server">
> <asp:ListItem Value="0">one</asp:ListItem>
> <asp:ListItem Value="1">two</asp:ListItem>
> </asp:DropDownList>
> </ItemTemplate>
> </asp:TemplateColumn>
> </Columns>
> </asp:DataGrid>
> ch J
>
>
>

System.InvalidCastException: Specified cast is not valid.

Hi

I get the this error when i run my code:

private void Page_Load(object sender, System.EventArgs e)

{

// Put user code to initialize the page here

this.DataGrid1.DataSource= this.DataSource();

this.DataGrid1.DataBind();

}

private ICollection DataSource()

{

DataTable dt = new DataTable();

dt.Columns.Add(new DataColumn("kol0",typeof(Int16)));

for (int i=0;i<10;i++)

{

DataRow dr = dt.NewRow();

if (i%2==0)

{

dr[0]=1;

}

else

{

dr[0]=0;

}

dt.Rows.Add(dr);

}

DataView dv;

dv = new DataView(dt);

return dv;

}

private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)

{

int i = e.Item.ItemIndex;

if(i==0)

{

((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";

}

}

page:

one two
one two
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
absolute; TOP: 56px" runat="server"
Height="216px" Width="448px" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:DropDownList ID="dll" Runat="server">
<asp:ListItem Value="0">one</asp:ListItem>
<asp:ListItem Value="1">two</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid
ch JIt would help if you told us the line #. Is it at:
((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";

First of all, it looks like you are doing that when ItemIndex == 0
wouldn't that be ur HeaderTemplate in which case cell[0].Controls[0]. really
might not be what you expect. Secondly, you might prefer
e.Item.FindControl("dll") or e.Item.Cells[0].FindContorl("dll") (not sure
which will work, favor the first one if it'll work) over using indexes. It
makes your code more flexible and less likely to break. Sometimes literals
(like spaces and newlines) are converted to controls, so while you might
think it's Controls[0], it might really be Controls[1] 'cuz there was a
newline before it.

It should be pretty easy to step through your code and debug though...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy" <beffer@.gmail.com> wrote in message
news:eX0b2r$yFHA.2556@.TK2MSFTNGP10.phx.gbl...
> Hi
> I get the this error when i run my code:
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> this.DataGrid1.DataSource= this.DataSource();
> this.DataGrid1.DataBind();
> }
> private ICollection DataSource()
> {
> DataTable dt = new DataTable();
>
> dt.Columns.Add(new DataColumn("kol0",typeof(Int16)));
>
> for (int i=0;i<10;i++)
> {
> DataRow dr = dt.NewRow();
> if (i%2==0)
> {
> dr[0]=1;
>
> }
> else
> {
> dr[0]=0;
>
> }
> dt.Rows.Add(dr);
> }
> DataView dv;
> dv = new DataView(dt);
> return dv;
> }
> private void DataGrid1_ItemDataBound(object sender,
> System.Web.UI.WebControls.DataGridItemEventArgs e)
> {
> int i = e.Item.ItemIndex;
> if(i==0)
> {
> ((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
> }
>
> }
>
> page:
>
> one two
> one two
> <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
> absolute; TOP: 56px" runat="server"
> Height="216px" Width="448px" AutoGenerateColumns="False">
> <Columns>
> <asp:TemplateColumn>
> <ItemTemplate>
> <asp:DropDownList ID="dll" Runat="server">
> <asp:ListItem Value="0">one</asp:ListItem>
> <asp:ListItem Value="1">two</asp:ListItem>
> </asp:DropDownList>
> </ItemTemplate>
> </asp:TemplateColumn>
> </Columns>
> </asp:DataGrid>
> ch J
>
>

Saturday, March 24, 2012

System.Net.WebPermission Error?

Hi, I' trying to read some RSS feeds and all works fine on the DEV
machin. once it's at Magma i run into this error.

Security Exception
Description: The application attempted to perform an operation not
allowed by the security policy. To grant this application the required

permission please contact your system administrator or change the
application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the
permission of type 'System.Net.WebPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:

Line 31: //XmlTextReader xmlReader = new
XmlTextReader(RSSURL);
Line 32: DataSet ds = new DataSet();
Line 33: ds.ReadXml(RSSURL); <<<<<<<<<<<<<<<<<error
Line 34: return ds.Tables[2];
Line 35: }

Source File: d:\users\cahrp\html\Controls\MedicalNewsFeeds.ascx .cs
Line: 33

What should i be doing to solve this any help or hints would be
greatley apreciated.

Thanks,
Bilal
www.bilalhamdan.comyou using webclient, or using a web reference, but your website is not
allowed to access http resouces. talk to hoster to supply the permissions.

-- bruce (sqlwork.com)

<bilal.hamdan@.gmail.comwrote in message
news:1155581685.889730.98870@.h48g2000cwc.googlegro ups.com...

Quote:

Originally Posted by

Hi, I' trying to read some RSS feeds and all works fine on the DEV
machin. once it's at Magma i run into this error.
>
Security Exception
Description: The application attempted to perform an operation not
allowed by the security policy. To grant this application the required
>
permission please contact your system administrator or change the
application's trust level in the configuration file.
>
>
Exception Details: System.Security.SecurityException: Request for the
permission of type 'System.Net.WebPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
>
>
Source Error:
>
>
Line 31: //XmlTextReader xmlReader = new
XmlTextReader(RSSURL);
Line 32: DataSet ds = new DataSet();
Line 33: ds.ReadXml(RSSURL); <<<<<<<<<<<<<<<<<error
Line 34: return ds.Tables[2];
Line 35: }
>
>
Source File: d:\users\cahrp\html\Controls\MedicalNewsFeeds.ascx .cs
Line: 33
>
>
>
>
What should i be doing to solve this any help or hints would be
greatley apreciated.
>
Thanks,
Bilal
www.bilalhamdan.com
>

Tuesday, March 13, 2012

System.Runtime.InteropServices.COMException (0x800A1066)

I m using Office 10.0 Com library for power point and for word application in
my Web application but when i run it through web server of web hosting site
that time it is throwing exception like following

System.Runtime.InteropServices.COMException (0x800A1066)

can any one help me regarding this."akshar108" <u37462@.uwewrote in message news:783f955f1cd23@.uwe...

Quote:

Originally Posted by

>I m using Office 10.0 Com library for power point and for word application
>in
my Web application but when i run it through web server of web hosting
site
that time it is throwing exception like following
>
System.Runtime.InteropServices.COMException (0x800A1066)
>
can any one help me regarding this.


Server-side Office automation isn't supported by Microsoft because, as you
have discovered, it doesn't work:
http://support.microsoft.com/defaul...-US;q257757#kb2
Depending on what your exact requirements are, this will be your only
option:
http://www.aspose.com/Products/Aspo...ds/Default.aspx
http://www.aspose.com/Products/Aspo...es/Default.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
but if i want to use free component then how can i count word of doc, ppt
files and do u know any technique for count word of pdf file in .net then
please say me

Mark Rae [MVP] wrote:

Quote:

Originally Posted by

Quote:

Originally Posted by

>>I m using Office 10.0 Com library for power point and for word application
>>in


>[quoted text clipped - 5 lines]

Quote:

Originally Posted by

>>
>can any one help me regarding this.


>
>Server-side Office automation isn't supported by Microsoft because, as you
>have discovered, it doesn't work:
>http://support.microsoft.com/defaul...-US;q257757#kb2
>
>Depending on what your exact requirements are, this will be your only
>option:
>http://www.aspose.com/Products/Aspo...ds/Default.aspx
>http://www.aspose.com/Products/Aspo...es/Default.aspx
>


"akshar108" <u37462@.uwewrote in message news:7840ea68455d9@.uwe...

Quote:

Originally Posted by

Quote:

Originally Posted by

>>Server-side Office automation isn't supported by Microsoft because, as you
>>have discovered, it doesn't work:
>>http://support.microsoft.com/defaul...-US;q257757#kb2
>>
>>Depending on what your exact requirements are, this will be your only
>>option:
>>http://www.aspose.com/Products/Aspo...ds/Default.aspx
>>http://www.aspose.com/Products/Aspo...es/Default.aspx


Quote:

Originally Posted by

but if i want to use free component then how can i count word of doc, ppt
files and do u know any technique for count word of pdf file in .net then


You'll have to look for a free component to do this - I don't know of one...

However, Aspose will do everything you require...

--
Mark Rae
ASP.NET MVP
http://www.markrae.net

System.Runtime.Serialization.SerializationExceptio n:

Hello,
I'm getting the following error now with my aplication, but only when I run it ocally on my machine:
System.Runtime.Serialization.SerializationExceptio n: Cannot find member name System.Data.SqlClient.SqlError.
If I push the same build to a production server it runs without issue. This began happening suddenly and was working without issue locally on my machine. I've made no configuration changes to the machine except install windows updates.

Any ideas on how to get around this are much much appreciated..
ThanksHave you recently updated your local machine from .NET 1.0 to 1.1? Maybe you
are having this issue:
http://www.glacialcomponents.com/Ar...tionExceptio n

--
Hope this helps,
Bryant Hankins
Numinet Systems Inc.
http://www.numinet.com

"Really stuck" <Really stuck@.discussions.microsoft.com> wrote in message
news:1F535AEF-EA81-482B-B1AE-CFC7F7029B8F@.microsoft.com...
> Hello,
> I'm getting the following error now with my aplication, but only when I
run it ocally on my machine:
> System.Runtime.Serialization.SerializationExceptio n: Cannot find member
name System.Data.SqlClient.SqlError.
> If I push the same build to a production server it runs without issue.
This began happening suddenly and was working without issue locally on my
machine. I've made no configuration changes to the machine except install
windows updates.
> Any ideas on how to get around this are much much appreciated..
> Thanks
Thanks for the response Bryant.
unfortuantely no, the machine was running 1.1 all along as far as I recall.
REading that article, where can I make thoe changes? the web.comfig file?

Thanks again for your reply

"Bryant Hankins" wrote:

> Have you recently updated your local machine from .NET 1.0 to 1.1? Maybe you
> are having this issue:
> http://www.glacialcomponents.com/Ar...tionExceptio n
> --
> Hope this helps,
> Bryant Hankins
> Numinet Systems Inc.
> http://www.numinet.com
>
> "Really stuck" <Really stuck@.discussions.microsoft.com> wrote in message
> news:1F535AEF-EA81-482B-B1AE-CFC7F7029B8F@.microsoft.com...
> > Hello,
> > I'm getting the following error now with my aplication, but only when I
> run it ocally on my machine:
> > System.Runtime.Serialization.SerializationExceptio n: Cannot find member
> name System.Data.SqlClient.SqlError.
> > If I push the same build to a production server it runs without issue.
> This began happening suddenly and was working without issue locally on my
> machine. I've made no configuration changes to the machine except install
> windows updates.
> > Any ideas on how to get around this are much much appreciated..
> > Thanks
>
Yes. This would be a web.config or machine.config change.

--
Hope this helps,
Bryant Hankins
Numinet Systems Inc.
http://www.numinet.com

"REally Stuck" <REally Stuck@.discussions.microsoft.com> wrote in message
news:AB3A6781-E3DE-4ED7-A2E5-C78280FEA50B@.microsoft.com...
> Thanks for the response Bryant.
> unfortuantely no, the machine was running 1.1 all along as far as I
recall.
> REading that article, where can I make thoe changes? the web.comfig file?
> Thanks again for your reply
> "Bryant Hankins" wrote:
> > Have you recently updated your local machine from .NET 1.0 to 1.1? Maybe
you
> > are having this issue:
http://www.glacialcomponents.com/Ar...tionExceptio n
> > --
> > Hope this helps,
> > Bryant Hankins
> > Numinet Systems Inc.
> > http://www.numinet.com
> > "Really stuck" <Really stuck@.discussions.microsoft.com> wrote in message
> > news:1F535AEF-EA81-482B-B1AE-CFC7F7029B8F@.microsoft.com...
> > > Hello,
> > > I'm getting the following error now with my aplication, but only when
I
> > run it ocally on my machine:
> > > System.Runtime.Serialization.SerializationExceptio n: Cannot find
member
> > name System.Data.SqlClient.SqlError.
> > > If I push the same build to a production server it runs without issue.
> > This began happening suddenly and was working without issue locally on
my
> > machine. I've made no configuration changes to the machine except
install
> > windows updates.
> > > > Any ideas on how to get around this are much much appreciated..
> > > Thanks
>

System.Runtime.Serialization.SerializationException:

Hello,
I'm getting the following error now with my aplication, but only when I run
it ocally on my machine:
System.Runtime.Serialization.SerializationException: Cannot find member name
System.Data.SqlClient.SqlError.
If I push the same build to a production server it runs without issue. This
began happening suddenly and was working without issue locally on my machine
. I've made no configuration changes to the machine except install windows u
pdates.
Any ideas on how to get around this are much much appreciated..
ThanksHave you recently updated your local machine from .NET 1.0 to 1.1? Maybe you
are having this issue:
http://www.glacialcomponents.com/Ar...cepti
on
Hope this helps,
Bryant Hankins
Numinet Systems Inc.
http://www.numinet.com
"Really stuck" <Really stuck@.discussions.microsoft.com> wrote in message
news:1F535AEF-EA81-482B-B1AE-CFC7F7029B8F@.microsoft.com...
> Hello,
> I'm getting the following error now with my aplication, but only when I
run it ocally on my machine:
> System.Runtime.Serialization.SerializationException: Cannot find member
name System.Data.SqlClient.SqlError.
> If I push the same build to a production server it runs without issue.
This began happening suddenly and was working without issue locally on my
machine. I've made no configuration changes to the machine except install
windows updates.
> Any ideas on how to get around this are much much appreciated..
> Thanks
>
Thanks for the response Bryant.
unfortuantely no, the machine was running 1.1 all along as far as I recall.
REading that article, where can I make thoe changes? the web.comfig file?
Thanks again for your reply
"Bryant Hankins" wrote:

> Have you recently updated your local machine from .NET 1.0 to 1.1? Maybe y
ou
> are having this issue:
> http://www.glacialcomponents.com/Ar...cep
tion
> --
> Hope this helps,
> Bryant Hankins
> Numinet Systems Inc.
> http://www.numinet.com
>
> "Really stuck" <Really stuck@.discussions.microsoft.com> wrote in message
> news:1F535AEF-EA81-482B-B1AE-CFC7F7029B8F@.microsoft.com...
> run it ocally on my machine:
> name System.Data.SqlClient.SqlError.
> This began happening suddenly and was working without issue locally on my
> machine. I've made no configuration changes to the machine except install
> windows updates.
>
>
Yes. This would be a web.config or machine.config change.
Hope this helps,
Bryant Hankins
Numinet Systems Inc.
http://www.numinet.com
"REally Stuck" <REally Stuck@.discussions.microsoft.com> wrote in message
news:AB3A6781-E3DE-4ED7-A2E5-C78280FEA50B@.microsoft.com...
> Thanks for the response Bryant.
> unfortuantely no, the machine was running 1.1 all along as far as I
recall.
> REading that article, where can I make thoe changes? the web.comfig file?
> Thanks again for your reply
> "Bryant Hankins" wrote:
>
you
http://www.glacialcomponents.com/Ar...zationException[color=
darkred]
I
member
my
install

System.StackOverflowException

hi.

when i run the following program

MyGrid.EditItemIndex = 0
MyGrid.DataBind()

there is a statement

System.StackOverflowException

what's the problemHy,

A detailed description wud b beneficial..
Hi,

to what are you binding? It's a best practice to create a private sub where you do the datagrid binding. Setting the edititemindex can be done in the proper eventhandler and after that you can recall that sub where your databinding occurs. Also make sure in this case that you check for postbacks in your page_load.

Grz, Kris.
Where are you setting the datasource for the datagrid

System.Text.RegularExpressions.dll

I'm developing a custom namespace that needs to run a regular expression.
Here is a quick example of what I was doing
Imports System.Text.RegularExpressions
Namespace blah
public class foo
Public Function bar(ByVal strInput as string, strExpression) as boolean
dim rgx as new RegEx
rgx.pattern = strExpression

return rgx.test(strInput)
end function
end class
end namespace
Problem is It gives me an error trying to importSystem.Text.RegularExpressions and the VBC can't find theSystem.Text.RegularExpressions.dll and neither can I when I do a filesearch for it.
This concerns me because this namespace will be used on an asp.netapplication ... what if the host doesn't have that dll either? and whydon't I have that dll? am I missing something somewhere?
please help.
It's a name space. Not necessarily a physical file.
My bet would be that it is in System.dll.

are you sure you are using this code as it is ?
it doesnot seems to be complied !!!