Cannot load user control design view in Visual Studio 2019 - c#

This is very strange. I have a custom UserControl called UIControl. That user control has another custom control (derived from Label control).
This worked OK for long time. Both at design time and at run time. However, now, I needed to edit that custom UIControl but the Visual Studio 2019 shows this error message:
This error means that the RealTime.DigitalClock is not found. As you see in the project, that control is not part of an external assembly, but the same assembly where UIControl is.
I have compiled and recompiled thousand of times and compilations finish perfectly. Even the application runs.
Furthermore, when I build the project, those user controls appear in tool box, but when I try to place it in any form, an error telling that the component could not be added and it will be removed from the tool box is shown.
I don't really know what is happening here. I have even closed and re-open VS 2019 but no avail.
Regards
Jaime

According to To prevent possible data loss in windows form c#, I suggest that you can do as the following steps.
First, Please find all the RealTime.DigitalClock related code in UIControl.designer and UIControl.cs.
Second, you can delete the above code.
Third, you need to rewrite the code you just deleted.
Finally, rebuild it and check if it works for you.

Related

MessageBox.Show not working at all

I am developing an app for Windows Phone 8 with C#
And I've been working alot with MessageBox.Show() , and All the time it used to show a PopUp message like i wanted , but then suddenly , it Won't show anything , I debugged the app , the code runs normally and compiles the Line MessageBox.Show("Something");
but it doesn't pop up !
I also tried to put it in another page , doesn't work too !
All i remember that yesterday I have messed with References of the Project
But is that the problem ?
Anyways here's a photo of the references of my Project
When you build a Windows Phone Project it automatically generates all the required dependencies for you. You should be able to in your class file and add the following using statement:
using System.Windows
Once you've done that you'll be able to implement the MessageBox class. If not, then you'll need to do the following:
Open Solution Explorer
Right Click Reference Folder
Add Reference
Go to Assemblies
Go to Browse
Navigate to: C:\Windows\Microsoft.Net\Assembly\GAC_MSIL\PresentationFramework
Reference PresentationFramework.dll
Once you've referenced that library, you'll be able to call: MessageBox.Show(#"Something"); without a single hiccup.
Solved!
1.) Restarted my computer
2.) Deleted the app from the phone
3.) Debug
I had a problem with MessageBox.Show() not working.
It happened on two different pieces of software: Kaxaml, and an example from the Troelsen C# book.
I troubleshot it by just using a simple string inside the Show() instead of the "Exception" delegate in different spots in the code, and that helped tell me that I had the right references. Obviously, if MessageBox worked in any place in the code at all, that told me I had the correct references.
Basically, what was happening was the Visual Studio debugger would fire before the catch-try blocks, preventing the MessageBox from ever appearing. When I used the Release version, there would be no MessageBox either though.
What solved it was by just turning off a little click-box that said on Visual Studio, something like, "Don't show this exception". Kind of odd that Visual Studio still fired off an exception error, even though it was in a catch-try block, but whatever, this worked for me.

Visual c# nothing is appearing

This might sound extremly strange, but i have no idea what to do.
Visual studio 2008
c# windows form
I've been working on a project for a while, and it's all been rosy. Now, anything i add to the windows form in terms of labels, picturebox's ect don't appear at runtime. They are visible in the designer view, but do not appear at run time. Now, even when i move things that were already there, they don't move at runtime.
I'm guessing this is the cause of a windows update messing with visual studio again, but i can't find anything on the problem
Just a note, The project runs exactly how i left it yesterday every single time. Regarless if i move objects, add labels.
Anyone know of anything like this, know of a fix.
Thank you
I think you should Clean your solution and then rebuild it.
As you are using Express Edition, Clean option might not be added by default.
Go to Tools -> Settings and Select "Express Settings".
Now go to Tools -> Customize. And select Commands tab in the dialog.
In the dropdown next to Menubar radiobutton, select Build.
Click on AddCommands and add "Clean Solution".
Now you can go to Build -> Clean Solution. And then rebuild the project.
One time, I found the .suo file of the solution corrupted for unknown reasons.
Delete or rename it, then try again ?
The designer for classname.cs rewrites classname.designer.cs. View the code of the designer.cs and see if your changes are actually being saved into this file. Try hand-editing this file (change a label string or something else easy to spot at runtime).
Maybe the designer.cs file is read-only or perhaps there is a design-time exception that prevents saving the new .cs. I have run into issues like this when I had third-party component libraries in a project and the third-party designers were crashing.
Did you perhaps remove the call to InitializeComponent() from your Form class constructor?

