How to perform "shell" icon embedding in Visual Studio 2010? - visual-studio

As far as I can tell, there have been (at least?) three types of icon embedding. There's the original style used by shell32.dll and friends, .NET's embedding, and the new type that WPF uses. I'm looking for how to perform the first one, as I want to have a few other icons available as resources for a jumplist, which can only accept that style. However, I can't figure out how to embed in this style, only the other two.
How do I do this? All the results I find on google, etc are for adding icons to ResX files or similar.

I never heard the term "icon embedding" before. If you are talking about the icon that's visible for a EXE or DLL in Explorer or a desktop shortcut: that's done the same way for any Windows program. Both WF and WPF give the assembly an unmanaged resource with the selected icon using the /win32res compile option. You can see it in Visual Studio with File + Open + File, select the EXE or DLL.
To create a .res file, first create a .rc file. You can create one with the C++ IDE. Right-click the solution, Add New Project, Visual C++, Win32, Win32 Console Application. Right-click the Resource Files folder, Add + Resource, select Icon, Import. select your file. Repeat as needed. After you build, you'll get a .res file in the project's Debug build directory.
Back to your C# project, Project + Properties, Application tab. Select the Resource File option and navigate to the .res file.

I'd highly recommend taking a look at this solution posted here (http://einaregilsson.com/add-multiple-icons-to-a-dotnet-application/). It integrates right into a ms build post build event and doesn't require an unmanaged project (to create an assembly from a .rc/.res file).
This removes a dependency on managing a second solution / assembly anytime you want update an icon and saves you from IL Merging the compiled c++ assembly.
I'd also recommend taking a look at WIX for your deployment. I've written a guide that accompanies this answer located here.

Related

Why doesn't Resharper's Assembly Explorer show anything?

