Is there a better option for including images in my program than "resources" or am I just doing something wrong? - vb.net

So I'm a bit of a self-taught programmer. I learned VB6 in college and used it sporadically for several years. A few years ago I got back into it and switched over to vb.net. I'm currently using Visual Studio Community 2019. I've been learning as I go and have been getting by pretty well. Lately, though, I'm having an issue that I can't seem to figure out. Here's the problem:
I have a program I'm writing that is fairly graphic heavy. It's a game so there are a lot of image assets that I've added to the resources (1752 items currently and most are images). Everything has been fine, but lately I'm having a lot of issues adding additional images. I'll get compile failures that won't tell me what the errors are. I'll get "Out Of Memory" exceptions that say certain images can't be initiated. I've had to revert to backups several times because I just couldn't undo whatever had gone wrong even if I removed the images I added.
I still have several new images I want to add as part of an update. I've tried simply dragging and dropping the images to add them and I've tried adding them through the "add resource" button but the results are the same. I've tried adding the images in smaller batches but I still run into issues. I tried adding different images to see if the ones I was using were somehow the problem but that didn't help either.
This is one of those things that I accept I may just not know best practices on. Is there a better way to add images to my program other than putting them into the resources? Is there something I can do with my resources to prevent these issues? Any advice would be really appreciated!
Thanks.

I switched to Visual Studio 2022 and that helped with the issue to some degree. One big change was that the compile failures without any reported errors went away. That was a huge help because it pointed me in the direction of the underlying problem.
I was able to track down a couple of the 1500 new images that were causing the issue. I'm still not positive what was wrong with them (they appeared to be no different than any of the others) but I rerendered them and now everything is great! Thanks to everyone for the advice!

Related

Convert XNA + VB.Net game into MonoGame

I'm writing a strategy game in XNA and VB.NET. This technology combination looked like quite a good choice, right until I decided I would like to switch to MonoGame (but keep my game logic in VB.Net intact).
The problem is that MonoGame currently does not support VB.Net. I did some research and it seems I have basically two options:
Rewrite my code to C#
Write a small C# wrapper around MonoGame and turn my Game Logic code into a library
Needless to say, both of these options suck. Am I missing another option here? I don't mind giving considerable effort into making this thing work in MonoGame, but rewriting just isn't an option.
My findings so far:
While browsing the web, I stumbled across a MonoGame template for VB.Net. While it looked to be just what i needed, it crashed upon loading even after running a plain new project. I then proceeded to google for the error, but got nowhere near running the thing.
To explain my technology choice (because someone will ask):
Why XNA? I used it before, I'm familiar with it and even though it's outdated, it suits my needs perfectly and should still work for a couple years.
Why VB.Net? I have huge experience with it and I prefer it's syntax over C#. This is important to me since I'm writing a rather large-scale strategy game and keeping the code clean and understandable is essential.
Why not C#? Experience. I worked with C# for a little over a year, but it ain't natural yet. VB is.
I found a solution. A failry painless way to make this work was the MonoGame template I mentioned earlier. There are several small issues with that approach, but nothing too problematic.
Issue #1: Error when starting MonoGame Project.
After running a new VB MonoGame template project, a nasty error is thrown upon startup (System.TypeLoadException in mscorlib.dll). This happened since the template reference an incorrect version of MonoGame library (I'm using windows and there was an android library linked to the project).
Solution: Remove the MonoGame reference from your new project, and use browse to add back the correct version.
Issue #2: Content project missing in MonoGame.
MonoGame does not have a Content Project, but rather a folder called 'Content', which honestly behaves just like the project. Just add all your content from the XNA content project to this folder and it works. Amazing!
What it failed to do however is loading sounds and fonts from uncompiled content files (e.g. myFont.spriteFont). For MonoGame content, sound and font files had to be replaced with their compiled version from the XNA project.
Plus there is one small nuisance - each content file must be marked as 'Copy always' or 'Copy if newer' (default 'Copy Never'). I didn't really find a way to change this for all of them at once, but it doesn't take that much time.
Issue #3: XNA project was automatically resolving imports.
XNA project had one 'Syntactic Sugar' advantage. I never realized it until i switched to mono, but I never saw a single line called 'imports' in my XNA project. I made massive use of this, having many small classes which consisted only of few lines and used a 'list' of 'Vector2', etc. After porting to MonoGame I had to go through several hundred compile errors due to missing imports.
I'm still wondering whether this was caused by the XNA project or some other config in Visual Studio itself, but I must say I liked it. If you know something about this, please do share.
Conclusion:
Looking back, the process of porting to MonoGame took me about a month to figure out - but when I finally had all the pieces, the entire process took about 4 hours for 100+ source file + 100+ content file project. I'd say the guys at MonoGame did a tremendous job, and so did the gentleman who modified the template to work with VB.Net.

Image Buffering in Visual Studio (Any Version)

Hey there I was wondering if anyone had a solution to the problem I am having when programming in Microsoft Visual Studio with VB.NET.
Basically I want to know how to load images on a form faster. I am creating a 1 form design of a program and whenever I use too many images, it takes >20 seconds to load and becomes really slow. I was looking to see if anyone has managed to find a work around around this however I can't seem to find one.
Any help would be greatly appreciated :)

