Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Virtual PC

Vista - .NET Code to find the IP of the Virtual PC at runtime

Reply
 
Old 05-11-2009   #1 (permalink)
skyW


 
 

.NET Code to find the IP of the Virtual PC at runtime

Hi,

Can one use the .net namespace System.net to find the Ip of the Virtual PC
running windows server 2003 on host xp pro.

The code I am running for a custom web part fails at runtime . I have tried
both Shared (NAT) and "host Ethernet card" option of network adapter.

Thanks




My System SpecsSystem Spec
Old 05-11-2009   #2 (permalink)
Jakob Bohm


 
 

Re: .NET Code to find the IP of the Virtual PC at runtime

skyW wrote:
Quote:

> Hi,
>
> Can one use the .net namespace System.net to find the Ip of the VirtualPC
> running windows server 2003 on host xp pro.
>
> The code I am running for a custom web part fails at runtime . I have tried
> both Shared (NAT) and "host Ethernet card" option of network adapter.
>
> Thanks
>
>
>
If your .NET code is running inside the Virtual PC, any .NET function to
detect the "computers" own IP address should return the IP address(es)
(if any) used by the Virtual PC.

If your .NET code is running outside the Virtual PC, the only ways I can
think of to detect the IP address of the Virtual PC are:

a) Talk to a software interface exposed by the Virtual PC software
itself for this purpose.
b) Use network techniques to discover the IP address of the "remote"
computer which is the Virtual PC, for instance you could look up the IP
address for its computer name.
c) Use a software interface exposed by the Virtual PC software itself
to determine the MAC address of the simulated network adapter in the
Virtual PC, then use the arp command (or its .NET API equivalent) to
determine the IP address associated with that "remote" network card.
d) Run a command or program inside the Virtual PC which communicates
its IP address to your .NET code outside the Virtual PC. This could be
as simple as sending a single UDP packet (containing some magic value)
to a port on the Host PC where your .NET code is listening for incoming
packets, comparing the contents with the magic value and checking the IP
return address of the packet if ok.
e) Use Virtual PC folder sharing to give the Virtual PC write access
to a folder on the Host PC, then inside the Virtual PC run a command
which reports its IP address to a file in the shared folder. (This is
really a crude variation of method d).

For each of these methods make sure to protect yourself from all the
ways in which malicious code in another Virtual or real PC could try to
provide you with the wrong address!

--
Jakob Bøhm, M.Sc.Eng. * jb@xxxxxx * direct tel:+45-45-90-25-33
Netop Solutions A/S * Bregnerodvej 127 * DK-3460 Birkerod * DENMARK
http://www.netop.com * tel:+45-45-90-25-25 * fax:+45-45-90-25-26
Information in this mail is hasty, not binding and may not be right.
Information in this posting may not be the official position of Netop
Solutions A/S, only the personal opinions of the author.

My System SpecsSystem Spec
Old 05-11-2009   #3 (permalink)
Mark Rae [MVP]


 
 

Re: .NET Code to find the IP of the Virtual PC at runtime

"skyW" <skyW@xxxxxx> wrote in message
news:64DA14F5-FE8C-4F34-9179-A7C6EAD2C2A4@xxxxxx
Quote:

> Can one use the .net namespace System.net to find the IP of the Virtual PC
> running Windows Server 2003 on host XP Pro.
Yes, but you're in the wrong newsgroup. The fact that you're trying to find
the IP address of a virtual machine instead of a physical machine is
completely irrelevant...
Quote:

> The code I am running for a custom web part fails at runtime . I have
> tried
> both Shared (NAT) and "host Ethernet card" option of network adapter.
Please post your question in microsoft.public.dotnet.languages.csharp, and
remember to include the code that you're trying to use, otherwise no-one
will be able to help you fix it...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

My System SpecsSystem Spec
Old 05-12-2009   #4 (permalink)
skyW


 
 

Re: .NET Code to find the IP of the Virtual PC at runtime

Exactly.

"Mark Rae [MVP]" wrote:
Quote:

> "skyW" <skyW@xxxxxx> wrote in message
> news:64DA14F5-FE8C-4F34-9179-A7C6EAD2C2A4@xxxxxx
>
Quote:

> > Can one use the .net namespace System.net to find the IP of the Virtual PC
> > running Windows Server 2003 on host XP Pro.
>
> Yes, but you're in the wrong newsgroup. The fact that you're trying to find
> the IP address of a virtual machine instead of a physical machine is
> completely irrelevant...
>
Quote:

> > The code I am running for a custom web part fails at runtime . I have
> > tried
> > both Shared (NAT) and "host Ethernet card" option of network adapter.
>
> Please post your question in microsoft.public.dotnet.languages.csharp, and
> remember to include the code that you're trying to use, otherwise no-one
> will be able to help you fix it...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
pure virtual function call runtime error General Discussion
Trying to improve "find nearest DC in domain" code PowerShell
Microsoft Visual C++ Runtime Library box with Runtime Error Vista General
Microsoft Visual C++ Runtime Library ...Runtime Error Vista mail
Installation Error: Visual C++ Runtime Linrary Runtime Error Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46