Cannot see changes I make when I run my application in Visual Studio

I make changes in .cs files and also some changes with the designer. After this I compile and run the project.
The problem is that it shows the my old form, and it does not show the new changes I made in the form.
In other words, I don't see the changes I made when I run my application.
Try to Rebuild or Clean/Rebuild project, of course first be sure that you Build it after change.
When you have compilation errors and stuff like that Visual Studio will pop up a windows asking if you want to run the last successful build. It has a checkbox that says "Do not show this dialog again". If you have previously checked that box it can produce something like what you are talking about.
This may not be your problem but at the very least you should check it out, just in case.
The window looks like this:
To fix it go to your Tools->Options then:
I don't think it is a problem, you may not building the application.
I would check your Configuration Manager for your solution. It's possible that your active solution (e.g. the solution type specified by your Configuration / Platform combination) is not set to actually build the project.
The Configuration Manager has a Build column with checkboxes. Ensure that all the projects you want to build for a configuration are set to build.

Why can VS not display my WPF application in the designer, but it can run it just fine?

This is absolutely ridiculous! Visual Studio is able to run (debug) my program just fine, but it won't display my layout in the designer. It just gives this useless error:
alt text http://img6.imageshack.us/img6/8661/vserrorscreenshot.png
Can anyone help explain this? I have not changed the XAML at all, not a single character, since the last time it worked fine. I've only changed some .cs code.
because VS is cripple in terms of Xaml editing. Just turn off that designer, http://www.thejoyofcode.com/Using_the_Source_Code_Editor_for_XAML_in_Visual_Studio.aspx
Have you tried doing a rebuild? In the past I have noticed that this happens if the compiled code is out of date.
See this: XAML Designer failing to render - UserInitiatedNavigationPermissio
Basically, that looks like bug that is fixed in Visual Studio 2008 SP1. If you already have SP1, then run repair installation of VS2008 (go to Add/Remove and then select Repair option)
Also see this StackOverflow questions:
wpf custom control not recognized
WPF Designer exception while trying to edit UI in Visual studio 2008
This sometimes happens when the application must use some data that is gathered at runtime to render properly. I've had this problem when my controls are bound to data in a web service.
Have you tried Expression Blend? It has a better design view, you can edit the cs code (though the Intellisense is limited) and you can run the debugger.
While it's not a full replacement (it's not meant to be) it does mean you don't have to continually swap between Blend and Visual Studio if you're just modifying the UI.

My DataGridView properties window went blank!

I'm using Visual Studio 2005 w/.NET 2.0. I have no idea what happened, but all of a sudden I noticed that the Properties window for ALL of the DataGridViews in my project went blank. I've tried dropping in new ones..still blank. I restarted Visual Studio and my computer...still blank. I've done some google searches, and I've found people who have had the same problem, but there is no solution and it appears that Microsoft has been unable to duplicate it. Any ideas?
I created a new project in a new instance of Visual Studio and dropped a DataGridView in there, and it worked..then I checked my other project in the other instance of VS and the Properties can back for my DataGridViews. Fluke or solution? No idea.
I have had similar problems where my property windows go blank. It tends to happen when your machine is using a lot of UI resources or your toolbox is trying to update its list of controls.
Check to see if your control is being selected by your property window at the top of the property window screen
Try switching to a different control and then back to force the property window to update
Just close your UI Designer and re open it.
If all else fails, just close and reopen your solution
If it's still a problem you can always reduce how much memory your toolbox/UI designer uses by removing custom control generation in your toolbox window. To do this go to Tools / Options / Windows Form Designer / AutoToolboxPopulate - set to false. Now this will not populate your toolbox with custom controls anymore from your solution.
This same thing happened to me because the full path of the project contained an '&'. When I moved the project to a path that did not have an '&' everything worked.
There was same problem - reason was '&'.
I had a bunch of similar problems with Visual Studio UI doing wacky things. I figured it had to do with memory consumption (not a lack of machine memory). Jetbrains made a wrapper here that has solved a lot of my problems in Visual Studio 2005.

Categories