Showing posts with label message. Show all posts
Showing posts with label message. Show all posts

Saturday, March 31, 2012

system.enterpriseservices.dll error

I am running a web app on w2k3/IIS 6.0/ASP.net 2.0. This app runs fine on a different server. The error message I get is

Compiler Error Message:CS0006: Metadata file 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll' could not be found

I have seen solutions to remove the "<identity impersonate="true" />" setting from the web.config file. That has not been helpful. Another solution was to delete the system.enterpriseservices.dll from C:\Windows\assembly. I have deleted the file, copied a new .dll, and that did not work. I have reinstalled IIS and ASP.Net 2.0 as well. So far, no dice. Any other ideas are greatly welcomed!


AJ

Hello AJ,

This may be a dumb question, but is the assembly in the GAC on the deployment server? If it isn't, you should be able to add it by running "gacutil /if System.EnterpriseServices.dll" using the 2.0 version of gacutil.exe.

HTH,
Clay


Clay,

Thanks for the response. I just got the problem figured out today.

The file permissions were screwed up. Users did not have read and execute permissions to this folder:
C:\WINDOWS\WinSxS\x86_System.EnterpriseServices_b03f5f7f11d50a3a_2.0.0.0_x-ww_7d5f3790

After I fixed that I got a similar error message as before but it mentioned a system.enterpriseServices.Wrapper.dll and found out that this file was missing
C:\WINDOWS\WinSxS\x86_System.EnterpriseServices_b03f5f7f11d50a3a_2.0.0.0_x-ww_7d5f3790\System.EnterpriseServices.Wrapper.dll

Now it is running like a champ!

AJ

System.IndexOutOfRangeException

I'm seeing the above error message appear on a web form. All the formcode-behind does is grab data from a SQL Server db (2005 Beta) andwrite it out in specfied controls.
The line that throws up the error is the following:
<code>
Line 150: txtCoDeath1a.Text = dtr("COD1a")
</code>
'Dtr' is simply a datareader that has been initialised previously. Iknow I should be checking for nulls in the db, but that isn't theproblem in this instant as the record I'm grabbing does have data forthe field 'COD1a'. It's of type nvarchar, length 150.
I've googled this error and have not found anything that seems directly relevant.
I'm using VB.
Any help much appreciated.

try putting this before your code

if dtr.Read then
dtr("COD1a")
end if


Sorry Chris, I should've posted more of my code.
I already have those lines in the code.
Any other ideas?

Try this

if not System.DBNull(dtr("COD1a")) then

txtCoDeath1a.Text = dtr("COD1a")

end if

Could you post more of your code? Are results coming back from the database? Is there a field called COD1a?


Thanks for the help guys, but I've located the source of theproblem. Very simple; I'd misnamed 'Cod1a'. Its actually 'CodIa'. Spotthe difference? Neither did I for a while!
<Sheepish> Sorry and thanks again.

Wednesday, March 28, 2012

System.IO.FileNotFoundException help

