Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8141715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:36:15+00:00 2026-06-06T12:36:15+00:00

I have a class that uses My.Computer.Network.Ping to get a boolean value on whether

  • 0

I have a class that uses My.Computer.Network.Ping to get a boolean value on whether a IP address or hostname is reachable.

However, when I’m testing that class, I want to disable pinging so that during the test whenever I run the My.Computer.Network.Ping it will always return false or throw some kind of exception.

I have tried the following, but I still get a true returned (meaning, the attempts to disable ping didn’t work)

Dim restricited As New System.Net.NetworkInformation.NetworkInformationPermission(System.Security.Permissions.PermissionState.None)
    Dim mySocketPermission1 As New SocketPermission(PermissionState.None)
    Dim myWebPermission As New WebPermission(PermissionState.None)
    myWebPermission.Demand()
    mySocketPermission1.Demand()
    Dim ping As New PingOptions()
    ping.DontFragment = True
    ping.Ttl = 1

*attempt to ping here*
*but doesn't return the "ping failed" I wanted*

Any ideas?
Edit: ‘m using VS2010 with .Net 4.0 Framework (full)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T12:36:17+00:00Added an answer on June 6, 2026 at 12:36 pm

    You could also try to modify the hosts file (assuming you are using host names and not IP addresses) but this seems to be a rather ugly approach… – Paul B. Jun 9 at 15:02

    Paul B’s answer did it for me. I’m testing on Win7 and XP, but XP seems to be fussy when using the host file method. Works fine on Win7.

    Paul is the man.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that uses XStream and is used as a transfer format
i have a class that uses a proxy class inside to call a service
I have a class that uses org.apache.ant and the class is very simple, it's
I have a class that uses priority queue to display 5 strings in ascending
I have a custom class that uses boost mutexes and locks like this (only
I have a model class that uses a custom validator as shown in following
I have created a button CSS class that uses background images with different positions
Let's say that I have class , that uses some functionality of dict .
I'm working on someone's code and they have a constructor that uses: class qwerty
I have a POJO that uses a service to do something: public class PlainOldJavaObject

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.