Here's another goodie from the Visual Studio 2008 SDK. In
ProjectNode.CopyPaste.cs in the namespace Microsoft.VisualStudio.Package you'll find the following code snippet:
StringBuilder selectionContent = null;
// If there is a selection package the data
if (selectedNodes.Count > 1)
{
foreach (HierarchyNode node in selectedNodes)
{
selectionContent = node.PrepareSelectedNodesForClipBoard();
if (selectionContent != null)
{
sb.Append(selectionContent);
}
}
}
else if (selectedNodes.Count == 1)
{
HierarchyNode selectedNode = selectedNodes[0];
selectionContent = selectedNode.PrepareSelectedNodesForClipBoard();
if (selectionContent != null)
{
sb.Append(selectionContent);
}
}
Why do we need this if - else if construct? Does the foreach for a list with zero or one element not work?
Dienstag, 4. März 2008
Mittwoch, 30. Januar 2008
How to add a Wizard to a Visual Studio 2008 Project Template
Following the description in How to: Use Wizards with Project Templates I always got this "Error: this template attempted to load an untrusted component" error.
I added my assembly to the GAC and built it with a strong name. I finally found a solution to this problem. My-tag was missing processorArchitecture=msil part.
CustomWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=74329847392 didn't work, but
CustomWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=74329847392,processorArchitecture=MSIL did just fine.
I added my assembly to the GAC and built it with a strong name. I finally found a solution to this problem. My
Labels:
IWizard,
Templates,
Visual Studio 2008,
VsTemplate,
Wizards
Donnerstag, 17. Januar 2008
Visual Studio 2008 SDK Goodies #2
In ProjectOptions.cs in the Managed Package Framework of Visual Studio 2008 SDK you'll find funny field definitions, e.g.:
///must be an int if not null
public object CodePage;
Why don't they just define it as an int and define some value or exception indicating, that CodePage is not set?
///
public object CodePage;
Why don't they just define it as an int and define some value or exception indicating, that CodePage is not set?
Abonnieren
Posts (Atom)

