Fixing a Common WinForms Bug (CS0103) in 10 Minutes or Less

2024 ж. 16 Сәу.
4 280 Рет қаралды

Have you ever had an issue when working on a Windows Form where the form designer wouldn't even load? You get this blue, yellow, and white error message saying error CS0103. That error is a rather common one to experience when you first start out. Thankfully, it is also a very easy one to fix.
Full Training Courses: IAmTimCorey.com
Mailing List: signup.iamtimcorey.com/

Пікірлер
  • Absolutely! This is a common error many people face when starting Win Forms projects, specially without a strong foundation in the basics. Thanks Master

    @andergarcia1115@andergarcia1115Ай бұрын
    • You are welcome.

      @IAmTimCorey@IAmTimCoreyАй бұрын
  • I had that problem so many times when I was new; accidentally creating an event, hitting CTRL+Z, and seeing your form bug out, and not understanding partials was tough.

    @webluke@weblukeАй бұрын
    • Thanks for sharing!

      @IAmTimCorey@IAmTimCoreyАй бұрын
  • Thanks Tim. I know on how to solve this the next time i face this problem.

    @rameshvegi94@rameshvegi94Ай бұрын
    • Great!

      @IAmTimCorey@IAmTimCoreyАй бұрын
  • I first started my career as a developer working on a WinForms app that had been in production, still being used after 10 years even though being neglected for most of it. After struggling to fix everything over several years we took the path of migrating it and all of its different projects from .NET Framework 2.0/3.5 to .NET Framework 4.8 then later .NET 7 and the solution from Visual Studio 2008 to 2022 (redeveloping it not an option apparently), the improvements in the designer were underwhelming, especially this exact problem.

    @mynameisshadywhat@mynameisshadywhat23 күн бұрын
    • Yeah, WinForms hasn't progressed a lot in terms of the designer or tooling. The speed of the underlying code is incredibly different, but it does feel like the tooling has not been a big focus.

      @IAmTimCorey@IAmTimCorey23 күн бұрын
  • Creating a form to inherit from to use as a base font/color template as well as some commonly called base methods could make a good short video. How do you like the chevrons instead of +/- for expand/collapse regions? I hate the change and changed the color of the "Outlining Margin Vertical Rule" to cyan so the chevrons didn't blend in as much, and changed the color of collapsed text to stand out as well.

    @AvgDan@AvgDan28 күн бұрын
    • Form inheritance can be really helpful. I had a client (when I was consulting) that we ended up creating multiple base forms they could inherit from in order to bring in some default behaviors. I'm not sure I would use inheritance for the base font/colors, though. I would probably create a new item template that had those things set to different defaults instead. That keeps things simpler.

      @IAmTimCorey@IAmTimCorey27 күн бұрын
  • sir I have a question, what is it in your course that I should go with initially. im planning to subscribe monthly. im new to C# but I've been a PHP dev for quite some time. thanks

    @kenjohnsiosan9707@kenjohnsiosan9707Ай бұрын
    • The place to start is definitely the C# Mastercourse: www.iamtimcorey.com/courses/csharp-mastercourse/ It is designed to take you from knowing nothing to being able to fill a junior or even mid-level developer role, depending on how much you practice along the way.

      @IAmTimCorey@IAmTimCoreyАй бұрын
  • I learned about this is the hard way a few years back 😂😂 i think at the time i ran into a bug that deleted some exta code i had too.

    @Gbtx6@Gbtx6Ай бұрын
    • It can be a frustrating one.

      @IAmTimCorey@IAmTimCoreyАй бұрын
  • Alternatively, you could just click the hyperlink in an error message which will bring you right to the line with error (no need to search this one manually).

    @rusektor@rusektorАй бұрын
    • True, but I wanted to show where it was instead of a code window magically opening to the right place.

      @IAmTimCorey@IAmTimCoreyАй бұрын
  • you think VS could detect the function being deleted and maybe comment out the event assignment in the designer.

    @tetsballer1835@tetsballer1835Ай бұрын
    • That would be nice, although there are negative implications if you do that. Deleting code is a whole lot trickier than creating code.

      @IAmTimCorey@IAmTimCoreyАй бұрын
  • Why does anyone use winforms at all anymore? Haven't they been deprecated?

    @scottstrand7865@scottstrand7865Ай бұрын
    • Just the opposite, actually. Let's start with "why use WinForms". A large portion of desktop applications in production today are WinForms. The reason why is because WinForms has been around for over 20 years. When you start building on a technology, you don't typically change from that technology. That means WinForms had a major head start over other UI options. Then, WPF was new technology and people didn't like XAML. Those two things stunted its growth. That means that even when WPF came out, businesses didn't start adopting it right away. Companies have a heavy investment in their applications. They cannot just change because they like a new UI better. That takes a LOT of time and time is money. I worked at one company where we had 17 developers. They wanted to transition from one tech to another. It was going to take 18 months to get there, plus it was going to slow down current development to a crawl. They kept putting it off because of the cost implications. Think of how much that would cost. 17 developers times 18 months. At a very conservative $100,000/year/developer (don't forget that would mean a salary of about $65,000 since benefits are expensive), that would be a cost of $2.5 million. How do you justify that to an executive when the result is the same application visually and they can't get any (or many) new features for almost two years? Hint: you don't. And that is for a small company (less than 500 employees). A larger company would be even worse, if it is even possible. So, when you are looking for a job, you might want to work with the latest technologies, but most likely you will end up in an established organization. Depending on how long they have been around, the technology they are working with might be 5-15 years old. That doesn't mean they haven't done any updates. It most likely is going to be a spectrum, where there are some old things and some newer things. So, learning WinForms is important for that reason. As for the question of WinForms being deprecated, the answer is no. WinForms is being actively maintained. It is currently on .NET 8 and there are changes coming to it for .NET 9 in November. But let's look at the other desktop UI options from Microsoft. WPF is still around, although development has been sent to India (still Microsoft) which is usually an indication that a technology is in maintenance mode rather than development mode. UWP has been deprecated. WinUI 1 & 2 have been deprecated. WinUI 3 is still active, although based upon the fact that you have to be on Windows 10+ to run it, I doubt it will be around for long (companies can't usually make that type of commitment to a limited number of operating systems). Xamarin is going to be deprecated next month (May 2024). MAUI has replaced it and MAUI can do desktop apps for Windows (using WinUI 3) and Mac (no Linux support), but that isn't the primary focus of MAUI. The primary focus is iOS and Android, so I wouldn't recommend MAUI for desktop either. And that's it unless you count Console apps (which have a HUGE value, but mostly for automation and services). So, what's left standing? WinForms.

      @IAmTimCorey@IAmTimCoreyАй бұрын
    • @@IAmTimCorey That's great to hear. What are they doing to handle the issues when Windows changed ui rendering. This created havoc on my old winforms projects. This would be (I believe) with the adoption of Windows 7. All my winforms visually scaled poorly and I ended up finding a work around by altering the manifest file. Also, has Microsoft improved Winforms so they can run on other OS', i.e., a Mac (do you know)? Thanks for taking time to answer btw.

      @scottstrand7865@scottstrand7865Ай бұрын
  • Hi tim, I am receiving internal 500.00 error while running the asp. Net default program through Iis server , I fetched for solution in KZhead but no use, please help me if anyone know this

    @ammulu1966@ammulu1966Ай бұрын
    • Check the event viewer to see what the underlying problem is.

      @jonathanblackwell42@jonathanblackwell42Ай бұрын
    • A 500 error is a generic error. As @jonathanblackwell42 pointed out, look at event viewer or your application logs to determine what is the actual error.

      @IAmTimCorey@IAmTimCoreyАй бұрын
  • Is there People’s who write programs in Winform today in 2024 I thought it was Blazor we developed in

    @KnudNielsen-mv2dt@KnudNielsen-mv2dt28 күн бұрын
    • Remember that we don’t just start out with new apps when joining a company. You typically work on existing applications that have been built over the course of years. Blazor is a great option for new apps, but it is rather new.

      @IAmTimCorey@IAmTimCorey28 күн бұрын
    • WinForms stays a quick way to put into production apps with an interface and if you take some time to fine tune them... well...they are not that uggly. Personnal opinion of course :)

      @thomstunes6485@thomstunes64854 күн бұрын
KZhead