I am trying to decompile an assembly with ReSharper extension for Visual Studio, but when I go to ReSharper→Windows→Assembly Explorer, the explorer is blank. When I have a project open, the tool behaves the way it is meant to, but creating an empty project in order to be able to decompile is just awful. I would like to avoid using the standalone decompiler dotPeek.
The assembly explorer window is intended to show any assemblies that you want to decompile, but aren't referenced in the solution. If an assembly is referenced somewhere in the solution, ReSharper's normal navigation will decompile classes and methods on the fly.
In other words, it's intended to be used in conjunction with the currently open solution, which means it doesn't work without a solution open (also, I believe the list of assemblies in the assembly explorer are stored in the solution settings. Without a solution, there's no list to display).
What's the issue with using dotPeek? It's exactly the same codebase, just compiled with some standalone components rather than as a Visual Studio plugin?

Using a DLL I've created in another VS2010 project doesn't show the intellisense tooltips

I've created a DLL to a project in Visual Studio 2010.
I'm using this DLL in another project. Using the functions is completely possible - but I can't see any tooltip.
In addition - if I'm in the same project the tooltips can be seen.
I've read some issues about using the XML file with the name of the DLL in the 2nd project, but I'm afraid I don't have any XML file (as far as I see...).
I'll appreciate your help!
Lior
In the project settings of your DLL you can specify that a XML file will be created each time the assembly is build. Thi setting is located on the "Build" tab, region "Output" and is called "XML documentation file". Mark the checkbox in front and the xml file will be created.
When you use the dll in another project you have to copy the xml file along with the assembly file to have the IntelliSense information in place.

using Qt designer in visual studio?

I'm using visual studio 2010, Qt add-in etc all ok, then create new project using Qt add-in... when doubleclicking *.ui (the actual form) file in VS it opens Qtdesigner, then I put some controls on, but that does not change my code at all :/
Qt form is changed it contains those controls but source files are the same as before even after building my project.
I'm I missing something?
I think Qtdesinger shoult put some code for objects which I created using Qtdesigner.
cos without that we must write all the code as if there were no Qtdesigner so Qtdesinger is useles in Visual studio, the same thing we could just do by hand-coding a form interface.
thanks alot.
EDIT:
OK
I've copied this from Qt site:
You are referencing objects from a .ui file...
The Visual Studio code model parser only parses C++ sources, meaning
that widgets or objects defined in .ui files will not be accessible.
To workaround the problem, the Qt Visual Studio Add-in automatically
generates C++ code from the .ui file by saving the file and running
uic on it. This step is done everytime the project is built. If the
code completion does not work, try to rebuild the project. It is
possible that you have to wait some time, before code completion fully
works after updating an .ui file. For more information, you can refer
to the Modifying Project Properties section. It still does not work...
You should refresh the code model, Intellisense. This is done by
opening the solution explorer, invoking the context menu of the
project and activating the item Update Intellisense.
now it looks that I'm having such problems but this does not help at all, update intelisece. I can't see such option in visual studio,
it looks my visual studio add-in isn't working.
it says "You should refresh the code model" Woot? can someone explain me how to do that please.
here are some output warnings when building my project:
Warning 1 warning : No resources in 'C:\Users\Admin\documents\visual
studio
2010\Projects\VisualStudio\test\test.qrc'. C:\Users\Admin\documents\visual
studio 2010\Projects\VisualStudio\test\RCC Warning 2 warning LNK4099:
PDB 'vc100.pdb' was not found with 'qtmaind.lib(qtmain_win.obj)' or at
'C:\Users\Admin\documents\visual studio
2010\Projects\VisualStudio\vc100.pdb'; linking object as if no debug
info C:\Users\Admin\documents\visual studio
2010\Projects\VisualStudio\test\qtmaind.lib(qtmain_win.obj)
I'm going to explain a little bit how things work and the relationships between the files, and hopefully this will solve your problem.
When you edit the ui file using the designer all changes are made to the ui file itself. Then when you build a couple of things will happen.
First... a custom build step will be run on the ui file. This build step runs "uic" as Macke said, and will generate a file called "ui_thenameofyouruifile.h". Where this file is located depends on your project settings, but if you look in your project you should see a folder called Generated Files in your project.
If you look in there you should see the newly generated file. This is the code that is "changed" when you make changes to your form. Now if this file is not updated, or does not exist at all, then somehow your project settings got messed up. In this case I would remove your .ui file from the project and re-add it. The add-in should do it's magic and add all the stuff you need. Build again and it should work. (I assume that is probably your problem)
The second thing that should happen when you build, is that the class that uses your ui file should recompile. Generally when you create a ui file, you also create an accompanying .h and .cpp file. This is where we do any of the fun logic that we might need in our window. The Qt designer will never ever change this class.
In the header file we refer to the ui file by doing this:
namespace Ui {
class thenameofyouruifile;
}
#include "ui_thenameofyouruifile.h"
and then we add a member variable
Ui::thenameofyouruifile UI;
There are a couple of ways to do this, but basically that's the idea. The add-in is supposed to configure your project so that the directory where the generate files go is included in the "additional include directories" in your project settings, but that is another place to check to make sure that your code is really linking with the correct generated file.
If Qt Add-In installed properly, it should generate the custom build step for Qt related files (.ui or moc file). I have not tried Qt Add-in with VS 2010, but with VS 2008 it's okay.
The work-around for your problem, you need to add manually the custom build step for each ui file you have in the project. To do this, the step is:
Right clicked the ui file, and click the properties (I'm using VS-2008 to do this step, and expect this may not be much different in VS 2010).
Under custom build step, add this in the command line: "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_$(InputName).h" "$(InputPath)"
And add this under output: ".\GeneratedFiles\ui_$(InputName).h"
And this under additional dependencies: $(QTDIR)\bin\uic.exe. Then click apply / ok.
If this is done, the ui file is compilable, (when you right click it, it can be compiled), so when the ui file content change, the new ui code (.h) file is regenerated.
Alternatively, to reset the VS project file (vcprojx) you can create Qt project in Qt creator, (or if you have already one), and then convert the Qt creator project (.pro) into vcproj using this command line:
qmake -spec win32-msvc2010 -tp vc
This will create the vcproj with the proper custom build step for you (in case you have many ui files, then you don't need to do the first approach).
If you've created a Qt widget using the new class wizard, stuff should work as expected.
I.e. your .ui files are compiled by Qt's uic to .cpp files, i.e. you need to build your project to get these changes into the ui-class.
So, the .ui files should be added to the project, and have some special build rules that invoke 'uic' on them. If that's not the case, try and re-add them to your project (that way, the Qt add-in should configure the build rules)
Normally, you have a class that inherits QWidget which then includes the compiled cpp-class, by one way or another, usually as a member variable (but inheritance is an option too).
Adding an .ui-file straight up should work too (if you're in a Qt project, which you are..), but obviously something is wrong.
Does the example projects work as expected?

How do I put a dll into my project - visual studio C# 2010

I need to put a dll file into my project, my notes say simply drag the dll into the toolbox but it doesn't seem to be working.
How do i do this?
thanks.
You use the "References" item in the Solution Explorer to add a reference to it; Right-click and choose to Add Reference. There is an option there to select the DLL file.
When you do this, by default the DLL is copied and included in the project's output, which is what you usually want for a .NET Assembly, anyway.
Which reminds me to ask to make sure; Are you talking about a .NET Assembly DLL here? Things could be quite different if you mean a native code DLL.
Put the DLL into the root of your ASP.NET project, then make a regular .NET reference to it. Once you click "Add Reference..." you'll get to the .NET assemblies tab in the reference dialog. Then you click "Browse" which should open up the root directory of the project. In there you'll find the DLL you want to use, select it and ok out of everything. Visual Studio will then copy the DLL into the bin directory for you and the code that uses that assembly will then work.
<%#RegisterAssembly="(DLL Name)"Namespace="(Namespace from Object Browser)"TagPrefix="(Any Prefix)" %>

How do you tell the Visual Studio project type from an existing Visual Studio project

Using Visual Studio 2005.
Is there anything in the .sln or .vcproj files (or anywhere else) that defines the project type / subtype?
Edit: What I mean is that when you create a project, you first choose a language (e.g. Visual C#), then a project type (e.g. Windows) and then a subtype (e.g. Console Application).
Where is this information stored within the VS files?
In the project XML files:
Console applications contain:
<OutputType>Exe</OutputType>
WinForms applications contain:
<OutputType>WinExe</OutputType>
Library (.dll) projects contain:
<OutputType>Library</OutputType>
and do NOT contain a
<ProjectTypeGuids>
ASP.NET and WCF projects contain:
<ProjectTypeGuids>{603c0e0b-db56-11dc-be95-000d561079b0};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
The GUIDs do something to define exactly what type of project it is. The ones above were taken from an ASP.NET app. They exist in WCF projects too, and flipping around the GUIDs can fool Vis Studio into changing the project type when you open it.
Some further research and I found this:
INFO: List of known project type Guids.
My .sln file contains:
Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddNumbers", "AddNumbers.csproj", "{2C81C5BB-E3B0-457E-BC02-73C76634CCD6}"
The link shows:
Project Type Description Project Type Guid
Windows (C#) {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
So it's Windows C# and the subtype is as per #HardCode's reply. In my case, it's "Console Application".
Right Click on Project of a solution.
Open Properties -> Application Tab.
On the right you can see 'Output Type' which defines your project type of an existing solution.
The .vproj file defines the project type, for example, the following defines a C++ project.
<VisualStudioProject
ProjectType="Visual C++"
The project tag also includes the compiler version.
Double-click on "My Project" in the Solution Explorer, and look at the "Application type:" ComboBox. It tells you (and lets you change) the project type.
Easy solution.
If you want to know if it's a WCF Project or ASP.NET Web Service simply open your project's folders in File Explorer. You can hover over the icon with your mouse and a tooltip will display the project type as shown in the picture. Also, you can look under the Type column in File Explorer and it shows it there as well.
WCF Web Service Project:
ASP.NET Web Service Project:
Also to note, if your project has a Resources.Designer.cs or Settings.Designer.cs in its Properties folder it's likely a WinForms application.
If you are interested in finding subtypes of a project i.e. Under C# Windows Project Category, checking whether it is a Windows Form Application or WPF
Try adding new item in the project and it will show you the items specific to that project type along with default options.
For instance if there is a WPF project it shows the WPF related options like 'Window' , 'Page' 'User Control' ... In case of Window Form Application it Shows 'Window Form' etc.....
Follow:
Solution Explorer -> hover/right click over your project item ( not the project folder. Check the Properties view to find if you clicked on the folder or the project) -> Properties.
Then all information is available for the project.
Right click on solution and click open folder in file explorer. Navigate to Project file. hover on it, tool tip displays the type of project file.

Resources