I can't figure out why some activities in the WF designer do not expand.
Looking at the sample documentation for the WizardActivityPack activities:
But when I try to open the same file in Visual Studio 2010's WF designer:
If I look at the file using the XML editor I can see all the activities are in the file, but the designer only shows me the one box and I cannot click into or expand it.
You have to place the *.design.dll somewhere that visual studio can find it. Like in the %programfiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies.
VS looks for designers by convention; if the activities are in an assembly called Activity.dll, VS looks for its design classes in an assembly called Activity.Design.dll under VS' codebase (and subdirectories) or (I believe) in the GAC.
This fact is important to know when creating your own activities/designers! The reason behind this is so that your Activity assembly doesn't need to reference the Designers dll; you can deliver the Activity assembly by itself to production while leaving the Designers dll on the design machine.
(If you reference the *.Design.dll from your Activities assembly, or if they exist in the same assembly, this doesn't apply. The recommended pattern is to separate the two and allow VS to load them via convention. For an example of this, see this sample.)
add this line
new DesignerMetadata().Register();
to WPF presentation
Related
I'm learning F# and I'm just trying to build Animate a pendulum program.
Here's the code:
https://rosettacode.org/wiki/Animate_a_pendulum#F.23
As far as I understand, VS 2019 doesn't support WinForms in F# (maybe, I'm wrong), so I have error messages, trying to copy/paste that code:
What should I do?
Thanks a lot !
If you're looking to use Winforms on .NET core, you'll need to do the following in your project:
Open the project file (double-click on the node in Visual Studio)
Change the Sdk to Microsoft.NET.Sdk.WindowsDesktop
Ensure you have this OutputType: <OutputType>WinExe</OutputType>
Add the following property to the top-level PropertyGroup: <UseWindowsForms>true</UseWindowsForms>
There won't be a visual designer to use, but you should have access to the APIs.
Unfortunately, there is no Winforms designer in Visual Studio 2019 for F# projects of any type, and Winforms can only be easily accessed (as far as I know) in .Net Framework (NOT .NET Core) projects they can be accessed as per #Phillip Carter's answer.
However you can still make Winforms programs easily by manually adding the references to your .NET Framework project, or (more easily) by manually compiling with the F# compiler, fsc.
The Fast Way
The easiest way to do this is simply compile the source code with the F# compiler from a single source file with fsc.exe. The F# compiler will automatically resolve dependencies for things like System.Windows.Forms and a lot of other commonly used namespaces. You can also provide lots of compiler directives for requiring other resources as well.
Example using VSCode, with various extensions:
Another Way
Start a new F# console .NET Framework project (don't pick .NET Core).
Right click on "References" in the Solution Explorer and click "Add Reference..."
Under assemblies, look for "System.Windows.Forms," select it...
And also select "System.Drawing" and then hit OK
Now you have access to both of those namespaces.
Before you run the project in Visual Studio, you should replace
[<STAThread>]
Application.Run( new PendulumForm( Visible=true ) )
with
[<STAThread;EntryPoint>]
let main _ =
Application.Run( new PendulumForm( Visible=true ) )
0
This way you (and VS) know where main actually is. It's not necessary for this small of a program to actually run it, but as your projects get larger VS will complain more about where things are located in your project.
I've generated pseudo-localized versions of an app's resource files (for example Order Summary and Payment is localized as [[[[[Òŕd̂ër̊ S̀úm̂m̈år̀ý ân̈d̊ P̀áŷm̈e̊ǹt́]]]]]) so that we can test for localizability bugs ahead of getting actual translations.
I have named them using the qps-ploc resource identifier to match the existing pseudo-locale identifier, e.g. my pseudo-localized version of Details.resx is named Details.qps-ploc.resx.
However when I add these resx files to the project, Visual Studio ignores them. If I rename them using a "real" language code (such as Details.fr-FR.resx) then Visual Studio does create a subfolder named with this language code and builds the satellite assembly.
So it looks to me like Visual Studio rejects qps-ploc (without even a build warning). Am I missing something or can anyone suggest a way to get these qps-ploc resources built as part of my Visual Studio project?
The qps- locales work fine in my ASP.NET web application with .resx files (not compiled resource dll), however, I did find this MS article on enabling pseudo locales in the registry. Perhaps it will help.
Using Pseudo-Locales for Localization Testing
Additionally, you may wish to create custom locales, as given in this MS article:
How to: Create Custom Cultures
Best regards.
I am new to Visual Studio Extensibility and want to make an addin/extension which shall do the following:
It should read all the files with a specific file extension (assume "*.ump").
It should process the text/code/whatever in the files.
It should create new Class/Code file with some code in it. [The code will be produced in step 2, just need to know how to do it?]
Yet, I have been racking my brains through extensibility, saw the single file generators .... and addins which go through ProjectItems and can detect the file extension,
BUT I HAVE NOT BEEN ABLE TO FIND a complete tutorial, guide or explanation as to how or what to do!!
Please help...
You don't want to read all files with a specific file extension in Visual C++ project nor standard Visual C# project. You may do that with hand-made MSBuild project (included in the solution).
In Visual C++ projects, there is a way to define custom tools. They are run as separate processes, so you can implement them in anything you want. Studio will ask you whether you want to define a tool (they are defined in special xml files; studio has dialog for editing them) when you add a file with extension unknown to it. In Visual C# projects, just manually write a MSBuild tasks and insert them into the project.
Do whatever you want. IIRC the generated files will have to be included in the project though. Well, for MSBuild, just tweak the project to your heart's desire, but in Visual C++ they have to.
You can combine MSBuild (csproj,vbproj) and VisualC++ projects in a single solution, so I recommend using separate.
If you ever find out you need to compile for different target where you can't use Visual Studio, you'll be glad that you have stand-alone tool you were just calling from Studio and not something that embeds in it.
Even with F# installed, Visual Studio 2008 (and probably 2010) only provides Add-In project templates for C#, VB.NET and C++.
So, how to create a F# based Add-In?
I have tried to create a F# class library project with a new class implementing IDTExtensibility2, setting the correct references (EnvDTE, Extensibility, ...), copying a few project attributes from the C# Add-In (mainly the command line for debugging), and creating the .AddIn manifest file by hand, but no success. When VS is launched, my Add-In is not listed in the available ones.
What are the missing steps? Some kind of COM registration somewhere?
I've not tried this exact scenario, but the general strategy I've had the best luck with is: start with the C# template, rename the .csproj to .fsproj and change the <Import>s for F# and replace the <Compile> of C# code with F# code, and go from there.
The templates often have various important logic in them for build/deployment, so start with a working template for C# and tweak it for F#.
I finally found what went wrong: I simply forgot to put the .AddIn file in the AddIn directory (the C# wizard is doing this automatically).
So, to create a F# based Add-In for Visual Studio:
Create a new F# class library project
Add a few reference assemblies to the project (mainly EnvDTE, EnvDTE80, EnvDTE90, Extensibility)
Create a new class implementing IDTExtensibility2
Copy the debugging properties of a C# based Add-In project into your F# project
Copy the .AddIn manifest file, and modify it according to your F# project
*.. and don't forget to copy that new file in the AddIn directory for the user session
enjoy!
I am hoping someone can help me with this. What I have been looking around for but can't seem to find is if there is someway to add an event, or anything else that will allow a visual studio plug-in to watch for an external reference to be added to a currently open solution / project?
Or even better yet would anyone happen to know of an add-in that automatically adds all controls from a referenced dll into the visual studio toolbox?
Thanks.
Not exactly what you asked, but I've written a Visual Studio 2008 Integration Package, and if I recall correctly I could override the "add reference" method, as well as inherit the "reference node" and thus change its behavior, for example its constructor.
This functionality might be missing from an add-in (which is more limited than an integration package), so you might consider writing a package instead.
I have written a macro that will change a file reference to a project reference if you add the project to the solution (and vice versa), but I don't think that's what you want?