|
Hi,
Every after 4-5 days, application is showing HTTP error 503 and after restart Application from IIS, then it is working, please suggest if anyone faced this issue.
Event Log as below:
Faulting application name: w3wp.exe, version: 10.0.14393.0, time stamp: 0x57899135
Faulting module name: mscorlib.ni.dll, version: 4.6.1586.0, time stamp: 0x575a1299
Exception code: 0xc00000fd
Fault offset: 0x0037198c
Faulting process id: 0x1138
Faulting application start time: 0x01d3de33a1b2c0e2
Faulting application path: C:\Windows\SysWoW64\inetsrv\w3wp.exe
Faulting module path: C:\Windows\assembly\NativeImages_v4.0.30319_32\mscorlib\40571abae9422cd2ca6fafbbde1c3cdc\mscorlib.ni.dll
Report Id: dc62cf7c-c780-400d-8912-a8597269ad96
Faulting package full name:
Faulting package-relative application ID:
|
|
|
|
|
Hmmm,
I'm not a C# guy but I do know that 0xc00000fd is not a memory leak... that's a stack overflow.
Best Wishes,
-David Delaune
|
|
|
|
|
As Randor says, Exception code 0xc00000fd is a stack overflow, not a memory leak - always Google exception codes if you don't know what they mean.
And there is only really one way to cause a stack overflow in a C# app: recursive code.
So start by looking through your code to find what might be recursing slowly - and I do mean slowly, if it's taking days then it's really slow - the stack is normally only around one megabyte, so it doesn't take much for a wildly recursing app to overflow it.
We can't do that for you, and the timescale involved makes the debugger less than practical so you are going to have to fall back on the old ways and add logging code to your app to find out where it enters a method, and doesn't exit before the method is called again. Hopefully, your app is written in a well structured way and that won't be too complicated.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks,
I am using Response.Redirect("~/Error.aspx");
So, Thread is aborted, this can be also cause to pressure in Stack?
Shall we use Response.Redirect("~/Error.aspx", false); ?
Thanks
|
|
|
|
|
We cannot tell.
We have no idea what your code is doing, because we can't see it!
You need to start logging this: at the moment you have no information, and are just guessing what is causing this.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hello,,
I need to find the first and second most repeated element in an array.If there are two most repeated numbers then it needs to print the maximum among them.can anyone suggest a solution for it.
|
|
|
|
|
Look at some of the answers below to your original question. You just need to adjust the code for the different counts that you want to collect.
|
|
|
|
|
What have you tried?
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
We can't just "give you a solution" even if we wanted to, because we have no idea how far you are into your course: the solution I'd use - a Linq Query - wouldn't work for you if Generics and Linq are still to be covered in your course.
And of course there is this: your tutor knows this site exists. He will be looking for students handing in other people's work as their own - it's called plagiarism - and can throw you off the course, or out of the school...
If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
this is the code which i tried.it is actually giving output for first frequent element but producing a false output for second frequent.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp14
{
class Program
{
static void Main(string[] args)
{
int i, j, count, maxcount = 0, number = 0, n = 10, part1 = 0, part2 = 0, number1 = 0;
int[] array = new int[10];
for(int k=0;k<10;k++)
{
array[k]= Convert.ToInt32(Console.ReadLine());
}
for (i = 0; i < n; i++)
{
count = 0;
for (j = 0; j < n; j++)
{
if (array[i] == array[j])
count++;
}
if (count > maxcount)
{
maxcount = count;
number = array[i];
}
else
if (count == maxcount)
{
if (array[i] > number)
number = array[i];
}
}
maxcount = 0;
for (i = 0; i < n; i++)
{
count = 0;
if(array[i]==number)
{
continue;
}
for (j = 0; j < n; j++)
{
if (array[i] == array[j])
count++;
}
if (count > maxcount)
{
maxcount = count;
number1 = array[i];
}
else
if (count == maxcount)
{
if (array[i] > number)
number1 = array[i];
}
}
part1 = number;
part2 = number1;
Console.WriteLine(part1);
Console.WriteLine(part2);
Console.ReadKey();
}
}
}
|
|
|
|
|
And now it's time for you to learn to use the debugger!
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.
Time for you to learn a new (and very, very useful) skill: debugging! Trust me, get used to this - you will be using this a lot, and it's well worth learning while you are dealing with nice, little, self contained problems like this one - trying to learn it on a million line of code behemoth is a lot worse!
Give it a try: You'll be surprised now much information you can get.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Assuming they are teaching using VS I'm astonished that debugging is not the second lesson taught - hello world being the first. Surely a basic knowledge of the IDE would be primary. Or maybe they expect the students to explore the IDE, just like we all did.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
And perhaps teaching that a clean compilation does not mean your code is right...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
If it compiles, ship it.
This space for rent
|
|
|
|
|
Mr Gates, Sir! I didn't know you had an account!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I learned all I know about release management there....
This space for rent
|
|
|
|
|
Mycroft Holmes wrote: Assuming they are teaching using VS I'm astonished that debugging is not the second lesson taught I'm not; followed several courses and there's usually no explanation of the IDE, or debugging techniques.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
In every class I ever took, basic debugging and debugging techniques were never covered. From what we're seeing in the forums and QA, I'd say that's still the case.
Thankfully, I already knew what I was doing when I walked into those classes.
|
|
|
|
|
Why learn that when you can use Code Project?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Debugging is for wimps. Just get it right the first time. I don't even build anything any more, just check it into source control and whack the publish button.
Regards,
Rob Philpott.
|
|
|
|
|
Dear All,
I add a dolder in solution explorer tree. And I add txt files into it.
How can I read it from there?
Thanks.
|
|
|
|
|
Depends on exactly what you did when you added the files: If you highlight the file and go to the Properties pane, you can set the "Build Action" to "Embedded Resource".
Then go to the project in the Solution Exploerer panel, and open the "Properties" branch.
Double click "Resources.resx".
Drag the text file from the solution folder to the resources page, and drop it.
You can now access the file from the Properties in your code:
string myText = Properties.Resources.MyTextFile; Where "MyTextFile.txt" was the original file name.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi,
I am trying to load a treeview with the list of directories present in the folder location asynchronously in a wizard type form.
The same code works as a separate standalone form.
The below is the code for the wizard form:
public partial class DLWizardPage3 : WizardFormLib.WizardPage
{
frmAlertForm alert;
public delegate void Add(TreeView tv, string value);
public DLWizardPage3(WizardFormBase parent)
: base(parent)
{
InitPage();
}
public DLWizardPage3(WizardFormBase parent, WizardPageType pageType)
: base(parent, pageType)
{
InitPage();
}
public void InitPage()
{
InitializeComponent();
base.Size = this.Size;
this.ParentWizardForm.DiscoverPagePanelSize(this.Size);
}
public override bool SaveData()
{
return true;
}
public override bool ValidateData()
{
return true;
}
private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
{
_logger.DebugFormat(LogMessageFormatString, "DLWizardPage3::backgroundWorker2_DoWork", "Started loading Directories for Metadata collected...");
BackgroundWorker worker = sender as BackgroundWorker;
Message = "Loading Data... Please Wait...";
worker.ReportProgress(0);
for (int i = 0; i < 10; i++)
{
Message = "Loading Data... Please Wait...";
tvDir.Invoke(new Add(AddRootNode), new object[] { tvDir, CommonData.ProjectPath });
worker.ReportProgress(i * 10);
}
}
private void backgroundWorker2_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
alert.Message = Message + e.ProgressPercentage.ToString() + "%";
alert.ProgressValue = e.ProgressPercentage;
}
private void backgroundWorker2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
bool isProcessCompleted = false;
if (e.Cancelled == true)
{
lblResult.Text = "";
isProcessCompleted = false;
}
else if (e.Error != null)
{
lblResult.Text = "Error: " + e.Error.Message;
isProcessCompleted = false;
_logger.ErrorFormat(LogExceptionNameMessageFormatString, "DLWizardPage3::backgroundWorker2_RunWorkerCompleted", e.Error.Message);
}
else
{
isProcessCompleted = true;
}
alert.Close();
if (isProcessCompleted)
{
_logger.DebugFormat(LogMessageFormatString, "DLWizardPage3::backgroundWorker2_RunWorkerCompleted", "Completed loading folders for Metadata collected...");
DialogResult diagRes = MessageBox.Show("Has the metadata been collected using Omni Tool?", "Data Load", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
if (diagRes == DialogResult.Yes)
{
CommonData.IsReportGeneratedThroughSOMA = true;
}
else
{
CommonData.IsReportGeneratedThroughSOMA = false;
}
}
}
private void DLWizardPage3_Load(object sender, EventArgs e)
{
if (backgroundWorker2.IsBusy != true)
{
alert = new frmAlertForm(false, ProgressBarStyle.Marquee, 30);
alert.Canceled += new EventHandler<EventArgs>(btnCancel_Click);
alert.Show();
backgroundWorker2.RunWorkerAsync();
}
}
private void ListDirectory(TreeView treeView, string path)
{
treeView.Nodes.Clear();
var rootDirectoryInfo = new DirectoryInfo(path);
CommonData.ProjectName = rootDirectoryInfo.Name;
treeView.Nodes.Add(CreateDirectoryNode(rootDirectoryInfo));
}
private static TreeNode CreateDirectoryNode(DirectoryInfo directoryInfo)
{
var directoryNode = new TreeNode(directoryInfo.Name);
directoryNode.Expand();
foreach (var directory in directoryInfo.GetDirectories())
{
if ((!Regex.IsMatch(directory.Name, @"^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$")) && (directory.Name.ToString().ToUpper() != "CSS") && (directory.Name.ToString().ToUpper() != "IMG") && (directory.Name.ToString().ToUpper() != "JS") && (directory.Name.ToString().ToUpper() != "DMV") && (directory.Name.ToString().ToUpper() != "MESSAGES"))
{
directoryNode.Nodes.Add(CreateDirectoryNode(directory));
}
}
return directoryNode;
}
public void AddRootNode(TreeView treeView, string path)
{
treeView.Nodes.Clear();
var rootDirectoryInfo = new DirectoryInfo(path);
treeView.Nodes.Add(CreateDirectoryNode(rootDirectoryInfo));
}
}
Below is the code AlertForm that shows a progress bar.
public partial class frmAlertForm : Form
{
public string Message { set { lblMessage.Text = value; } }
public int ProgressValue { set { progressBar1.Value = value; } }
public frmAlertForm(bool isCancelVisible)
{
InitializeComponent();
btnCancel.Visible = isCancelVisible;
}
public frmAlertForm(bool isCancelVisible, ProgressBarStyle style, int animationSpeed)
{
InitializeComponent();
btnCancel.Visible = isCancelVisible;
progressBar1.Style = style;
progressBar1.MarqueeAnimationSpeed = animationSpeed;
}
public event EventHandler<EventArgs> Canceled;
private void btnCancel_Click(object sender, EventArgs e)
{
EventHandler<EventArgs> ea = Canceled;
if (ea != null)
ea(this, e);
}
private void frmAlertForm_Load(object sender, EventArgs e)
{
}
}
I am using backgroundWorker to make the asynchronous loading of treeview.
When ever, I add the tree node, I am getting exception "
Cannot access a disposed object. Object name: 'TreeView' " What is it that I am doing wrong in the code.
Kindly help.
Regards,
Rani Iyer
|
|
|
|
|
ranimiyer10 wrote: tvDir.Invoke(new Add(AddRootNode), new object[] { tvDir, CommonData.ProjectPath }); You are accessing the TreeView from another thread.
I'd pass the form as an argument (like you did with the BGW), and invoke on that
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello,, I wrote a code for finding the non repeated character from a character array.But the indexof function is not working.It is showing as argument null exception.Can anyone suggest an alternate way to do this?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp7
{
class Program
{
public static void Main(string[] args)
{
char[] str = new char[5] { 'a', 'b', 'b', 'a', 'c' };
char result = '0';
for (int index = 0; index < str.Length; index++)
{
if (str.LastIndexOf(str[index]) == str.IndexOf(str[index]))
{
result = str[index];
break;
}
}
Console.Write(result);
Console.ReadKey();
}
}
}
|
|
|
|
|
Just count the number of occurances ("group and count"; dictionary; etc.)
Any char with a count of 1 is "unique".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|