[Help].net framework

Posts 1–15 of 15 · Page 1 of 1
[Help].net framework
Ok so my friend who has .Net framework 4.0 gets an error every time he runs an application of mine that connects to the internet (i am on .net 3.5) would this be caused by the .net framework difference? and if it is how would i fix it? and also if i code a project in VB2010 on .net 4.0 will people with .net 3.5 be able to run it? Thanks & Rep for best answer
No, .NET 4 will be able to run .NET 3.5.

If you compile the application using .NET 4.0 you are going to need it.

You can change that setting in 2010 by Solution Explorer > My Project > Compile > Advanced Compile Options > Target Framework.
Quote Originally Posted by khaozizleet View Post
No, .NET 4 will be able to run .NET 3.5.

If you compile the application using .NET 4.0 you are going to need it.

You can change that setting in 2010 by Solution Explorer > My Project > Compile > Advanced Compile Options > Target Framework.
Hmm, everytime he runs it it gives him an error saying it cannot connect to the server yet on other peoples PC's who don't have V 4 installed it runs fine
It could be a firewall that's preventing your program accessing the internet?
I think he may need to repair his .NET installation. .NET 4.0 will not cause this problem. Plus, if he has firewall, windows will ask for the permission it self to allow or deny that application. If not, you can always use the following code on form's load event to make sure windows adds it automatically or atleast ask for it:

[php]
Public Sub ActivateFirewall()
Dim actFW As INetFwProfile
actFW = GetProfile()
actFW.FirewallEnabled = True
End Sub

Public Function GetProfile() As NetFwTypeLib.INetFwProfile
Dim oINetPolicy As NetFwTypeLib.INetFwPolicy
Dim oINetFwMgr As NetFwTypeLib.INetFwMgr
oINetFwMgr = GetFwMgr()
oINetPolicy = oINetFwMgr.LocalPolicy
Return oINetPolicy.CurrentProfile
End Function

Sub AddToFireWall()
Dim appType As Type = Type.GetTypeFromProgID("HnetCfg.FwAuthorizedApplic ation")
Dim app As INetFwAuthorizedApplication
app = DirectCast(Activator.CreateInstance(appType), INetFwAuthorizedApplication)
app.Name = "MPGHLC - MainWin"
app.ProcessImageFileName = Application.ExecutablePath
app.Scope = NET_FW_SCOPE_.NET_FW_SCOPE_ALL
app.Enabled = True
Dim apps As INetFwAuthorizedApplications
Dim fwMgrType As Type = Type.GetTypeFromProgID("HnetCfg.FwMgr")
Dim fwMgr As INetFwMgr
fwMgr = DirectCast(Activator.CreateInstance(fwMgrType), INetFwMgr)
apps = fwMgr.LocalPolicy.CurrentProfile.AuthorizedApplica tions
apps.Add(app)
End Sub[/php]
To make this code work, you need to add reference to "NetFwTypeLib" library that comes with every version of Windows. It is located in:

Code:
"C:\windows\system32\Hnetcfg.dll"
First call the ActivateFirewall method, then call AddToFirewall.

I recommend you add this to your application, so it will allow your application to connect to internet automatically. I used it in two of my recent applications and it worked great. Also, ask your friend to repair his installation at the first place.
Quote Originally Posted by Hassan View Post
I think he may need to repair his .NET installation. .NET 4.0 will not cause this problem. Plus, if he has firewall, windows will ask for the permission it self to allow or deny that application. If not, you can always use the following code on form's load event to make sure windows adds it automatically or atleast ask for it:

[php]
Public Sub ActivateFirewall()
Dim actFW As INetFwProfile
actFW = GetProfile()
actFW.FirewallEnabled = True
End Sub

Public Function GetProfile() As NetFwTypeLib.INetFwProfile
Dim oINetPolicy As NetFwTypeLib.INetFwPolicy
Dim oINetFwMgr As NetFwTypeLib.INetFwMgr
oINetFwMgr = GetFwMgr()
oINetPolicy = oINetFwMgr.LocalPolicy
Return oINetPolicy.CurrentProfile
End Function