dojox.mobile.view slow

when tapping just on the "Back button" it last 1-1.5secs (iOS 4-5 iPhones) seconds before it goes back. Is there anything I can do ?
I had a closer look and removed ALL bottlenecks in my code. Even when the view is empty, its unacceptable slow.
I also had a look in the dojo sources, its seems that dojo.setStyle and dojo.setClass is called a few hundreds times when moving in or out a view. I debugged this with a self baken mozilla browser and its true, dojo view changes involve a complete repaint/reflow of the entire dom tree, thats more than bad.
We spent now 3.5 months fulltime on a commercial project and the customer is not happy with the performance at all and I'am facing a little desaster.
I also saw that dojo prefers DOM manipulation instead of innerHTML and wants even stick to that. Are there any workarounds or utils within the DOJO framework to support innerHTML approaches ?
Looks, I need to rewrite the view class.
Any suggestions are welcome, guenter
Are you running an optimized build or from source? Any chance this is a file load/latency problem?
I'd recommend you take your comments to dojo-interest where the community and dojox.mobile maintainers are more likely to see it. You may also want to post some examples to demonstrate the performance problems you're seeing.

XRCed learning resources?

I've seen many people saying XRCed very strong "if you have learned how to use it". Unfortuntately, there're few documents about it, and many of the links on SF.net home page is 404 now.
The best I can found is XRCed Tutorial, however it is too primitive - so, does anyone have some idea for where can I find better documents about it?
Just a suggestion; have you tried wxFormBuilder? XRCed seems a little outdated (hasn't been updated for a while), and it does the same thing as wxFB. I've been using wxFB for a while in several projects and it's a life saver.
Alongside the already mentioned wxFormBuilder, I'm going to throw in wxGlade, as well. While I prefer wxFormbuilders GUI, I found it to be lacking in the available widgets. So I moved to wxGlade based on the amount of widgets it offers.
Both can create XRC files (and some other codes like C++ and python) and I think both are actively maintained. I think XRCed hasn't been updated since 2007.
For ease of use, I would go with wxFormBuilder. If you want to use various different widgets, for the moment, go with wxGlade. I don't know if wxFormbuilder is planning on incorporating ToggleButtons and the like in their future releases. It isn't in the one that I am using...

Visual Studio 2008 designers screw up on large VB projects

We have 3 developers all using the same version (VS 2008 SP1) and we all use large VB projects (windows forms). From time to time, the IDE will have all sorts of issues such as locking up, crashing, and even not being able to drag a form object around or it will just instantly disappear.
On the largest of our projects (which is actually 5 projects in one solution file), a couple people here can only rebuild the project for testing 2 - 3 times before they have to close the studio and reopen it.
Has anyone else experienced this? Does this happen with large C# projects?
Yes, I experience this all the time! It has gotten better in 2008, if you can believe it.
I usually find that the reason has to do with an exception in my own code. The UI might bring in a custom control that does not behave well in design mode, causing the problem.
Sometimes, I will bring up a second execution of VS2008 and attach the debugger to the first execution of VS. Then, I can debug my own code as it is being run in the designer of the first instance. Often, an exception is thrown and I can fix my code to play better in the designer.
In other circumstances, I have no idea why it happens.
I have heard of people having this issue, however, I have never had an issue at all myself.
I have heard that a number of people trace the issues back to the use of ReSharper as the primary cause.
The most common problem I've had that causes the designer to crash is when I create a form where the only constructors require parameters.
To alleviate that, when I need the form only to be instantiated with parameters, I create a private parameterless constructor that the designer can use but which the form's consumers won't see.
I have personally experienced all sorts of designer wickedness with VS2008 sp1. I uninstalled the service pack to return stability to my dev environment. This is an unfortunate answer, but give it a try.
Only thing I've had close to this is the design view crashing and bringing up an error, formerly causing me to have to recreate the form and copy and paste the code across until I learnt how to fix it.
My problem was occurring because of me using ctrl+f a lot though. If you are using big files, this might be what's happening.