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?
Related
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'm using ChromiumWebBrowser for my program. I follow the steps in Github to set it to be any CPU. Then I've encounter a problem: I could not load UI XMAL Designer but I could run the code after closing MainWindow.xaml. And when I open UI Designer, it shows me:
And the error is:
The name 'ChromiumWebBrowser' does not exist in the
namespace'clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf'.
But I've already put xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf".
I also check for the question here, but it does not help.
I'm looking for some suggestions. Thanks in advance!
One option is to skip the "Any CPU" route and instead compile you WPF app to x86. This way you can get the designer to work more easily.
But as you mentioned, your app works in "Any CPU" even though the designer shows an error so if you can live without the WPF designer and just manually edit the XAML, things should work normally.
Here's the steps to make the Visual Studio's WPF designer to work with ChromiumWebBrowser in x86 WPF app:
Create new WPF project
Install Nuget-package CefSharp.Wpf 57.00
If you now try to compile the solution, you'll see an error: CefSharp.Common will work out of the box if you specify platform (x86 / x64).
Select Build - Configuration Manager
Click "Active solution platform" - New
Create x86 configuration and make sure it's active
Build
(Restart Visual Studio)
Open MainPage.xaml and add the Chromium:
Designer and the app should work correcly
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
My Visual Studio 2012 project may end up being memory-intensive, so I have built all of the projects in its solution for a 64-bit processor. There was at least one project (unfortunately I don't remember which) that was left at "Any CPU". I decided to convert the contents of a form to a user control. It built successfully, and I was able to add the resulting DLL to the toolbox and then drag the new control onto a form.
However, I was getting ugly warnings about mismatches between processor selections. To clean them up, I changed all projects to target 64-bit processors. Suddenly, I could not use my 64-bit control on my forms. Research revealed one article that said that Visual Studio is a 32-bit process, and therefore it could not host 64-bit controls in the toolbox, but it is still possible to use those controls dynamically. But the KB article I found dated back to the days of VS 2008.
Is this still true in VS 2012? How can I get my 64-bit control into the toolbox so I can drag and drop it onto a form?
Thank you very much.
Solution:
Add a Class Library to your Solution - Use the Any CPU flag to compile.
Move your UserControls to this library.
Add a reference in your x64 project to this library.
Build the solution, and then the UserControls are available in your x64 designers.
I ran into this when writing an application using 64-bit Oracle.DataAccess. The solution then had to become 64-bit, leading to the usual problem with 64-bit controls not being draggable from the Toolbox onto forms. I ended up making all components that had a Designer build with AnyCPU, but the rest of the application as x64. Worked perfectly.
I wrote a C# program and I will compile like this:
C:\Users\Administrator\Documents\Visual Studio 2005\Projects\GUITest\GUITest>mcs *.cs /r:System.Data,System.Drawing,System.Windows.Forms,..\HtmlAgilityPack.dll
But the output application has a console window.
Is there a way to compile the program so that I can get a application without a console window?
There are two different "modes" or types of Windows applications: console applications and GUI applications. The same goes for managed applications, regardless of how you build them.
Console applications will always display a console window on startup, automatically. You can also write code to display a GUI window (e.g., a form), but this is optional. Either way, the console window will always be displayed.
GUI applications do not display anything on startup. Generally, you write code that displays a GUI window (e.g., a form), but you do not have to. If you do not display anything, you have created what people often refer to as a "background application" because it runs in the background without displaying any UI. That is not possible with a console application, because it displays that ugly console window.
So if you don't want the console window, you don't want a console application. You want a regular GUI application.
Now, the challenge is figuring out how to achieve this using the Mono compiler. Visual Studio exposes this option as a project-level setting. The Mono compiler needs a flag, /target to tell it what type of application to build.
/target:exe (the default option) will build a console application
/target:winexe will build a GUI application
/target:library will build a library (which is not an executable application, but just a chunk of reusable code)
So, change the command you're running at the command line to:
mcs *.cs /target:winexe /r:System.Data,System.Drawing,System.Windows.Forms,...
I believe that you will also need to make sure that you're running a relatively recent version of Mono. The older versions did not include support for creating GUI applications (the /target:winexe switch was not implemented). I know that this is fully supported as of version 2.8, but there's little reason not to use the latest version available.
In case my answer is not authoritative enough for you, you'll find the same quick fix (without the rationale) documented in the Mono WinForms FAQ.