Sub AddToFireWall()
Dim appType As Type = Type.GetTypeFromProgID("HnetCfg.FwAuthorizedApplic ation")
Dim app As INetFwAuthorizedApplication
app = DirectCast(Activator.CreateInstance(appType), INetFwAuthorizedApplication)
app.Name = "MPGHLC - MainWin"
app.ProcessImageFileName = Application.ExecutablePath
app.Scope = NET_FW_SCOPE_.NET_FW_SCOPE_ALL
app.Enabled = True
Dim apps As INetFwAuthorizedApplications
Dim fwMgrType As Type = Type.GetTypeFromProgID("HnetCfg.FwMgr")
Dim fwMgr As INetFwMgr
fwMgr = DirectCast(Activator.CreateInstance(fwMgrType), INetFwMgr)
apps = fwMgr.LocalPolicy.CurrentProfile.AuthorizedApplica tions
apps.Add(app)
End Sub[/php]
To make this code work, you need to add reference to "NetFwTypeLib" library that comes with every version of Windows. It is located in:

Code:
"C:\windows\system32\Hnetcfg.dll"
First call the ActivateFirewall method, then call AddToFirewall.

I recommend you add this to your application, so it will allow your application to connect to internet automatically. I used it in two of my recent applications and it worked great. Also, ask your friend to repair his installation at the first place.
Asumming that they use Windows Firewall right?
Quote Originally Posted by master131 View Post
Asumming that they use Windows Firewall right?
Yes, but you can do it with any other Firewall provided they provide API (which mostly do). Or if you're not using firewall in your OS, your router might block the connection which is solved using UPNP framework.
He turned off windows firewall but hes not exactly PC savy so he may be running an antivirus firewall
Ill tell him to reinstall 4.0 as well and the error is only when accessing the internet
What exact error is he getting?
Quote Originally Posted by Blubb1337 View Post
What exact error is he getting?
It just says "Unable to access the remote server", the program attempts to download a text file...it woks fine for every1 else
Quote Originally Posted by Bombsaway707 View Post

It just says "Unable to access the remote server", the program attempts to download a text file...it woks fine for every1 else
What's your current download method? Perhaps we can provide an alternate method that is compatible with his computer.
Quote Originally Posted by Jason View Post


What's your current download method? Perhaps we can provide an alternate method that is compatible with his computer.
Code:
Dim PW As String
        PW = "http://***************.net/************/Authorizedusers.txt"
        Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(PW)
        Dim response As System.Net.HttpWebResponse = request.GetResponse()
        Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream(), System.Text.Encoding.GetEncoding("windows-1252"))
        Dim PWFILE As String
        PWFILE = sr.ReadToEnd()
        TextBox1.Text = PWFILE
Starred out the website name as to not be advertising
I think hassan has it, disable windows firewall, and any antiviruses, see if that works, or add your application the the exceptions for both.

Target Framework is always + - , in meaning, 1.0 compiled application will work on 1, 2, 3, 4, etc. However, there is some code that becomes obsolete, but VB will warn you.

IE, some code may work on 3.5 , but has become obsolete in 4.0. Though I highly doubt you have hit those few parts that have.
There are a few possibilities - I highly doubt its the (awesome) .NET framework
- Firewall blocking outgoing traffic
- Server issue (I know some hosts block certain IP ranges and countries)
- ISP-level filtering

Most likely the first two.

to confirm, try downloading the Google homepage or something.
Quote Originally Posted by freedompeace View Post
There are a few possibilities - I highly doubt its the (awesome) .NET framework
- Firewall blocking outgoing traffic
- Server issue (I know some hosts block certain IP ranges and countries)
- ISP-level filtering

Most likely the first two.

to confirm, try downloading the Google homepage or something.
Alright thanks man, ill have him try that
Posts 1–15 of 15 · Page 1 of 1
This thread is closed for replies.
Talk with us