Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET 4.5
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Amazon Web Services
Analysis Services
Android
Architecture
Arduino
ASP .NET Web API
ASP.NET
ASP.NET MVC
ASP.NET WebForms
Azure
B2B (Business Integration)
BDD
Big Data
Bing
BizTalk
Book Excerpts
Build and Deploy
Business Intelligence
C#
C++
ClickOnce
Cloud Computing
Code Contracts
CODE Framework Info - non Technical
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Debugger
Design Patterns
Development Process
Display Technologies
Distributed Computing
Document Database
DotNetNuke
DSL
Dynamic Languages
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Git
Graphics
HTML 5
Internet Explorer 8.0
Interviews
IOS
iPhone
Iron Ruby
Java
Java Script
JavaScript
jQuery
JSON
Lightswitch
LINQ
Linux
LUA
Mac OS X
MDX
Messaging
Metro
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Dynamics
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
MsBuild
MVVM
MySQL
Network
NHibernate
node.js
NOSQL
Nuget
Object Oriented Development
Objective C
Odata
OLAP
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
PHP
Podcasts
Post Mortem
PowerPoint
Print/Output
Prism
Product News
Product Reviews
Project Management
Prolog
Python
Q&A
Rails
Rake
Razor
Reporting Services
REST
RIA Services
Ruby
Ruby on Rails
Scheme
Search
Security
Services
SharePoint
SignalR
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server 2012
SQL Server CE/AnyWhere/Mobile/Compact
SSIS
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
TFS
Tips
TypeScript
UI Design
UML
User Groups
VB Script
VB.NET
Version Control
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 11
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio 2011
Visual Studio 2012
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WebMatrix
WF
Whitepapers
Windows 7
Windows 8
Windows Azure
Windows Live
Windows Phone 7
Windows Phone SDK
Windows Server
Windows Vista
WinForms
WinRT
Workflow
WPF
XAML
Xiine Documentation
XML
XNA
XSLT



LearnNow


XAMALOT
 


SSWUG

Reader rating:
Article source: CoDe (2009 May/Jun)

Ask the Doc Detective


Doc Detective

Finding what you need in the Microsoft® Visual Studio® 2008 documentation, which has over 200,000 topics, can be a daunting task. The Doc Detective is here to help, utilizing his investigative skills to probe the depths of the documentation.

Can’t find what you’re looking for? Just ask-if it’s in there, I’ll find it for you; if it isn’t, I’ll let you know that as well (and tell you where else you might go to find it).

Have a question for the Doc? Send your questions for future columns to me at docdetec@microsoft.com.

Dear Doc Detective,

I was looking at the documentation for the Form.Dispose method and found the following statement: “Dispose will be called automatically if the form is shown using the Show method. If another method such as ShowDialog is used, or the form is never shown at all, you must call Dispose yourself within your application.”

This is a surprise to me. I had always been led to believe that Dispose is always called for a Form. It looks like if I don’t call Dispose after displaying a modal dialog, there will be a resource leak. Is the documentation wrong, or if not, can you please explain this behavior?

- Befuddled in Bellingham

Dear Befuddled,

In this case the documentation is correct, although apparently well-hidden. It is a best practice to call Dispose on modal forms when you are done with them.

Forms and the controls within them use unmanaged resources such as window handles which are a limited system resource. The garbage collector is good at cleaning up memory but not so good at cleaning up resources such as handles that are more precious than memory.

Modal forms were designed so that you could access state information such as text in a textbox or a dialog result after the form has closed. If Dispose was called automatically, there is no guarantee that the information will still be there when you try to access it.

- Doc D

Dear Doc Detective,

I’m trying to return a machine’s IP address, and I can’t seem to get it right. Every example I see uses code such as the following:

System.Net.Dns.GetHostEntry(My.Computer.Name).
 AddressList(0).ToString()

