Exception Unhandled: System.OutOfMemoryException: 'Out of memory.' - c#

Basically, it has been 3 days since I'm trying to resolve this issue. I'm coding a sort of Mail Client in C# - everything was working pretty much good, while I started getting this unhandled exception... I would like to post a code section, but I do not know exactly what it causing this problem. A good fact is that the project is pushed over Github. Over internet it is said that maybe some variables used on some loops may cause the problem; I've already tried to edit some parts, but unluckily nothing worked...
Latest edit:
Added a Bunifu.Framework.UI.BunifuFlatButton over a UserControl. On click event, this happens:
MessageBox.Show(settingsControl.FLAG.ToString());
- I was testing if this would print me the int FLAG variable taken from another UserControl called settingsControl.
Every suggestion is appreciated. Thanks!

Related

Windows Universal: Getting Value from ComboBox

I have a problem which drives me crazy: Up until Christmas my C# Rpi app worked without problems. Coming back from vacation it seems that my ComboBoxes do not work anymore.
I have a method for "SelectionChanged" where I try to get the selected value using
cbox_SleepState.SelectedIndex. (cbox_SleepState is obviously my ComboBox).
Looking at it in the debugger I get this warning:
SelectedIndex - An internal error has occurred while evaluating method Windows.UI.Xaml.Controls.Primitives.Selector.get_SelectedIndex().
I understand why the codes dos not work but I do not get what I need to do to fix this -
especially as the code worked before.
Any help is highly appreciated.
Roger

Program only works correctly in debug mode

Here is my previous question, if you want some further information regarding my current problem:
WinForm: Inherited Panel wont Autosize
If you don't want to read through it, I'll give you some general information:
I'm not working directly via the programme, I'm just editing a specific DLL, that is used by this programme
That means, that I don't have any access to the source code of this specific programme
That also means that I have to fix this problem via some changes in the DLL, that is - as I mentioned before - used by this programme.
What I found out so far:
It works without any problems, if I attach the programme to the DLL's source code in VS2015.
But it has some glitches if I build the code and then copy the DLL into the programme's folder - that's also my actual problem: it somehow shrinks the tableLayoutpanel to half its actual size and I get some weird glitches in the other half of its actual, in normal start somehow not used, size.
What I tried out:
I changed the size manually, not via "Dock = Fill" or "Autosize = true" and it worked. But that's, as you all may know, not the best solution and we only want to use it, if there is absolutely no other way around it. No one likes to hard-code.
I tried to inherit its Parent's Size via:
this.tablelayoutPanel.Size = this.Size;
and
this.tableLayoutPanel.Size = new Size(this.Height, this.Size);
So do you guys have any ideas?
Okay, I did not figured out why the debuger worked and the release/debug build not. But I just forced a redraw on the tableLayoutPanelMainwith with Application.DoEvents(). I never tried this out before, because Invalidate() + Update() or Refresh() did not work - I was like: okay, that wont be that easy, so just forget about that.
But after some trial & error and a lot of time...well, I was working for two weeks on it...I tried the simpliest thing out and YEAHY, it worked!
Anyways, thank you for your help, guys. I appreciate that.

Dynamically add command after IExternalApplication.OnStartup to the Revit Ribbon?

Is it possible to dynamically add commands after IExternalApplication.OnStartup has executed to Revit's Ribbon Panel?
I came across this post on TheBuildingCoder...
http://thebuildingcoder.typepad.com/blog/2010/03/adding-noncommands-to-the-revit-ribbon.html
.. and the first "P.S." on there seems to imply that it's not possible, but that was back in 2010. I'm wondering if anything has changed?
I haven't been able to figure it out myself. Trying to just execute the AddPushButton() code that I've written results in:
An unhandled exception of type System.Runtime.InteropServices.SEHException' occurred in RevitAPIUI.dll
It works fine when placed inside the IExternalApplication.OnStartup block, which seems to imply that I either need to execute the code to add to the Ribbon panel in some sort of Transaction pattern or similar... or, it's just not possible :(
Any help would be appreciated, thank you!
I've been able to do this in the past (at least with Pulldown buttons, adding more of them later on).
During the OnStartup, I stored a static reference to the main PulldownButton, and then later on, call PulldownButton.AddPushButton() to add the additional buttons.
(I know- short on details, but I hope it helps!).

Completely remove "error list" from visual studio

