-
April 14th, 2007, 12:30 AM
#1
[Resolved, Sort of] Enabling IPv6 within Visual Studio .NET 2.0
Hi people,
I've got this slight problem that I am pulling my hair out about.
I've installed the IPv6 protocol on my Windows XP SP2 computer and cannot get Visual Studio to recognise that is in fact operational. I know it is operational because when I run "ipconfig" from the command line I get a pretty IPv6 address as well as my standard IPv4 address.
Using the following VB code I get a window saying "disabled"...
Code:
Dim test As New Ipv6Element() 'In System.Net.Configuration
If test.Enabled = True Then
MsgBox("Enabled")
Else
MsgBox("Disabled")
End If
The msdn documentation on IPv6 contradicts itself in several places, sometimes it says IPv6 is disabled by default in other places it says it is enabled by default. I have also actually enabled it in the machine.config file, even though some documentation says this isn't nessesary with 2005. So what is the go?
Last edited by ^Johnny2Bad; April 20th, 2007 at 09:17 AM.
Reason: Flagging as resolved
-
April 19th, 2007, 09:22 PM
#2
Re: Enabling IPv6 within Visual Studio .NET 2.0
Okay after getting really frustrated with this fault I have rebuilt my machine.
Visual Studio 2003 .NET running the 1.1 framework does pick up an Ipv6 address in it, however it seems erroneous; "::1". It does not match any of the Ipv6 addresses listed by ipconfig.
When I ran Visual Studio .NET 2005 the original error occurs, where it continously claims that Ipv6 is NOT enabled. And this is with machine.config changed with <ipv6 enabled=true>. I also added a .cmd file that executes at machine startup (this is documented withint visual stidio 2003 help) which is the following...
Code:
net start tcpip6
Ipv6 install
Ipsec6 L c:\windows\ipv6\database
That is supposed to get ipv6 running correctly.
Perhaps it could be that the ipv6 addresses that ipconfig lists are all loopback or ipv6 addresses that are really ipv4 addresses but in an ipv6 format.
My .net Server 2003 R1 certainly doesn't assign this machine ipv6 addresses, but I am going to look further into this. And just to rub salt in the wound when I queried my ISP about whether their routers support ipv6 they replied with, "this infortmation is not available". A simple yes or no would have been prefered, rather than leaving me thinking they simply do not know which leads me to believe that they probably dont support ipv6 at all.
Anyway if anyone has an idea why I'm getting this problem could you please help!
Regards,
Jonathan.
-
April 20th, 2007, 04:04 AM
#3
Re: Enabling IPv6 within Visual Studio .NET 2.0
Okay,
Here's the problem, in the original code...
Code:
Dim test As New Ipv6Element() 'In System.Net.Configuration
If test.Enabled = True Then
MsgBox("Enabled")
Else
MsgBox("Disabled")
End If
As I am creating a "New" IPv6Element, the Enabled property defaults to false. This Object should be used to read from the machine.config file or saved within the machine.config file. So the correct way to get whether IPv6 is installed is with the following code...
Code:
Dim IPv6 As Ipv6Element
Dim Config As Configuration
Dim Group As ConfigurationSectionGroup
Dim Section As ConfigurationSection
Dim Element As ElementInformation
Dim Value As PropertyInformation
Config = ConfigurationManager.OpenMachineConfiguration()
Group = Config.GetSectionGroup("system.net")
Section = Group.Sections("settings")
Element = Section.ElementInformation()
Value = Element.Properties("ipv6")
IPv6 = Value.Value()
If IPv6.Enabled() Then
MsgBox("Enabled")
Else
MsgBox("Disabled")
End If
There is probably an easier way to do it, but as I am new to playing with XML files that's the best I could do at the moment.
The critical information that I missed in the documentation about fetching IP addresses is this...
"When an empty string is passed as the host name, this method returns the IPv4 addresses of the local host for all operating systems except Windows Server 2003; for Windows Server 2003, both IPv4 and IPv6 addresses for the local host are returned." - Visual Studio 2005 help for Dns.GetHostEntry.
Naturally I am developing on a windows XP box so I was only getting IPv4 addresses. Rather than use Dns.GetHostEntry with an empty string I used My.Computer.Name() to get the computers name and then pass the resulting string to GetHostEntry.
The following code illustrates a better way to do it...
Code:
Dim ThisPC As New IPHostEntry 'IP host is the computer this code is running on
Dim Addr As IPAddress 'Address being examined
Dim szName As String 'Name of this computer
Dim szType As String 'String of protocol type
Dim szAddr As String 'Address as string
Dim lvItem As New ListViewItem 'listview item
szName = My.Computer.Name()
ThisPC = Dns.GetHostEntry(szName) 'get host entry from computer name
For Each Addr In ThisPC.AddressList 'go through each address in this PC
'Create string of address type
Select Case Addr.AddressFamily
Case Sockets.AddressFamily.InterNetwork
szType = "IPv4"
Case Sockets.AddressFamily.InterNetworkV6
szType = "IPv6"
Case Else
szType = "Not TCP/IP"
End Select
szAddr = Addr.ToString() 'get Address in Type format
lvItem = New ListViewItem() 'create new list view item
'Set listview data
lvItem.Text = szAddr
lvItem.SubItems.Add(szType)
lvAddrs.Items.Add(lvItem) 'add listview item to listview
Next
The above code assumes you have a listview control called "lvAddrs" within a form with two columns, Address and Type respectively.
The code does work, with a catch the only IPv6 address returned is ::1. I think I will start a new thread for this particular issue after I have done further investigation.
Cheers,
Jonathan.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|