I’ve tried this, but the string I get back is something like “fe80::85f3:3dc2:42e6:eaa5%8”. The actual IP address isn’t returned until I reach the .AddressList(2) or .AddressList(3) element. What’s up with that?

- Listless in Livonia

Dear Listless,

The AddressList array can contain a different number of elements depending on factors such as whether the machine has multiple network cards or is using IP Version 4 or IP Version 6. It sounds like you are looking for the IP 4 address-you can get this by looping through the AddressList array and checking the AddressFamily value:

For Each ip In System.Net.Dns.GetHostEntry(
System.Net.Dns.GetHostName).AddressList
   If ip.AddressFamily = 
   Net.Sockets.AddressFamily.InterNetwork Then
      'only IP4
      Me.ComboBox1.Items.Add(ip)
   End If
Next

In this example, the AddressFamily enumeration InterNetwork represents the IP Version 4 address, as noted in the topic “AddressFamily Enumeration”. Try this, and you should get the right IP address.

- Doc Detective

Dear Doc Detective,

I’m a long-time Visual Basic programmer just getting started with Silverlight. When I try to reference the My namespace in a Silverlight app, I keep getting errors. Is the My namespace supported in Silverlight?

- Mystified in Mystic

Dear Mystified,

The My namespace which Visual Basic programmers have come to know and love is not supported in Silverlight. This is noted in the topic “Visual Basic Run-Time Support in Silverlight”.

What isn’t noted in the topic is the reason why. Silverlight apps run in a “sandbox” environment and are prevented from accessing local resources. Since most of the functions in the My namespace involve accessing local resources, and since Silverlight wanted to keep it’s runtime small... well, you get the picture. Hope that solves the mystery.

- The Doc

Dear Doc Detective,

I have a Label control of a fixed size. When we localize the application into other languages, the localized string is sometimes too long for the allotted space.

Our solution is to use the GetPreferredSize method to determine the length of the string, then add a “...” on the end of the string and display the full string in a ToolTip. I can’t figure out how do get just the displayed portion of the string and append the “..." onto it. Any ideas?

- Strung Out in Stroudsburg

Dear Strung,

Sometimes the answer is staring you right in the face. The Label control has a AutoEllipsis property that does exactly what you are looking for. Just set it to true and you’re done-isn’t it nice when you don’t have to write code?

- Doctor D

Doc’s Doc Tip of the Day

Every issue the Doc has admonished you to send your feedback on documentation that is incorrect or isn’t helpful. Ever wonder what happens when you actually do send feedback?

Every single comment that you send in, whether via the local or online links, is reviewed and passed on to the appropriate writer. Writers are responsible for following up on these and determining if the topic does indeed need to be fixed; in many cases they may contact you to get clarification.

Last year the process resulted in over 1500 topics that were corrected or improved based on your feedback. Once a topic has been updated, a “change table” entry is added to the bottom of the topic with “customer feedback” listed as the reason for the change.

I’ve said it before and I’ll say it again: Found a topic in Help that doesn’t help? Tell the Visual Studio documentation team about it by clicking on the “Send feedback” link in local Help topics, or the “Click to rate and give feedback” link in online Help.

URLs

http://msdn.microsoft.com/en-us/library/aw58wzka.aspx

http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.addressfamily.aspx

http://msdn.microsoft.com/en-us/library/system.net.sockets.addressfamily.aspx

http://msdn.microsoft.com/en-us/library/bb404714(VS.95).aspx

http://msdn.microsoft.com/en-us/library/system.windows.forms.label.autoellipsis.aspx


How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
4.3 out of 5

3 people have rated this article.

Instantly Search Terabytes Of Text
“Lightning Fast”
– Redmond Mag
“Covers all data
sources” – eWeek
25+ fielded & full-text search options
dtSearch’s own document filters highlight hits in popular file types
Web Spider supports static & dynamic data
APIs for .NET, Java, C++, SQL, etc.
Win / Linux (64-bit & 32-bit)
www.dtSearch.com
 

      Sharepoint TechCon

 

SSWUG