I want to completely remove "error list" from visual studio 2008, not disable it i want it gone. It annoys me to no end popping up endlessly, i guess i must be "doing it wrong" but w/e i just want to use VS without being alerted every other keystroke about some warning.
I've tried editing many different fields in the options (tools -> options) it has only slightly decreased the frequency of the error list popping up. I have also deselected errors, warnings, and Messages. and it pops up with nothing to display. unpinning it doesn't help either.
also upgrading to VS 2010 is not an option at this point.
Im looking for a solution something like the following: remove a dll or config file responsible for this
Also I still want the inline validation (the little squiggly marks, etc), but
the error list window annoys me.
I think this is probably exactly what you're wanting:
http://blogs.msdn.com/b/zainnab/archive/2010/05/16/hide-or-show-error-list-when-the-build-finishes-with-errors-vstiptool0022.aspx
You can change this behavior by going to Tools -> Options -> Projects
and Solutions -> General and deselecting the "Always show Error List
if build finishes with errors".
I'm guessing this will work with ASP.Net as well, since that's building on the fly.
I am using Visual Studio 2017, and I also have to cope with the useless, impossible-to-disable, annoyingly-in-your-face, and outright disturbing "Error List" window.
So, here is what I did:
Undock the "Error List" window to make it free-floating.
Resize it to the smallest size possible.
Move it out to some remote area of the screen where it is not so annoying.
And voila, problem solved ! (*1)
*1 Well, problem mostly solved. It will be completely solved when I abandon this dinosaur of an IDE.
My 'Error List' was constantly displaying also (VS2012). I also hate it.
I turned it off years ago, but today it just started appearing.
It was being caused a unreadable packages.config file. For some reason that reports it's fail state through the yukky 'Error List'.
Fixing the packages.config file stopped the 'Error List' from appearing.
for VS2017, select the "Build only" value from the drop down list in Error tab. Refer to the image below:
Hope this helps!
On Error tab, you have Errors / Warnings / Info buttons. Click on Errors button (de-press).
hope it helps.
I suggest turning off inline validation.
Yes, I know that you still want it. But, seriously, how important is it? It's trying to validate code that is half-written. How valuable can that be?
First of all, as-you're-typing code validation is distracting. It makes it harder to focus on the problem you are trying to solve. For example, writing a function with a non-void return will display the "not all code paths return a value" error continually until you get to the end of the function. In the meantime, the editor is telling you that there is a problem. I am sure that people learn to ignore these things over time (I have never kept the feature on for more than a few minutes after a new VS installation, so I don't know), but if you are actively ignoring something, then what good is it?
Second of all, any good that the validation would be capable of is unnecessary, because those errors will be brought to your attention at compile-time anyway. Having an uninitialized variable pointed out to you while you are thinking through the algorithm does not improve the quality of the code at all verses having it pointed out when you try to run the program. The variable is still going to be initialized either way. And there is an extremely high likelyhood that you are going to fix the problem before trying to run the code anyway.
So I just don't see the point of it. I suggest turning it off, and then your problem goes away.
UPDATE
As pointed out by #Charlie Kilian, there is a flaw in VS in which .aspx files are not validated at all, unless the "Show live semantic errors" option is enabled for C#, rather than validating those pages at compile-time as would be expected.
Therefore, editing aspx files will require turning this option back on for validation.
I guess I'll be going back-and-forth with it from now on. I hope they fix this in future versions of VS.
I still think that doing a semantic analysis and error-reporting on code that is actively being edited is a fool's errand. (Of course, I have also been known to write entire programs in notepad, just to see if I could get it to compile and run correctly the very first time without the crutch of Intellisense. It feels pretty awesome when it works.)
Selected answer is incorrect because unchecking "Always show Error List if build finishes with errors" does nothing to stop the dreaded Error List window from popping up on other errors, even if you change it to show only Build errors.
11 years later in Visual Studio 2022 it is still impossible to disable Error List window.
The only correct answer to the question "Completely remove error list from visual studio" is to uninstall Visual Studio itself which, thankfully, also removes Error List window.
Either that, or we should all get used to it, because Developer Gods from Microsoft want everyone to work in absolutely the same way as they do. Every workflow that differs from their own is wrong, and every thought that doesn't align with their grand vision is blasphemy.
It is One Microsoft Way or the highway.

Application freezes when changing windows keyboard input language

When I run my application, do some work on it and click the language button on the Windows taskbar and change the input language, my C# application freezes displaying an hourglass cursor. Does anyone have any idea on what may be going wrong? I have absolutely no clue where to start...
First of all, your problem is hard to follow, since we don't know what is going on in your application. Neither we know which exactly code in your application freezes.
For others, the problem in your application is not clear. So having this quite weakly defined problem, it's hardly possible that someone can help.
You can do the following in order to resolve the issue:
Try to build a minimal test case, which reproduces the problem. Usually you'll need to start with a copy of your source code, and remove features until the bug is not reproducible any more.
After this, you will most likely see yourself, where the problem is.
If not, you can post the example and the changes which make the bug happen. Please kindly try to remove as much as possible from the example, leaving only essential part.
This way you will most likely have your problem solved.

Categories