
7.10.2003
VS .NET and C# Tips and Tricks
Notes from MSDN TV session.
WinCV
<:VSDir>\SDK\v1.1\Bin
Excellent! Browse the system assemblies and QUICKLY shows you all the methods available. You just type the object and see the memberse. Much faster than MSDN help, etc.
You can configure which assemblies are loaded to search by WinCV by editing the wincv.exe.config file.
Sharing a File for Multiple Projects
Physical file in a directory, but want to "point" to it from multiple projects.
In the project where you want to link, choose Add, Existing Item...find the file, but instead of click Open, pulll the Open button down and choose Link
This is great for AssemblyInfo.cs type stuff where version and signing key info are kept. Maybe only want to have one of these per solution.
Launch Multiple Processes in Debugger
Normally when you do GO -- it will launch the debugger on the "Startup Project".
Solution Properties, select multiple startup projects. For each one, can change start with or without debugging. as well as the order in which they are started.
Start with a Blank Solution
Helpful when you have many projects one level below where you want the solution. Instead of having the solution file in the same directory as the FIRST project you created.
Task List
Use //TODO: dan, fix this!
Tools, Options, Task List, add your own stuff, like ShowStopper etc. with different priorities.
Pre / Post Build
C# only.
Build properties,
Pre - maybe clean the build folders, remove from GAC, etc.
Post - maybe install to the GAC. i.e. "gacutil -i $(TargetPath)" (use Macros to point to various file paths, etc)
Set condition (only if successful, etc)
Treat Warnings as Errors
Build Properties, set to True. Recommend should always do this with release builds
Always set warning level to 4. (get as much help from compiler as possible)
Navigate XML and Structured Documents
xml, aspx, etc.
View, other windows, document outline.
C# Event Accessors
Usually a delegate is a public member variable. This is sometimes bad design, since you may want to control how many subscriptions are allowed, or limit access to subscriptions during key times, etc.
Can setup delegates with accessors much like a property.
Clients still use the += and -= operators to setup subscriptions to your event.
WinCV
<:VSDir>\SDK\v1.1\Bin
Excellent! Browse the system assemblies and QUICKLY shows you all the methods available. You just type the object and see the memberse. Much faster than MSDN help, etc.
You can configure which assemblies are loaded to search by WinCV by editing the wincv.exe.config file.
Sharing a File for Multiple Projects
Physical file in a directory, but want to "point" to it from multiple projects.
In the project where you want to link, choose Add, Existing Item...find the file, but instead of click Open, pulll the Open button down and choose Link
This is great for AssemblyInfo.cs type stuff where version and signing key info are kept. Maybe only want to have one of these per solution.
Launch Multiple Processes in Debugger
Normally when you do GO -- it will launch the debugger on the "Startup Project".
Solution Properties, select multiple startup projects. For each one, can change start with or without debugging. as well as the order in which they are started.
Start with a Blank Solution
Helpful when you have many projects one level below where you want the solution. Instead of having the solution file in the same directory as the FIRST project you created.
Task List
Use //TODO: dan, fix this!
Tools, Options, Task List, add your own stuff, like ShowStopper etc. with different priorities.
Pre / Post Build
C# only.
Build properties,
Pre - maybe clean the build folders, remove from GAC, etc.
Post - maybe install to the GAC. i.e. "gacutil -i $(TargetPath)" (use Macros to point to various file paths, etc)
Set condition (only if successful, etc)
Treat Warnings as Errors
Build Properties, set to True. Recommend should always do this with release builds
Always set warning level to 4. (get as much help from compiler as possible)
Navigate XML and Structured Documents
xml, aspx, etc.
View, other windows, document outline.
C# Event Accessors
Usually a delegate is a public member variable. This is sometimes bad design, since you may want to control how many subscriptions are allowed, or limit access to subscriptions during key times, etc.
Can setup delegates with accessors much like a property.
public event MyDelegate NumberChangedEventWithin the add/remove functions, you can do whatever you want. Didn't specify how to reject a subscription, etc. since there's no return value. Maybe you throw exceptions?
{
add { m_NumberChangedEvent += value; }
remove { m_NumberChangedEvent -= value; }
}
Clients still use the += and -= operators to setup subscriptions to your event.