|
Hello All
I am updating a database on a server using a web service, the web service, my program is reading a large text files in my local machine and every 1000 line send them as an array of type string to the web service method that accepts string array , it runs will for a while but after 2 or min it gives me an exception "The request failed with HTTP status 400: Bad Request"
can any one help on this plz!
|
|
|
|
|
Does the request exceed the default limit of 4 MB?
---
single minded; short sighted; long gone;
|
|
|
|
|
I don't know exactly what you mean, but if you mean the size of the string array, I had used a string array that contains 1000 line and another one that uses 100 line from the txt file, and both give me the same result.
|
|
|
|
|
Get ProcessExplorer or a similar tool and monitor the asp.net process that is running your webservice, I think that IIS is restarting the process due to large amount of RAM usage. I got the same error uploading large files by calling a webservice, chunk by chunk. A solution is to use free the memory from time to time by calling the Garbage Collector.
http://stefanprodan.wordpress.com
|
|
|
|
|
How can i call the Garbage Collector on the server machine, i am running my application on a client machine all i can do is to call the web service on the server, plz help
|
|
|
|
|
Hello,
As you know helpprovider component helps you to integrate help 1.0 files in the application. These are chm or html files. Is there a way to integrate help 2.0 files (hxs, msdn style help) into my windows forms application? So that it opens at specified place in document explorer like it happens in VS 2005. Thanks
|
|
|
|
|
Hi I have created a a service project in C#
It was installed perfectly. When the service started, It is giving error as "Could not perform requested operation for the Service "ServiceName" in local machine.
The Module is like this:
using System;
using System.IO;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Collections.Specialized;
namespace QuoteServer
{
///
/// Summary description for Class1.
///
public class QuoteServer
{
private TcpListener listener;
private int port;
private string filename;
private StringCollection quotes;
private Random random;
private Thread listenerThread;
public QuoteServer(): this ("quotes.txt")
{
}
public QuoteServer(string filename): this (filename,7890)
{
}
public QuoteServer(string filename, int port)
{
this.filename=filename;
this.port=port;
}
protected void ReadQuotes()
{
quotes=new StringCollection();
Stream stream=File.OpenRead(filename);
StreamReader streamReader=new StreamReader(stream);
string quote;
while((quote=streamReader.ReadLine())!=null)
{
quotes.Add(quote);
}
streamReader.Close();stream.Close();
random=new Random();
}
protected string GetRandomQuoteOfTheDay()
{
int index=random.Next(0,quotes.Count);
return quotes[index];
}
public void Start()
{
/*ReadQuotes();
listenerThread=new Thread(new ThreadStart(this.Listener));
listenerThread.Start();*/
}
protected void Listener()
{
try
{
//ReadQuotes();
IPAddress ipAddress=Dns.Resolve("localhost").AddressList[0];
listener=new TcpListener(ipAddress,port);
listener.Start();
while(true)
{
Socket socket=listener.AcceptSocket();//if the processor will take more time,
//we can create a new thread for each client will perform
string message=GetRandomQuoteOfTheDay();
UnicodeEncoding encoder=new UnicodeEncoding();
byte[] buffer=encoder.GetBytes(message);
socket.Send(buffer,buffer.Length,0);
socket.Close();
}
}
catch(SocketException e)
{
Console.WriteLine(e.Message);
}
}
public void Stop()
{
//listener.Stop();
}
public void Suspend()
{
listenerThread.Suspend();
}
public void Resume()
{
listenerThread.Resume();
}
public void RefreshQuotes()
{
ReadQuotes();
}
}
}
////////////////////////
The Service Module is like this:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;
//using QuoteServer;
namespace QuoteService
{
public class QuoteService : System.ServiceProcess.ServiceBase
{
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
private QuoteServer.QuoteServer quoteServer;
private Thread t;
public QuoteService()
{
// This call is required by the Windows.Forms Component Designer.
InitializeComponent();
// TODO: Add any initialization after the InitComponent call
}
// The main entry point for the process
static void Main()
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
// More than one user Service may run within the same process. To add
// another service to this process, change the following line to
// create a second service object. For example,
//
// ServicesToRun = new System.ServiceProcess.ServiceBase[] {new Service1(), new MySecondUserService()};
//
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new QuoteService() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
//
// QuoteService
//
this.CanPauseAndContinue = true;
this.ServiceName = "QuoteService";
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
///
/// Set things in motion so your service can do its work.
///
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
/*t=new Thread(new ThreadStart(this.StartQuoteServer));
t.Start(); */
quoteServer=new QuoteServer.QuoteServer(@"C:\Documents and Settings\sumantar\Desktop\C#\C# Experiment\QuoteServer\quotes.txt",4567);
quoteServer.Start();
}
/*protected void StartQuoteServer()
{
quoteServer=new QuoteServer.QuoteServer(@"C:\Documents and Settings\sumantar\Desktop\C#\C# Experiment\QuoteServer\quotes.txt",4567);
quoteServer.Start();
}
*/
///
/// Stop this service.
///
protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary to stop your service.
quoteServer.Stop();
}
protected override void OnPause()
{
// TODO: Add QuoteService.OnPause implementation
//base.OnPause ();
//quoteServer.Suspend();
}
protected override void OnContinue()
{
// TODO: Add QuoteService.OnContinue implementation
//base.OnContinue ();
//quoteServer.Resume();
}
protected override void OnShutdown()
{
// TODO: Add QuoteService.OnShutdown implementation
//base.OnShutdown ();
//OnStop();
}
public const int commandRefresh=128;
protected override void OnCustomCommand(int command)
{
// TODO: Add QuoteService.OnCustomCommand implementation
//base.OnCustomCommand (command);
switch(command)
{
case commandRefresh:
//quoteServer.RefreshQuotes();
break;
default:
break;
}
}
}
}
//////
The problem lies:
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
quoteServer=new QuoteServer.QuoteServer(@"C:\Documents and Settings\sumantar\Desktop\C#\C# Experiment\QuoteServer\quotes.txt",4567);
quoteServer.Start();
}
If I remove the 2 line:
The service is installed and starting and stoping.
If I put this 2 line,m Service is installed but not starting. It give the following error:
"Could not perform requested operation for the Service "ServiceName" in local machine.
Please help me. Thanks in advance.
|
|
|
|
|
My first guess would be whoever you set up the windows server to run as, that is the username and password does not have rights to do what you are trying to do.
Hope that helps.
Ben
|
|
|
|
|
Thanks Ben!!!
In effect when I try to start the service I
receive an error that says something like that: "The DataBaseService
service on the local computer has been started and then stopped. Some
services stop automatically if there aren't operation to execute, for
example ........ "
|
|
|
|
|
Most of the time when I get that error, it means my username and password are not valid. That is not a good message to get. You want to get sevice started successfully.
Ben
|
|
|
|
|
But I changed the Account Properties to: LocalService
Still I am getting the same error
|
|
|
|
|
I don't think you want it to run as localservice. I was set up a new user and password for that server with the correct rights on the computer to do what it needs to do.
Ben
|
|
|
|
|
Thanks Ben.
The Code works fine if I remove the 2 lines from the Start Method.
QuoteServer.QuoteServer quoteServer;
quoteServer=new QuoteServer.QuoteServer(@"C:\Documents and Settings\sumantar\Desktop\C#\C# Experiment\QuoteServer\quotes.txt",4567);
quoteServer.Start();
Even the start method is not having any thing
public void Start()
{
}
Without the above 2 lines the code works fine. When I put these lines, It gives error
|
|
|
|
|
If you take those two lines out of the start method then your window service doesn't do anything. I don't know what a quoteserver is, but I am guessing the user that the windows sevice is running as needs to have some rights. I would guess by default what ever user you are using doesn't have rights to your personal desktop. I would suggest creating a folder called C:\temp Put your quotes.txt file in c:\temp and change your QuoteServer call to point to c:\temp. Or set the user and password as you since you have access to your own desktop.
Hope that helps.
Ben
|
|
|
|
|
hey is ur problem solved .. if not plz span a new thread onstart and do what ever u have to on that thread .. like
protected override void OnStart(string[] args)
{
Thread runThread= new Thread(new ThreadStart(Run));
runThread.Start();
}
private void Run()
{
//do all ur loginc here
}
ghumdai firdai
|
|
|
|
|
Hello
I'm developing a UserControl like you can see in TaskPane of "My computer".
For this i used GroupBox with Label control and some effects to expanding and collapsing it.
Then when i used this usercontrol in one windows project, I couldn't add controls to it! I want to add controls like button from toolbox to it in design time by drag-n-drop.
Regards
|
|
|
|
|
I solved My problem :
Here is some links contains samples about this subject :
http://www.codeproject.com/cs/miscctrl/xpgroupbox.asp[^]
ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.KB.v10.en/enu_kbvcsharpnetkb/vcsharpnetkb/813450.htm
And my code :
<br />
using System.ComponentModel.Design;<br />
<br />
namespace TaskPanel<br />
{<br />
[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]<br />
public partial class UserControl1 : UserControl<br />
{<br />
public UserControl1()<br />
{<br />
InitializeComponent();<br />
this.ControlAdded += new ControlEventHandler(UserControl1_ControlAdded);<br />
}<br />
<br />
private void UserControl1_ControlAdded(object sender, ControlEventArgs e)<br />
{<br />
e.Control.BringToFront();<br />
}<br />
<br />
}<br />
}<br />
|
|
|
|
|
i created a remider project. But now all I want is when its 1 oclock, the program display a pop up message "Testing!!!" even if the project is close.
|
|
|
|
|
If the program is not running it can't check time and display pop-up
|
|
|
|
|
You can either use SchTasks ) to schedule the start-up of your application at givent time or write you own service to do that.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thanks I have something with it. Please don't be mad at me when i have a program again with this
You are what you are
|
|
|
|
|
Add a timer, handle its Tick event, compare DateTime.Now.Hours to 1 or 13 and show a MessageBox.
If it your timer continues to fire Tick events when the MessageBox is still displaying (while you are sleeping for example ) then you should create a custom Message Box from Form class and store a reference to it in you application like:
Reminder : Form
{
}
MyApplication : Form
{
Reminder reminderForm = null;
myTime_Tick(...)
{
if(reminderForm != null && !reminderForm.Disposing)
{
reminderForm.Dispose();
reminderForm = null;
}
else
{
reminderForm = new ReminderForm();
reminderForm.Show();
}
}
}
or you should be able to just hide and show the reminder form instead of disposing and recreating it.
|
|
|
|
|
How to get a list of all shared netbios resources of remote computer in the Local Area Network, knowing it's IP? Write please the sample of such code. or show me links to some pages, where i can see an answer on this question. links to some resources, containing code of lan-scanners are also welcome.
p.s. it's C#
|
|
|
|
|
Can anyone please help me with this.
I am building a C# console application that has to read a xml file and download the csv file's to a certain location. All the information is written in the xml file.
So far the reading en displaying the content of the xml file is going OK.
But... I do not know the code to download the csv file from the url in the xml file.
Down here i've attached the code i've written for so far.
Thank u.
= = ==
using System;
using System.IO;
using System.Xml;
using System.Net;
namespace Book
{ ///
/// Summary description for Class1.
///
class Class1
{[STAThread]
static void Main(string[] args)
{ XmlTextReader reader = null;
reader = new XmlTextReader("WTZI.xml");
WebClient client = new WebClient();
while (reader.Read())
{ if (reader.NodeType == XmlNodeType.Element)
{if(reader.LocalName.Equals("locatie"))
{Console.Write("{0}",reader.ReadString());}
if(reader.LocalName.Equals("bestemming"))
{Console.Write("{0}",reader.ReadString());}
}
}
}
}
}
====
Content of XML FILE
<bestanden
<bestand
locatie="">http://www.bouwcollege.nl/Exports/CIBG/GRIP_Doelgroepen.csvc:\temp\WTZI\Doelgroepen.csvhttp://www.bouwcollege.nl/Exports/CIBG/GRIP_Instellingen.csvc:\temp\WTZI\Instellingen.csvhttp://www.bouwcollege.nl/Exports/CIBG/GRIP_Toelatingen.csvc:\temp\WTZI\Toelatingen.csvhttp://www.bouwcollege.nl/Exports/CIBG/GRIP_Toelatingfuncties.csvc:\temp\WTZI\Toelatingfuncties.csvhttp://www.bouwcollege.nl/Exports/CIBG/GRIP_Zorgkantoren.csvc:\temp\WTZI\Zorgkantoren.csv
|
|
|
|
|
Take a look at the documentation of the WebRequest.Create method.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|