I created an user control and I added it into a new form, but some errors happened.
Everything is OK in any CPU mode but when I want to switch to X64, design form doesn't show.
I have had the same problem and I fixed it. Actually Visual Studio only works with X86 controls and you can't create a user control in X64 mode and use it.
You should add a new class library in Any CPU mode and build the class library. then you can add its DLL in your project. Done.
If it doesn't you must go to the Configuration manager and set the Active solution platform to X64 also do that for all subprojects.
Remember that build option has to be checked.
and go to the properties of the class library and click on the build tab. then set the platform target to Any CPU.
I am using a a single solution to reside two projects in visual studio 2012.
Project 1:
wpf
uses "any cpu" configurations (which is a must)
Project 1:
winforms
uses "x86" configurations (which is a must again)
the solution runs like this.
the window from wpf application opens up as startup window. from here a button is pressed to open a form in winform project.
Problem: if i keep the configuration as any cpu, the winform window wont open up and give an error. If i keep the configuration as x86 the wpf would give an error becasue the mlapp (matlab application) i am using wont be recognised.
please help.
The solution is to set individual projects to respective configurations as per requirement and then setting the overall solution configuration to "mixed platforms". it worked
I have a winform c# app with a real text box that I use for logging output. When I compile the app with "anycpu", i can view the main form (with the text box on it) just fine. However, when I compile as x64 (which I need to do for ms database engine), it states could not find my logging control. As soon as I go back to anycpu, again the form opens in designer just fine.
What am I missing?
Apparently, in configuration manager I had active solution platform: x64 and the project platform as x64 and that was not working. Switching the project platform to Any CPU at least for now enables me to view the form in design view so I guess it's fixed?
I'm getting the following error
Could not find type 'My.Special.UserControl'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.
But what doesn't make any sense is that My.Special.UserControl is in the same assembly as the form. What's more, if I view code on the Designer.cs file, There are references to My.Special.UserControl that seem to be fine. The assembly builds fine, and runs fine as well. It's the just the designer that's having issues.
As such we have to do all our design work by making adjustments to the Designer.cs file by hand. How can I make the designer work again?
The following procedure has worked for me:
Delete the /bin and /obj folders in your source code directory.
Restart VS (be sure the offending Form Designer is closed)
Compile
Open the Form in Designer again. The problem should be resolved.
I'm sure deleting both /bin and /obj are not necessary, but I haven't been able to reproduce the error and come to a more specific solution. (My projects are typically small enough that re-compiling the whole thing is no big deal.)
Usually, this error seems to occur after refactoring / renaming objects of the offending class. So my guess is that there is a VS bug that doesn't recompile the appropriate object file after a User Control or Custom Control is refactored.
Change the project type temporarily to x86, compile and open the Designer. Visual Studio is a 32 bit application.
There is propably an exception happening in the Load or Initialize Part of your Form / UserControl. Can you try to comment out any code there and retry opening in designer?
You can use another instance of Visual Studio to attach a debugger to your Visual Studio instance not letting you open the Form. Once an exception occurs you will be able to pinpoint the location where something goes wrong.
I had similar problem when shifted from VS 2017 community edition to professional.
Close VS
Go to Project folder
Delete .vs folder. Back up if you need.
Start VS
This should solve the problem
I have experienced the exact same problem. I am fairly certain that it is connected to the platform target x64. Here is a related post mentioning it as a bug in Visual Studio:
https://stackoverflow.com/a/11582828/7665665
How I deal with it: Although my solution is actually only x64, I have created another platform target x86 for the projects just to be able to use the designer. Now I switch the target to x86 in order to see my controls in VS Designer. For everything else, I switch back to x64.
I had the same problem with a user control which was derived from the standard .NET control within my form.cs. Nothing of the above worked for me (my solution is compiled as x64 because of other unmanaged components which only support x64).
I finally ended up with creating a separate project "Utils" and moving the offending derived controls to this project. This worked like a charm !
In my case I just unload project and reload again
Switching the project target to x86 was the only possible solution for me
This happened to me today. Cleaning, Rebuilding, restarting Vs and even rebooting did not help. Everything ran as expected, the only thing that would not work was the designer in VS.
In my case, since nothing lese worked, I went to designer file, removed the faulty control and then added a new one. Renamed, re-assigned event listeners and it worked.
Designer now works, but if this must be some kind of VS bug, I don't know.
This is not the answer I'd like to read when coming to SO, but I'll post it in case it helps anyone later.
For me, I deleted the .resx file for the form, and it built and showed up in the designer, no problem. Go figure....
I had a similar experience when I sub-classed DataGridView. The following procedure has worked for me:
Close the Form Designer tab
Close VS (2015)
Delete the /bin and /obj folders of the project
Restart VS
Rebuild the solution
I don't know which steps could be skipped as I have not taken the time to refine the process.
On my project, it only worked if I made the custom user control in a separate project in the solution:
Add new project "Class Library (.NET Framework)"
Add references to System.Windows.Forms & System.Drawing
Add the source of the new user control in the new project
Build the solution
Open the designer
Drag the new user control in the form
In my case the designer automatically added a reference to the new project when I dragged the custom user control in my form.
Hope this help others who stumble upon this question.
When I run my solution for the second time, this error appears:
Error 467 Unable to copy file "obj\x86\Debug\uil.dll" to "bin\x86\Debug\uil.dll". The process cannot access the file 'bin\x86\Debug\uil.dll' because it is being used by another process.
For work I need to close and reopen the solution.
Are you sure you are stoping running instances of your application? You need to stop the application you are developing (debugging or release mode) to start debugging.
Check to make sure your application still running in Task manager, if yes, kill it.
Disable 'Visual Studio Hosting process' from project properties.
I've found a bug in VS2010, regarding solutions that reference multiple projects in which you have at least one WPF control library.
When you open the WPF designer, the DLL's referenced by the project are locked. Therefore, trying to compile will issue that error.
If this is the scenario you are suffering, there's no solution AFAIK, but as workaround:
1. Make sure to close ALL the WPF open designers
2. Make a rebuild all, then clean solution, then build again. This works most of the time
Or, open the XAML files in XML editor in VS2010, so the designer is not loaded. I usually write XAML directly. If you have to write a more complex XAML, then open Blend side-by-side with VS2010, so you edit XAML in Blend and compile and debug in VS2010.