Not sure where this error is coming from. I have my asp.net app set to email
me error messages, but this error message does not indicate where it occurs.
There is no page called get_aspx_ver.aspx and I don't know where it's
getting that. Any ideas?
System.IO.FileNotFoundException:
c:\inetpub\wwwroot\framescale\get_aspx_v
er.aspx
at System.Web.UI.TemplateParser.GetParserCacheItem()
at System.Web.UI.TemplateControlParser.CompileAndGetParserCacheItem(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.TemplateControlParser.GetCompiledInstance(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.PageParser.GetCompiledPageInstanceInternal(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)"When you try to open an ASP.NET Web Application project, the ASP.NET
process accesses a nonexistent file that is named Get_aspx_ver.aspx to
retrieve the ASP.NET version information. If the defaultRedirect attribute
is not set to an HTML file or to an ASP file, the request for the
Get_aspx_ver.aspx file returns the HTTP 404 error and the ASP.NET version
information. If the defaultRedirect attribute is set to an HTML file or to
an ASP file, the request for the Get_aspx_ver.aspx file does not return the
ASP.NET version information. Therefore, you receive the error that is
mentioned in the "Symptoms" section of this article. "
http://support.microsoft.com/defaul...kb;en-us;825792
Also:
http://bluebones.net/news/default.a...ory&story_id=50
"msnews.microsoft.com" <maximus@.portvista.com> wrote in message
news:%23B6kthPSEHA.3944@.TK2MSFTNGP11.phx.gbl...
> Not sure where this error is coming from. I have my asp.net app set to
> email
> me error messages, but this error message does not indicate where it
> occurs.
> There is no page called get_aspx_ver.aspx and I don't know where it's
> getting that. Any ideas?
> System.IO.FileNotFoundException:
> c:\inetpub\wwwroot\framescale\get_aspx_v
er.aspx
> at System.Web.UI.TemplateParser.GetParserCacheItem()
> at System.Web.UI.TemplateControlParser.CompileAndGetParserCacheItem(String
> virtualPath, String inputFile, HttpContext context)
> at System.Web.UI.TemplateControlParser.GetCompiledInstance(String
> virtualPath, String inputFile, HttpContext context)
> at System.Web.UI.PageParser.GetCompiledPageInstanceInternal(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)
>
Nice going Microsoft. I'd not being wearing that MVP badge so proudly! lol!
"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> wrote in message
news:e1ie4XQSEHA.568@.TK2MSFTNGP12.phx.gbl...
> "When you try to open an ASP.NET Web Application project, the ASP.NET
> process accesses a nonexistent file that is named Get_aspx_ver.aspx to
> retrieve the ASP.NET version information. If the defaultRedirect attribute
> is not set to an HTML file or to an ASP file, the request for the
> Get_aspx_ver.aspx file returns the HTTP 404 error and the ASP.NET version
> information. If the defaultRedirect attribute is set to an HTML file or to
> an ASP file, the request for the Get_aspx_ver.aspx file does not return
the
> ASP.NET version information. Therefore, you receive the error that is
> mentioned in the "Symptoms" section of this article. "

System.IO.FileNotFoundException help

Not sure where this error is coming from. I have my asp.net app set to email
me error messages, but this error message does not indicate where it occurs.
There is no page called get_aspx_ver.aspx and I don't know where it's
getting that. Any ideas?

System.IO.FileNotFoundException:
c:\inetpub\wwwroot\framescale\get_aspx_ver.aspx
at System.Web.UI.TemplateParser.GetParserCacheItem()
at System.Web.UI.TemplateControlParser.CompileAndGetP arserCacheItem(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.TemplateControlParser.GetCompiledIns tance(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.PageParser.GetCompiledPageInstanceIn ternal(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.PageHandlerFactory.GetHandler(HttpCo ntext context, String
requestType, String url, String path)
at System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig)"When you try to open an ASP.NET Web Application project, the ASP.NET
process accesses a nonexistent file that is named Get_aspx_ver.aspx to
retrieve the ASP.NET version information. If the defaultRedirect attribute
is not set to an HTML file or to an ASP file, the request for the
Get_aspx_ver.aspx file returns the HTTP 404 error and the ASP.NET version
information. If the defaultRedirect attribute is set to an HTML file or to
an ASP file, the request for the Get_aspx_ver.aspx file does not return the
ASP.NET version information. Therefore, you receive the error that is
mentioned in the "Symptoms" section of this article. "

http://support.microsoft.com/defaul...kb;en-us;825792

Also:

http://bluebones.net/news/default.a...ory&story_id=50

"msnews.microsoft.com" <maximus@.portvista.com> wrote in message
news:%23B6kthPSEHA.3944@.TK2MSFTNGP11.phx.gbl...
> Not sure where this error is coming from. I have my asp.net app set to
> email
> me error messages, but this error message does not indicate where it
> occurs.
> There is no page called get_aspx_ver.aspx and I don't know where it's
> getting that. Any ideas?
> System.IO.FileNotFoundException:
> c:\inetpub\wwwroot\framescale\get_aspx_ver.aspx
> at System.Web.UI.TemplateParser.GetParserCacheItem()
> at System.Web.UI.TemplateControlParser.CompileAndGetP arserCacheItem(String
> virtualPath, String inputFile, HttpContext context)
> at System.Web.UI.TemplateControlParser.GetCompiledIns tance(String
> virtualPath, String inputFile, HttpContext context)
> at System.Web.UI.PageParser.GetCompiledPageInstanceIn ternal(String
> virtualPath, String inputFile, HttpContext context)
> at System.Web.UI.PageHandlerFactory.GetHandler(HttpCo ntext context, String
> requestType, String url, String path)
> at System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
> requestType, String path, String pathTranslated, Boolean useAppConfig)
Nice going Microsoft. I'd not being wearing that MVP badge so proudly! lol!

"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> wrote in message
news:e1ie4XQSEHA.568@.TK2MSFTNGP12.phx.gbl...
> "When you try to open an ASP.NET Web Application project, the ASP.NET
> process accesses a nonexistent file that is named Get_aspx_ver.aspx to
> retrieve the ASP.NET version information. If the defaultRedirect attribute
> is not set to an HTML file or to an ASP file, the request for the
> Get_aspx_ver.aspx file returns the HTTP 404 error and the ASP.NET version
> information. If the defaultRedirect attribute is set to an HTML file or to
> an ASP file, the request for the Get_aspx_ver.aspx file does not return
the
> ASP.NET version information. Therefore, you receive the error that is
> mentioned in the "Symptoms" section of this article. "

Monday, March 26, 2012

System.Net HttpWebRequest - post a form

(Type your message here)
From: senthil t
There is a third party website that we use=2E Whenever someone=
unsubscribes from our website, some one has to go to that third=
party website, enter the unsubscribed user info and submit the=
form=2E We are doing this manually=2E What I would like is, whenever=
any user unsubscribes from our website, auto post the third=
party website form with all the user information from my =2Enet=
code=2E This is the code I have right now=2E But this is not=
working=2E
HttpWebRequest webRequest =3D (HttpWebRequest) WebRequest=2ECreate=
(URL);
webRequest=2EKeepAlive =3D false;
webRequest=2ETimeout =3D 100000;
webRequest=2EMethod =3D "POST";
webRequest=2EContentType =3D "application/x-www-form-urlencoded";
byte[] requestBytes =3D (new=
System=2EText=2EASCIIEncoding())=2EGetBy
tes (PostData);
webRequest=2EContentLength =3D requestBytes=2ELength;
Stream requestStream =3D webRequest=2EGetRequestStream();
requestStream=2EWrite (requestBytes, 0, requestBytes=2ELength);
requestStream=2EClose();
webResponse =3D (HttpWebResponse) webRequest=2EGetResponse();
sr =3D new StreamReader (webResponse=2EGetResponseStream(),=
System=2EText=2EEncoding=2EASCII);
response =3D sr=2EReadToEnd ();
With =2Easpx page, it was not doing anything until I added the=
viewstate info to the postdata=2E But is throwing an error at this=
line=2E
webResponse =3D (HttpWebResponse) webRequest=2EGetResponse();
Internal Server Error=2ESystem=2ENet=2EHttpWebResponse at=
System=2ENet=2EHttpWebRequest=2ECheckFin
alStatus() at=
System=2ENet=2EHttpWebRequest=2EEndGetRe
sponse(IAsyncResult=
asyncResult) at System=2ENet=2EHttpWebRequest=2EGetRespo
nse()
Can any one tell me what is wrong with what I am doing?
Posted by a user from =2ENET 247 (http://www=2Edotnet247=2Ecom/)
<Id>0ZTNUiUrPECOfo+INVokdg=3D=3D</Id>Hi senthil:
What I've done in the past is use a tool like Fiddler [1] to compare
what my program is POSTing to the server versus what happens when I
use a browser.
http://www.fiddlertool.com/fiddler/
Scott
http://www.OdeToCode.com/blogs/scott/
On Sun, 15 May 2005 05:03:55 -0700, senthil t via .NET 247
<anonymous@.dotnet247.com> wrote:

>(Type your message here)
>--
>From: senthil t
>There is a third party website that we use. Whenever someone unsubscribes from our
website, some one has to go to that third party website, enter the unsubscribed user
info and submit the form. We are doing this manually. What I would like is, wheneve
r a
ny user unsubscribes from our website, auto post the third party website form with all the
user information from my .net code. This is the code I have right now. But this is not work
ing.
> HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create (URL);
> webRequest.KeepAlive = false;
> webRequest.Timeout = 100000;
> webRequest.Method = "POST";
> webRequest.ContentType = "application/x-www-form-urlencoded";
> byte[] requestBytes = (new System.Text.ASCIIEncoding()).GetBytes (PostDa
ta);
> webRequest.ContentLength = requestBytes.Length;
> Stream requestStream = webRequest.GetRequestStream();
> requestStream.Write (requestBytes, 0, requestBytes.Length);
> requestStream.Close();
> webResponse = (HttpWebResponse) webRequest.GetResponse();
> sr = new StreamReader (webResponse.GetResponseStream(), System.Text.Enco
ding.ASCII);
> response = sr.ReadToEnd ();
>With .aspx page, it was not doing anything until I added the viewstate info
to the postdata. But is throwing an error at this line.
>webResponse = (HttpWebResponse) webRequest.GetResponse();
>Internal Server Error.System.Net.HttpWebResponse at System.Net.HttpWebReque
st.CheckFinalStatus() at System.Net.HttpWebRequest.EndGetResponse(IAsyncResu
lt asyncResult) at System.Net.HttpWebRequest.GetResponse()
>Can any one tell me what is wrong with what I am doing?
>--
>Posted by a user from .NET 247 (http://www.dotnet247.com/)
><Id>0ZTNUiUrPECOfo+INVokdg==</Id>

System.Net.Mail

I have a class that contains(taken from faq section):

using System.Net.Mail;

public class MailHelper
{
/// <summary>
/// Sends an mail message
/// </summary>
/// <param name="from">Sender address</param>
/// <param name="to">Recepient address</param>
/// <param name="bcc">Bcc recepient</param>
/// <param name="cc">Cc recepient</param>
/// <param name="subject">Subject of mail message</param>
/// <param name="body">Body of mail message</param>

public static void SendMailMessage(string from, string to, string bcc, string cc, string subject, string body)
{
// Instantiate a new instance of MailMessage
MailMessage mMailMessage = new MailMessage();

// Set the sender address of the mail message
mMailMessage.From = new MailAddress(from);
// Set the recepient address of the mail message
//mMailMessage.To.Add(to);
//mMailMessage.To = new MailAddressCollection().Add(new MailAddress(to));

ERROR HERE: "Property or indexer 'System.Net.Mail.MailMessage.To' cannot be assisgned to--it is read only

mMailMessage.To = new MailAddressCollection().Add(to);

// Check if the bcc value is null or an empty string
if ((bcc != null) && (bcc != string.Empty))
{
// Set the Bcc address of the mail message
mMailMessage.Bcc.Add(new MailAddress(bcc));
}

// Check if the cc value is null or an empty value
if ((cc != null) && (cc != string.Empty))
{
// Set the CC address of the mail message
mMailMessage.CC.Add(new MailAddress(cc));
}

// Set the subject of the mail message
mMailMessage.Subject = subject;
// Set the body of the mail message
mMailMessage.Body = body;

// Secify the format of the body as HTML
mMailMessage.IsBodyHtml = true;
// Set the priority of the mail message to normal
mMailMessage.Priority = MailPriority.Normal;

// Instantiate a new instance of SmtpClient
SmtpClient mSmtpClient = new SmtpClient();
// Send the mail message
mSmtpClient.Send(mMailMessage);
}

I call the method from the Form Submit button Like this:

private void GenEmails()
{

//Email Code Executed On Click Event
string from = EmailTextBox.Text;
string to = ContactIdentifier.EmailAddress;
string bcc = "null";
string cc = "null";
string subject = subjectTextBox.Text;
string body = DescriptionTextBox.Text;

MailHelper.SendMailMessage(from, to, bcc, cc, subject, body);
}

All I'm trying to do is pass the textbox.text values into the method as parameters. What am I doing wrong here?

why don't you put just:

mMailMessage.To.Add(to);
//mMailMessage.To = new MailAddressCollection().Add(new MailAddress(to));

//ERROR HERE: "Property or indexer 'System.Net.Mail.MailMessage.To' cannot be assisgned to--it is read only

//mMailMessage.To = new MailAddressCollection().Add(to);

works for me...


// Set the recepient address of the mail message
//mMailMessage.To.Add(to);
//mMailMessage.To = new MailAddressCollection().Add(new MailAddress(to));

mMailMessage.To.Add(new MailAddress(to);

http://msdn2.microsoft.com/en-us/library/system.net.mail.mailmessage.to.aspx


Dim messageAsNew MailMessage("sender@.emailaddress.com", Session("destionationemailaddress"),"Order Alert","my e-mail body")

message.cc="sendanother@.emailaddresstothisaddress.com"

Dim emailClientAsNew SmtpClient("xxxxxxserver")

emailClient.Send(message)

when I add cc to the message object I get message.cc readonly error.

could you please help me with my problem.

thanks


use System.Web.Mail.MailMessage instead of System.Net.Mail.MailMessage.

System.Net.Mail class smtpdemo needs users address in message body from txt.emailAddress

I have this code behind from the new asp.net 2.0 System.Net.Mail class smtpdemo i am working with. It sends an HTML email to myself the from address and to the email address in txt.emailAddress as a CC. I am trying to get the txt.email address somewhere in the message body that it sends out. this code does not show the imputed contents of txt.emailaddress anywhere in the email so i canot reply to the sender. It declaires me as the sender and sends the person filing out the form an email. I need to declar the contents of txt.emailadress as a variable and call it in the message body. Ive tryed dozens of different ways but they all have errors. i hope someone can look at this code and show me how to get the users email address sent with the message.
/code/
Imports System.Net.Mail

PartialClass report_aspx

Inherits System.Web.UI.Page

ProtectedSub sendEmail_Click(ByVal senderAsObject,ByVal e _

As System.EventArgs)Handles sendEmail.Click

Dim sBodyAsString

Dim fileReaderBodyAsString

Dim fileReaderFormatAsString

Dim WebDirectoryAsString = Server.MapPath(".") &"\"

Dim fileNameAsString = WebDirectory

Dim htmlEmailFormatAsString = WebDirectory &"MailFormat.htm"

SelectCase Subject.Text

Case"Broken Link"

fileName = fileName &"BrokenLink.txt"

Case"Missing Picture"

fileName = fileName &"MissingPicture.txt"

Case"Typographical Error"

fileName = fileName &"TypoError.txt"

CaseElse

fileName = fileName &"other.txt"

EndSelect

fileReaderBody =My.Computer.FileSystem.ReadAllText(fileName)

fileReaderFormat =My.Computer.FileSystem.ReadAllText(htmlEmailFormat)

sBody = fileReaderFormat.Replace("BODYGOESHERE", _

messageBody.Text)

sBody = sBody.Replace("CONTENTGOESHERE", fileReaderBody)

sBody = sBody.Replace("SUBJECTGOESHERE", Subject.Text)

Dim toAddressAs MailAddress =New _

MailAddress(me@dotnet.itags.org.myemailaddress,"Webmaster")

Dim ccAddressAs MailAddress =New _

MailAddress(emailAddress.Text, emailName.Text)

Dim SenderAddressAs MailAddress =New _

MailAddress(emailAddress.Text)

Dim fromAddressAs MailAddress =New _

MailAddress(me@dotnet.itags.org.myemailaddress)

Dim eMailAs MailMessage =New _

MailMessage(fromAddress, fromAddress)

eMail.CC.Add(fromAddress)

eMail.Subject = Subject.Text

Dim htmlTypeAs System.Net.Mime.ContentType = _

New System.Net.Mime.ContentType("text/html")

Dim txtTypeAs System.Net.Mime.ContentType = _

New System.Net.Mime.ContentType("text/plain")

eMail.AlternateViews.Add( _

AlternateView.CreateAlternateViewFromString(sBody, htmlType))

eMail.AlternateViews.Add( _

AlternateView.CreateAlternateViewFromString(fileReaderBody & vbCrLf & messageBody.Text, htmlType))

Dim attchmentAs Attachment =New _

Attachment(WebDirectory &"goldbar.gif")

eMail.Attachments.Add(attchment)

Dim clientAs SmtpClient =New SmtpClient("myemailserver")

client.Send(eMail)

lblMessageSent.Text ="MESSAGE SENT"

emailAddress.Text =""

emailName.Text =""

messageBody.Text =""

EndSub

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load

EndSub

EndClass
/end code/

I fixed my form by modifying the mailformat.htm page that I will place below and adding:

/codebehind file/
Body = sBody.Replace("NAMEGOESHERE", emailName.Text)

sBody = sBody.Replace("EMAILFROMGOESHERE", emailAddress.Text)
/end codebehind file/
/mailformat.html/

<html><body><h1>SUBJECTGOESHERE</h1><imgsrc="goldbar.gif"/><br/>BODYGOESHERE

<br/>

<imgsrc="goldbar.gif"/><br/>

NAMEGOESHERE<br/>

EMAILFROMGOESHERE<br/>

<br/>

<blockquote>CONTENTGOESHERE</blockquote></body></html>

system.net.mail network host cache?

I need to change the name of the mail server for my .NET application. I changed it in web.config and on the .aspx page that sends the message. However, I still get an error message saying that the remote name could not be resolved, and the error message has the name of theold mail server. I have tried rebooting the server, but still get the same error.

Does .NET save configuration settings somewhere other than web.config? Is something getting cached? Other ideas?

Are you running VS debugger or testing on IIS server?

You can delete all files in cache.

Do you use only one config file?

If you have BLL and DAL, sometimes you have also config files here.


Visit this?site.
http://www.systemwebmail.com/

As Johan said, delete your temporary files, and build your web site again

Thanks


Thanks for the responses.

JohanNL, this site is on an IIS server. There is only one web.config file for the site. I did not implement BLL/DAL.

JohanNL and e_screw - this is probably a dumb question - when you say to delete cache/temp files, do you mean the ones in c:\windows\temp? Or what is the correct location?


You need to clear the ASP.NET temporary files

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

Thanks

system.net.mail question

Hi

I am using system.net.mail to generate an E-mail from my form. When I recieve the message the header shows

MIME Version:1.0MIME Type:text/plain; charset=us-ascii

I am trying to determine if the MIME is getting added from the source server that is sending our email or the server where we retrieve our email from. Or can this be controled by system.net.mail? Any help is appreciated.

Robby

I don't know - but I use this place as a reference
http://systemnetmail.com/

Thursday, March 22, 2012

System.NullReferenceException: Object reference not set to an instance of an object.

Why do I get above error message while executing this code:

Public Sub DropDown_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Dim list As DropDownList = CType(sender, DropDownList)
Dim cell = CType(list.Parent, TableCell)
Dim item = CType(cell.Parent, DataGridItem)
Dim index = item.ItemIndex

Dim ds As DataSet
ds = DataGrid1.DataSource

Dim row As DataRow
row = ds.Tables(0).Select("ID = '" + item.Cells(0).Text + "'")(0)
'<-- ERROR
End SubSet a break point on the line

row = ds.Tables(0).Select("ID = '" + item.Cells(0).Text + "'")(0)

and see what is null there.

Could be:
no tables in ds;
no Cells(o) in item;
no item;
select doesn't return anything
...

Debug it.

Eliyahu

"John Smith" <john.smith@.microsoft.com> wrote in message
news:%Zahg.3487$oj5.1152205@.news.siol.net...
> Why do I get above error message while executing this code:
> Public Sub DropDown_SelectedIndexChanged(ByVal sender As System.Object,
> ByVal e As System.EventArgs)
> Dim list As DropDownList = CType(sender, DropDownList)
> Dim cell = CType(list.Parent, TableCell)
> Dim item = CType(cell.Parent, DataGridItem)
> Dim index = item.ItemIndex
> Dim ds As DataSet
> ds = DataGrid1.DataSource
> Dim row As DataRow
> row = ds.Tables(0).Select("ID = '" + item.Cells(0).Text + "'")(0)
> '<-- ERROR
> End Sub
Thank you.

"ds" was null. It seems I need to add DataSource into Session object
somehow. Beginner mistake. It seems DataGrid1.DataSource is not persistance?
> "ds" was null. It seems I need to add DataSource into Session object
> somehow. Beginner mistake. It seems DataGrid1.DataSource is not
> persistance?

I've declared ds as global Shared variable and it works fine so far.
Just note, that global Shared variables are shared between user sessions. It
means that if there will be multiple users using the app in the same time,
they will affect each other.

Eliyahu

"John Smith" <john.smith@.microsoft.com> wrote in message
news:tWbhg.3493$oj5.1152346@.news.siol.net...
>> "ds" was null. It seems I need to add DataSource into Session object
>> somehow. Beginner mistake. It seems DataGrid1.DataSource is not
>> persistance?
> I've declared ds as global Shared variable and it works fine so far.
> Just note, that global Shared variables are shared between user sessions.
> It
> means that if there will be multiple users using the app in the same time,
> they will affect each other.

So, should I declare it as "static" or as simple global variable (without
"shared")?
What is your data source?

"John Smith" <john.smith@.microsoft.com> wrote in message
news:Dpchg.3498$oj5.1152406@.news.siol.net...
>> Just note, that global Shared variables are shared between user sessions.
>> It
>> means that if there will be multiple users using the app in the same
>> time, they will affect each other.
> So, should I declare it as "static" or as simple global variable (without
> "shared")?
> What is your data source?

XML
If you can't re-populate the datasource on every postback, you can store it
in a session variable.

Eliyahu

"John Smith" <john.smith@.microsoft.com> wrote in message
news:G7ehg.3500$oj5.1153527@.news.siol.net...
>> What is your data source?
> XML
> If you can't re-populate the datasource on every postback, you can store
> it
> in a session variable.

There is no other way but session object?
John Smith wrote:
>> If you can't re-populate the datasource on every postback, you can
>> store it
>> in a session variable.
> There is no other way but session object?
If you need it to be session-specific, the session object makes it easy.
Sure, you can create a global hashtable keyed by some property of the
users of your application, but
1. this hashtable could get rather large, and
2. if you are not careful, bugs are hard to avoid.

Just out of curiosity, what is your objection to the session object?
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
> Just out of curiosity, what is your objection to the session object?

I am beginner and I have never used it before. I'll try it now.
John Smith wrote:
>> Just out of curiosity, what is your objection to the session object?
> I am beginner and I have never used it before. I'll try it now.
Ah!
I typically use a pattern like this in my pages:

Private _CachedDS as dataset
Private Propery CachedDS() as dataset
Get
If _CachedDS Is Nothing Then
If Not Session("CachedDS") Is Nothing Then
_CachedDS = CType(Session("CachedDS"), dataset)
End If
End If
Return _CachedDS
End Get
Set(ByVal Value As dataset)
Session("CachedDS") = Value
_CachedDS = Value
End Set
End Property

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
BindDataGrid()
End If

End Sub

...
Sub BindDataGrid
Dim ds as dataset
if CachedDS Is Nothing then
FillDataSet()
End If
'bind the grid
Dim ds as dataset=CachedDS
With DataGrid1
.DataSource=ds
.DataMember = ...
.DataBind
End With

End Sub

Sub FillDataSet()
Try
CachedDS = DataLayer.RetrieveData(parms)
Catch ex
'handle error
End Try
End Sub

Public Sub DropDown_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Dim list As DropDownList = CType(sender, DropDownList)
Dim cell = CType(list.Parent, TableCell)
Dim item = CType(cell.Parent, DataGridItem)
Dim index = item.ItemIndex

Dim ds As DataSet
if not CachedDS is Nothing then
ds = CachedDS
Else
'throw an error? call FillDataset? up to you.
End If

Dim row As DataRow
row = ds.Tables(0).Select("ID = '" + item.Cells(0).Text +
"'")(0)
etc.

HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
John Smith wrote:
>> Just note, that global Shared variables are shared between user
>> sessions. It
>> means that if there will be multiple users using the app in the same
>> time, they will affect each other.
> So, should I declare it as "static" or as simple global variable
> (without "shared")?

You should probably store it in Session rather than declaring it "Global
Shared"

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

System.NullReferenceException: Object reference not set to an instance of an object.

I am getting the following error message when I am trying to calculate the value of textboxes. What am I doing wrong?

System.NullReferenceException: Object reference not set to an instance of an object.
line: finalVal = finalVal + Convert.ToInt64(strAI.Text)
Code--------

' Grab the textbox values of the interest cost table, loop through them adding up the values and displaying the totals

PrivateSub btnInterestCostTotal_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles btnInterestCostTotal.Click

'AddField(DS_Term.Text)

Dim C, NAsInteger

'Find the txtAnnualInterestTotal textbox

Dim AITAs TextBox =CType(myTable.FindControl("txtAnnualInterestTotal"), TextBox)

Dim finalValAs Int64 = 0

'Loop through the dynamic textboxes

For C = 0ToCInt(DS_Term.Text) - 1

N = N + 1

Dim strAIAs TextBox =CType(myTable.FindControl("txtAnnualInterest" & N), TextBox)

'Add all the dynamic textboxes up

finalVal = finalVal + Convert.ToInt64(strAI.Text)

Next

'Display the total value in the txtAnnualInterestTotal textbox

AIT.Text = Convert.ToString(finalVal)

EndSub
code------------

Are you adding the textboxes dynamicaly? If so, you have to readd them on every postback.

I believe I am. Here is the code I am adding to the Page Init. Am I corrected adding them?

Sub createDynamicFields()

' Create the table and the controls based on the Term(# of years)

Dim IAsInteger

Dim intCounterAs Int64

If DS_Term.Text <> ""Then

For I = 0ToCInt(DS_Term.Text) - 1

Dim lblFiscalYearAs LiteralControl =New LiteralControl

Dim txtTextBoxAs TextBox =New TextBox

Dim txtTextBox2As TextBox =New TextBox

Dim txtTextBox3As TextBox =New TextBox

Dim tRow2As TableRow =New TableRow

Dim tCell1As TableCell =New TableCell

Dim tCell2As TableCell =New TableCell

Dim tCell3As TableCell =New TableCell

Dim tCell4As TableCell =New TableCell

' Grab Fiscal Year from tbBeginngingFiscalYear and Incurment the date by the DS_BondTerm field

lblFiscalYear.ID = "lblFiscalYear" & I + 1

lblFiscalYear.Text = Convert.ToString(Convert.ToInt64(DS_BeginningFiscalYear.Text) + I)

'**********************************

'Set the column width and

txtTextBox.Columns = 15

txtTextBox2.Columns = 15

txtTextBox3.Columns = 15

'Assign the textboxes IDs

txtTextBox.ID = "txtInterest" & I + 1

txtTextBox2.ID = "txtOsPrincipal" & I + 1

txtTextBox3.ID = "txtAnnualInterest" & I + 1

'Assign pre-defined values

'txtTextBox.Text = CStr(I + 1)

'txtTextBox2.Text = CStr(I + 1)

'txtTextBox3.Text = CStr(I + 1)

'Assign the cells to a row

tRow2.Cells.Add(tCell1)

tRow2.Cells.Add(tCell2)

tRow2.Cells.Add(tCell3)

tRow2.Cells.Add(tCell4)

'Assign the row to the table

myTable.Rows.Add(tRow2)

'Create the new controls

tCell1.Controls.Add(lblFiscalYear)

tCell2.Controls.Add(txtTextBox)

tCell3.Controls.Add(txtTextBox2)

tCell4.Controls.Add(txtTextBox3)

'Add the table to the placeholder

plhBondTerms.Controls.Add(myTable)

myTable.CellPadding = 0

myTable.CellSpacing = 0

'intCounter = intCounter + 1

'ViewState("Count") = intCounter

Next I

' ************************************

EndIf

EndSub


you should call this method on every postback

System.NullReferenceException: Object reference not set to an instance of an object.

This is the error message I get:
System.NullReferenceException: Object reference not set to an instance of an object.
at MyStore.CustomerFunctions.getCustomerOrders(String CustomerID)
at MyStore.Customer_Orders.Page_Load(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()
And this is my code:

PublicSharedFunction getCustomerOrders(ByVal CustomerIDAsString)As OrderCollection

Dim strSQLAsString
Dim m_strConnectionStringAsString
Dim MyReaderAs SqlDataReader
Dim mySqlParaAs SqlParameter
Dim MyOrdersAsNew OrderCollection

m_strConnectionString = ConfigurationSettings.AppSettings("ConnectionString_checkout")

strSQL = "sp_WWWgetCustomerOrders"

mySqlPara =New SqlParameter("@dotnet.itags.org.CustomerID", CustomerID)

Try
MyReader = SqlHelper.ExecuteReader(m_strConnectionString, CommandType.StoredProcedure, strSQL, mySqlPara)
MyOrders.Fill(MyReader)

Catch exAs Exception
' Rethrow Exception for the moment
Throw ex

Finally
MyReader.Close()
MyReader =Nothing

EndTry

Return MyOrders

EndFunction


Code that calls the method:

DimaCustomerAs Customer
Dim MyOrdersAs OrderCollection
aCustomer =CType(HttpContext.Current.User, CustomPrincipal).Customer

MyOrders = CustomerFunctions.getCustomerOrders(aCustomer.CustomerID)

If MyOrders.Count > 0Then
Me.rptOpenRecentOrders.DataSource = MyOrders
Me.rptOpenRecentOrders.DataBind()
pnlNoOrdersToDisplay.Visible =False
Else
pnlNoOrdersToDisplay.Visible =True
EndIf

I only get the error occasionally at busy times on the internet, the Stored Proc is valid the connection string is valid because it works some times. The problem is not incorrect data being passed because if no data or incorrect data is past a different exception will be displayed because I have tested. I have no idea why this is happening, I have a feeling its to do with SQL Server because it only happens when it is at its busiest.
If the Stored Proc returns an empty reader there is no error, I have alreadyinitialized My returning object (the Orders Collection) so it shouldn't matter.
I know that the customer id is valid because I have an email sent to me if there is an error in the application via the globalApplication_Errormethod, it gets the customer id from the currently logged in person
Dim aCustomerAs Customer =CType(HttpContext.Current.User, CustomPrincipal).Customer
strCustID = aCustomer.CustomerID
This is displayed correctly when emailed. As I say this only happens at busy times and I am pulling my hair out to identify whats happening, can any one help?
Cheers
Scott


elbandit--
Regarding this...

elbandit wrote:

...As I say this only happens at busy times and I am pulling my hair out to identify whats happening, can any one help?


...I am wondering-- exactly what line is causing the error?
(The line can be discovered by doing a step-through of the code.)
I am going to guess that it is this line...
Do While MyReader.Read = True
...that causes the error.
If so, then you may be able to check for Nothing before the operation, like this...
If (MyReader Is Nothing) Then
'Reader cannot be used, probably due to a database connection issue.
'Maybe retry 1x automatically and if no connection then show message to user and ask the user to retry.
Else
Do While MyReader.Read = True
'Continue.
End If
...which may or may not work based on your use case.
HTH.
Thank you.
--Mark Kamoski
Sorry Mark I posted the wrong function, I have now editied. Please can you have another look,
Thanks
Scott
i can not see in your code
Dim con as New Sqlconenction(connection string her)

is it some where else or that what you miss!!??
elbandit--
Regarding this...

elbandit wrote:

Sorry Mark I posted the wrong function, I have now editied. Please can you have another look...


...I still think that the issue may be that the Reader is not getting instantiated properly when then database is too busy. As I mentioned above, you may need to check for null (Nothing) before using it.
If the database is busy, you may need to increase the timeout (a property on the connection string, seehttp://www.ConnectionStrings.com for details).
Alternately, if the database is really busy maybe your licensing has reached the maximum number of of connections and that's why the Reader is not instantiated properly.
Another idea would be to use a DataAdapter and a DataSet. Yours is a simple case and these objects might be a bit more stable given that the Reader stays open until it is closed and you really do not need an open connection to the database in this case.
The code looks something like this...
System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand(COMMAND_TEXT, myConnection);
System.Data.OleDb.OleDbDataAdapter myDataAdapter = new System.Data.OleDb.OleDbDataAdapter(myCommand);
DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet);
...or you can seehttp://www.WebLogicArts.com/DemoReadingData01.aspx for a full working sample with all the code.
HTH.
Thank you.
--Mark Kamoski

Thanks Mark, I think you are probably right, as it only errors in busy periods I have changed the code to:

MyReader = SqlHelper.ExecuteReader(m_strConnectionString, CommandType.StoredProcedure, strSQL, mySqlPara)

If MyReaderIsNothingThen
Email.sendEmail()
EndIf
MyOrders.Fill(MyReader)

This way it will still error but I will get an email if the problem is that the reader is null, then I will be able to test with populating a dataset then populating my custom collection from that. The reason I didn't do it like that to begin with is that I thought a reader populated a dataset, but I guess if that is true the reader will populate a dataset faster than could populate my custom collection and therefore no error.
I will check out the time out property as well and let you know how I got on, and post the code that works. Cheers.
Thanks for the replies
Scott
P.S.
Fadil, I use MS Data Access Application Block to handle all connections to the database and opening the database and closing it is all done within in the most effiecient manner take a look athttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/daab.asp for more info.

System.NullReferenceException: Object reference not set to an instance of an object.

Why do I get above error message while executing this code:
Public Sub DropDown_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Dim list As DropDownList = CType(sender, DropDownList)
Dim cell = CType(list.Parent, TableCell)
Dim item = CType(cell.Parent, DataGridItem)
Dim index = item.ItemIndex
Dim ds As DataSet
ds = DataGrid1.DataSource
Dim row As DataRow
row = ds.Tables(0).Select("ID = '" + item.Cells(0).Text + "'")(0)
'<-- ERROR
End SubSet a break point on the line
row = ds.Tables(0).Select("ID = '" + item.Cells(0).Text + "'")(0)
and see what is null there.
Could be:
no tables in ds;
no Cells(o) in item;
no item;
select doesn't return anything
...
Debug it.
Eliyahu
"John Smith" <john.smith@.microsoft.com> wrote in message
news:%Zahg.3487$oj5.1152205@.news.siol.net...
> Why do I get above error message while executing this code:
> Public Sub DropDown_SelectedIndexChanged(ByVal sender As System.Object,
> ByVal e As System.EventArgs)
> Dim list As DropDownList = CType(sender, DropDownList)
> Dim cell = CType(list.Parent, TableCell)
> Dim item = CType(cell.Parent, DataGridItem)
> Dim index = item.ItemIndex
> Dim ds As DataSet
> ds = DataGrid1.DataSource
> Dim row As DataRow
> row = ds.Tables(0).Select("ID = '" + item.Cells(0).Text + "'")(0)
> '<-- ERROR
> End Sub
>
Thank you.
"ds" was null. It seems I need to add DataSource into Session object
somehow. Beginner mistake. It seems DataGrid1.DataSource is not persistance?

> "ds" was null. It seems I need to add DataSource into Session object
> somehow. Beginner mistake. It seems DataGrid1.DataSource is not
> persistance?
I've declared ds as global Shared variable and it works fine so far.
Just note, that global Shared variables are shared between user sessions. It
means that if there will be multiple users using the app in the same time,
they will affect each other.
Eliyahu
"John Smith" <john.smith@.microsoft.com> wrote in message
news:tWbhg.3493$oj5.1152346@.news.siol.net...
>
> I've declared ds as global Shared variable and it works fine so far.
>

> Just note, that global Shared variables are shared between user sessions.
> It
> means that if there will be multiple users using the app in the same time,
> they will affect each other.
So, should I declare it as "static" or as simple global variable (without
"shared")?
What is your data source?
"John Smith" <john.smith@.microsoft.com> wrote in message
news:Dpchg.3498$oj5.1152406@.news.siol.net...
>
> So, should I declare it as "static" or as simple global variable (without
> "shared")?
>

> What is your data source?
XML
If you can't re-populate the datasource on every postback, you can store it
in a session variable.
Eliyahu
"John Smith" <john.smith@.microsoft.com> wrote in message
news:G7ehg.3500$oj5.1153527@.news.siol.net...
>
> XML
>

> If you can't re-populate the datasource on every postback, you can store
> it
> in a session variable.
There is no other way but session object?

System.OutofMemoryException - Session

Hi

I have an application running on a cluster that's constantly throwing an OutOfMemoryException with the following message
"Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is 'StateServer' or 'SQLServer'.

In this instance, session state mode is set to 'StateServer' and the only object being stored in the session is a dataset (which is serializable)..

Anyone have any ideas

Thanks!for starters, what does your dataset contain?
any funky stuff in the dataset or just basic types?

i'm puzzled that an outofmemoryexception would contain a serialization
string

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
"Fletch" <anonymous@.discussions.microsoft.com> wrote in message
news:0F2E1CFD-71B2-41BA-9874-1AD07F3BDB5A@.microsoft.com...
> Hi,
> I have an application running on a cluster that's constantly throwing an
OutOfMemoryException with the following message:
> "Unable to serialize the session state. Please note that non-serializable
objects or MarshalByRef objects are not permitted when session state mode is
'StateServer' or 'SQLServer'."
> In this instance, session state mode is set to 'StateServer' and the only
object being stored in the session is a dataset (which is serializable)..
> Anyone have any ideas?
> Thanks!
for starters, what does your dataset contain?
any funky stuff in the dataset or just basic types?

i'm puzzled that an outofmemoryexception would contain a serialization
string

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
"Fletch" <anonymous@.discussions.microsoft.com> wrote in message
news:0F2E1CFD-71B2-41BA-9874-1AD07F3BDB5A@.microsoft.com...
> Hi,
> I have an application running on a cluster that's constantly throwing an
OutOfMemoryException with the following message:
> "Unable to serialize the session state. Please note that non-serializable
objects or MarshalByRef objects are not permitted when session state mode is
'StateServer' or 'SQLServer'."
> In this instance, session state mode is set to 'StateServer' and the only
object being stored in the session is a dataset (which is serializable)..
> Anyone have any ideas?
> Thanks!

System.OutofMemoryException - Session

Hi

I have an application running on a cluster that's constantly throwing an OutOfMemoryException with the following message
"Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is 'StateServer' or 'SQLServer'.

In this instance, session state mode is set to 'StateServer' and the only object being stored in the session is a dataset (which is serializable)..

Anyone have any ideas

Thanks!for starters, what does your dataset contain?
any funky stuff in the dataset or just basic types?

i'm puzzled that an outofmemoryexception would contain a serialization
string

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
"Fletch" <anonymous@.discussions.microsoft.com> wrote in message
news:0F2E1CFD-71B2-41BA-9874-1AD07F3BDB5A@.microsoft.com...
> Hi,
> I have an application running on a cluster that's constantly throwing an
OutOfMemoryException with the following message:
> "Unable to serialize the session state. Please note that non-serializable
objects or MarshalByRef objects are not permitted when session state mode is
'StateServer' or 'SQLServer'."
> In this instance, session state mode is set to 'StateServer' and the only
object being stored in the session is a dataset (which is serializable)..
> Anyone have any ideas?
> Thanks!

System.OutofMemoryException - Session

Hi

I have an application running on a cluster that's constantly throwing an OutOfMemoryException with the following message
"Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is 'StateServer' or 'SQLServer'.

In this instance, session state mode is set to 'StateServer' and the only object being stored in the session is a dataset (which is serializable)..

Anyone have any ideas

Thanks!for starters, what does your dataset contain?
any funky stuff in the dataset or just basic types?

i'm puzzled that an outofmemoryexception would contain a serialization
string

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
"Fletch" <anonymous@.discussions.microsoft.com> wrote in message
news:0F2E1CFD-71B2-41BA-9874-1AD07F3BDB5A@.microsoft.com...
> Hi,
> I have an application running on a cluster that's constantly throwing an
OutOfMemoryException with the following message:
> "Unable to serialize the session state. Please note that non-serializable
objects or MarshalByRef objects are not permitted when session state mode is
'StateServer' or 'SQLServer'."
> In this instance, session state mode is set to 'StateServer' and the only
object being stored in the session is a dataset (which is serializable)..
> Anyone have any ideas?
> Thanks!

Tuesday, March 13, 2012

System.Runtime.InteropServices.COMException: Word could not fire t

You need to post the code you are using plus the full error message. I
received this type of error while trying to use query AD using
DirectoryServices and the authentication/impersonation settings in my
web.config were set to a system account that didn't have rights.
"Microsoft NEws" wrote:

> i am getting this error when creating a new document using asp.net
> your thoughts
>
>i solved it
i just added ASPNET user to Microsoft Word Document DCOM
properties/security using dcomcfg.exe
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com