I just installed Visual Studio 2012 express for Desktop. I can't see any place to create a GUI application with C++ ! Where is this "Windows Form Application" used to exists in Visual C++ 2010 ? Where are these drag and drop controls? I installed this because I got details telling this supports GUI intellisense (Visual C++: Unable to invoke method from another class)
It is an unsubtle hint that they want you to stop creating C++/CLI Winforms applications. The plumbing is still in place however, at least for VS2012 and VS2013. This might not be the case in a future one.
You can turn a CLR console application into a Winforms application with these steps:
Start with File + New + Project, CLR node, CLR Console Application
Project + Add New Item, UI node, Windows Form
Project + Properties, Linker, System, SubSystem = Windows
Project + Properties, Linker, Advanced, Entry Point = main
Change the pre-generated .cpp file to look like this:
#include "stdafx.h"
#include "MyForm.h"
namespace ConsoleApplication45 { // Change this!!
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
int main(array<System::String ^> ^args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew MyForm());
return 0;
}
}
Note that you'll need to change the namespace name to your project name. Press F5 to test. You can design the form as normal once everything checks out.
NOTE, Visual Studio 2015 has a nasty static initialization order bug in the CRT that can cause the app to crash instantly with an AVE at startup if the project contains any native C++ code. As yet an unfixed bug, the somewhat inevitable hazard of having these project templates removed. A possible workaround is to change the Entry Point (4th bullet).
For a project that targets x86, copy paste this string:
?mainCRTStartupStrArray##$$FYMHP$01AP$AAVString#System###Z
For a project that targets x64, copy paste:
?mainCRTStartupStrArray##$$FYMHP$01EAPE$AAVString#System###Z
Somewhere around VS2017 the designer fails to open a new form with a cryptic error message. Workaround is to build the project first, use Build > Build.
Remove the #include "stdafx.h" and this works well for VS 2022. The form must be hand coded since the Form Designer support was removed starting with VS 2012.
Related
we are trying to use an activex control from WPF to save a rewrite right now. Found this article , https://msdn.microsoft.com/en-us/library/ms742735(v=vs.100).aspx that refers to the Windows Forms Control Library Template. now I have Visual Studio 2015 Community Edition and there is no such template. Googled and just found pages with no usable content. was wondering if I could be pointed to where this exist or is there an alternative?
The Windows Forms Control Library Template is a litte bit difficult to find. In my Visual Studio 2015 implementation I have it in the directory Visual C#\Windows\Classic Desktop. If you don't have this template, at least for Windows Forms you can also choose template Class Library and later change it in in such a way that you can use the Testcontainer when debugging your class library.
For how to achieve this see the post of Arnshea (6 upvotes) in this link A project with output type of class library cannot be started directly - with a startup exe. I have used his technique when I accidently used the wrong template when starting my projects.
Regards JRB
I must be brain dead. I have tried for six hours now (with Google) and can not solve this very very simple problem.
In Visual Studio 2010, I created a project. (right-click on solution, Add new project...).
Inside the new project, I created a new folder of name Helpers. To the folder I added a class for a converter.
Inside the project, I added a new XAML window (in WPF). The Target Framework is .Net Framework 4.0
Everything has been built (multiple times) without compilation errors. The platform target build for the project is X86.
The problem: Intellisense does not see the namespace for the class under the Helpers folder and so the Visual Designer fails. The namespace in the Helpers folder is:
Chaos.UI.Helpers
and trying to reference this namespace in the XAML like:
xmlns:converters="clr-namespace:Chaos.UI.Helpers"
ofcourse results in the dreaded:
Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'Chaos.UI.Helpers' that is not included in the assembly.
These are clean files in the same project. The only added code is in the converter class contained in the Chaos.UI.Helpers namespace.
How do I fix this? (I need the designer to work).
Anybody, Plz help
Try use assembly
xmlns:converters="clr-namespace:Chaos.UI.Helpers;assembly=Chaos.UI"
I just installed Visual Studio 2012 express for Desktop. I can't see any place to create a GUI application with C++ ! Where is this "Windows Form Application" used to exists in Visual C++ 2010 ? Where are these drag and drop controls? I installed this because I got details telling this supports GUI intellisense (Visual C++: Unable to invoke method from another class)
It is an unsubtle hint that they want you to stop creating C++/CLI Winforms applications. The plumbing is still in place however, at least for VS2012 and VS2013. This might not be the case in a future one.
You can turn a CLR console application into a Winforms application with these steps:
Start with File + New + Project, CLR node, CLR Console Application
Project + Add New Item, UI node, Windows Form
Project + Properties, Linker, System, SubSystem = Windows
Project + Properties, Linker, Advanced, Entry Point = main
Change the pre-generated .cpp file to look like this:
#include "stdafx.h"
#include "MyForm.h"
namespace ConsoleApplication45 { // Change this!!
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
int main(array<System::String ^> ^args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew MyForm());
return 0;
}
}
Note that you'll need to change the namespace name to your project name. Press F5 to test. You can design the form as normal once everything checks out.
NOTE, Visual Studio 2015 has a nasty static initialization order bug in the CRT that can cause the app to crash instantly with an AVE at startup if the project contains any native C++ code. As yet an unfixed bug, the somewhat inevitable hazard of having these project templates removed. A possible workaround is to change the Entry Point (4th bullet).
For a project that targets x86, copy paste this string:
?mainCRTStartupStrArray##$$FYMHP$01AP$AAVString#System###Z
For a project that targets x64, copy paste:
?mainCRTStartupStrArray##$$FYMHP$01EAPE$AAVString#System###Z
Somewhere around VS2017 the designer fails to open a new form with a cryptic error message. Workaround is to build the project first, use Build > Build.
Remove the #include "stdafx.h" and this works well for VS 2022. The form must be hand coded since the Form Designer support was removed starting with VS 2012.
I spend most of my time developing controls for both WPF and Silverlight using the same codebase. To do this I add existing files from one project (say Silverlight) "as links" to the other (say WPF). For minor differences I use preprocessor directives like
#if SILVERLIGHT
...
#else
...
#endif
The code in these blocks is grayed out depending on the type of project you've opened the file from. So if you open your file from Silverlight project (where SILVERLIGHT is defined) the else part is gray and Intellisense doesn't work in it.
In order for WPF part to be processed by IDE (with coloring and Intellisense support) you need to open the file from the WPF project. When you try to do that you get a message box saying that "This document is opened by another project" and when you click OK it displays that file in the context of the Silverlight project (not what I wanted to see). So I have to close the file, navigate to WPF project again and open the file again. This is very, very annoying.
So the question is this: is there some sort of setting or add-on that would make Visual Studio reopen the file from the project where I double-clicked on it instead of showing that stupid message box and showing me that file from the "wrong" project?
This has happened to me about twice in a month now, not in a WPF application. No idea why it happens but in both cases the fix was to Clean the solution, reboot the PC (not just restart Visual Studio) and then build the solution.
You could make this a little easier to work with by using partial classes and multiple files: shared code that is the same for both WPF and Silverlight in a shared linked file, and a separate file for each containing the code specific to one or the other (with identical method/property signatures), each of which is only in one of the projects. Doing this allows both the WPF and Silverlight versions to be opened at once (since they're separate files) at the cost of adding a bunch of extra file management overhead.
Beyond that, get some extra memory and use separate solutions.
It occurred to me, when I had one project containing a linked file of other project under one VS solution. When I tried to navigate to the definition of a method in linked file, VS prompted with a message that this document is opened by another project.
To resolve this, I had to unload the project that owns the original file from the VS solution. After that navigating to method definition in normal time and debug time was not an issue.
Yes this is possible using Visual Studio Shell.
First instantiate EnvDTE80.DTE2 object:
private static EnvDTE80.DTE2 _dte;
public static EnvDTE80.DTE2 DTE
{
get
{
if (_dte == null)
_dte = ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE2;
return _dte;
}
}
and then:
// On Document Opening, close the existing instances.
// This event occurs when you double-click file in Solution Explorer.
DTE.Events.DocumentEvents.DocumentOpening += (s, e) =>
{
if(!DTE.ItemOperations.IsFileOpen(YOURFILENAME))
return;
foreach(Window win in DTE.Documents.Cast<Document>()
.FirstOrDefault(s => s.FullName == YOURFILENAME).Windows))
win.Close();
}
// next; VS itself will call DTE.ItemOperatins.OpenFile(YOURFILENAME);
HTH.
I am compiling a Winforms app for use with Mono and using the .Net stuff built into Visual Studio 2008 for a Winforms app. Everything works fine, but I'd like to run without the terminal window opening.
Do I need to use gmcs to get this line to work:
-target:winexe
as seen here? Or can I do it with the built-in commands that Visual Studio uses for .Net?
In VS, make sure the project type is set to "Windows Application" and not "Console Application" on the project properties page.
If that doesn't fix it, try using monow.exe instead of mono.exe to run the application.