Browse by Tags

Tagged Content List
  • Blog Post: Converting a VBA Macro to C# 4.0

    I've talked a lot about improved COM interop in C# 4.0 and how much easier it is now to work with Office applications. This time I want to share some tips and tricks on how you can convert Visual Basic for Applications (VBA) macros to C# 4.0 by using Office 2010 and Visual Studio 2010. You can either...
  • Blog Post: How do I get and set Environment variables?

    Use the System.Environment class. Specifically the GetEnvironmentVariable and SetEnvironmentVariable methods. Admitedly, this is not a question specific to C#, but it is one I have seen enough C# programmers ask, and the ability to set environment variables is new to the Whidbey release, as is the EnvironmentVariableTarget...
  • Blog Post: Preprocess Win32 Messages through Windows Forms

    In the unmanaged world, it was quite common to intercept Win32 messages as they were plucked off the message queue. In that rare case in which you wish to do so from a managed Windows Forms application, your first step is to build a helper class which implements the IMessageFilter interface. The sole...
  • Blog Post: Be Mindful of the References / 'using' / Manifest Relationship

    Given that the .NET platform encourages binary reuse of types, it is commonplace to set references to external assemblies using the Visual Studio .NET Add Reference dialog box. Many programmers (especially those of the C(++) ilk) fear that adding unnecessary external references can result in a bit of...
  • Blog Post: Activate 'Full Screen Mode' During your Source Code Editing

    Okay, I admit this is a rather lame tip which can hardly qualify as 'insightful', however this is one of my favorite features of Visual Studio .NET (as well as previous editions of the Visual Studio product line) which many folks are (surprisingly) unaware of. Under the View menu you will find a menu...
  • Blog Post: Leverage the C# Preprocessor

    Like other languages in the C-family, C# supports a set of 'preprocessor' directives , most notably #define , #if and #endif (technically, csc.exe does not literally have a preprocessor as these symbols are resolved at the lexical analysis phase, but no need to split hairs…). The #define directive...
  • Blog Post: Avoiding Type Name-Clashes using 'using'

    You are already aware that the C# using keyword allows you to supply hints to the compiler regarding the fully qualified name of the types within a given *.cs file. However, what you may not know is that the using keyword also allows you to build aliases (very helpful for prevent name clashes). Assume...
  • Blog Post: Build 'Consistent' .NET assemblies with FxCop

    The term 'best practices' sends chills up the spines of many people. Reason being, what is 'best' for one is 'horrible' for another. However, if you are interested in ensuring that your custom .NET assemblies are in-sync with the coding guidelines proposed by Microsoft, you will want to obtain a freely...
  • Blog Post: Simplified Interface Implementation a la VS .NET 2003

    Another helpful feature of VS .NET 2003 has to do with the implementation of interface types. As you know, when a class or structure agrees to implement a given interface, it must implement all of the members. Assume you wish to support an interface containing six members. While you could type in the...
  • Blog Post: Simplified Event Handling a la VS .NET 2003

    Working with events under the .NET platform requires you to be aware of a number of details. For example, if you know the name of the event you wish to handle, you must then know the name of the related delegate type. Once you know that much, you must then be aware of the correct signature of the delegate...
  • Blog Post: Integrate ildasm.exe into VS .NET 2002

    VS .NET allows you to add any number of external tools to the Tools menu. One very helpful technique is to configure ildasm.exe to automatically load up the current assembly being compiled. While VS .NET 2003 sets this up automatically, VS .NET 2002 may update the Tools menu manually. To do so, activate...
  • Blog Post: Add Custom .NET Assemblies to the Add Reference Dialog

    As you most likely know by now, the Add References dialog of Visual Studio .NET does not list each and every assembly on your machine, does not directly map to the Global Assembly Cache and does not list your custom assemblies. Typically this limitation is addressed by manually navigating to the *.dll...
  • Blog Post: Leverage C# Response Files at the Command Line

    Although I'd bet most of you make use of VS .NET as opposed to the raw command line complier, csc.exe can be quite useful in a number of circumstances. However, few of us enjoy typing lengthy command line flags such as: csc /r: MyAsm.dll;MyOtherAsm.dll /t: winexe /out: myApp.exe *.cs To lessen...
  • Blog Post: Be Aware of wincv.exe

    When you install the .NET SDK / VS.NET, you are provided with numerous stand alone programming tools, one of which is named wincv.exe ( Windows Class Viewer ). Many developers are unaware of wincv.exe, as it is buried away under the C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin subdirectory...
  • Blog Post: Utilize the Server Explorer

    Visual Studio .NET provides a very interesting view of the world named the Server Explorer (which can be activated from the View menu). While you may already be aware many of these items can be opened within VS .NET for editing (for example, opening a database Table or editing a stored procedure), you...
  • Blog Post: Obtain Type Information on the Fly using typeof

    All .NET assemblies contain vivid type information which describes the structure of every internal and external type (this can be verified by loading an assembly into ildasm.exe and clicking the ctrl-m keystroke). On a related note, many methods in the .NET base class libraries require you to pass in...
  • Blog Post: Interacting with overloaded operators from overloaded operator challenged languages

    Like the C++ language, C# allows you to overload operators for your custom types. For example, assume you have a structure named MyPoint which has overloaded the plus operator. If this is the case, you can 'add' two MyPoints as so: // Add two MyPoint types to obtain a // 'bigger' Point. MyPoint...
Page 1 of 1 (17 items)