Hi All.
This test code:
using System.Net.Sock ets;
using System.Net;
using System;
class mail{
public static void Main(){
Console.WriteLi ne("** INIT **");
TcpClient tcp = new TcpClient();
try{
tcp.Connect("12 7.0.0.1", 9001 );
}catch( Exception e ){
Console.Write( e );
}
}
}
Generates the Exception you see below.
System.Security .SecurityExcept ion: Anmodningen om tilladelsen af typen
System.Ne
t.SocketPermiss ion, System, Version=1.0.500 0.0, Culture=neutral ,
PublicKeyToken=
b77a5c561934e08 9 mislykkedes.
at System.Net.Sock ets.TcpClient.C onnect(String hostname, Int32
port)
at mail.Main() in i:\CSharpDev\Ma il\main.cs:line
Does any one know why? As far as I have been able to figure out, it
has something to do whith the
C:\WINNT\Micros oft.NET\Framewo rk\v1.1.4322\ms corcfg settings, but no
matter what I try, I still get the same error.
Im running on win2000 and have administrators rigths to my machine. 6 4206
Kristian wrote: Hi All.
This test code:
using System.Net.Sock ets; using System.Net; using System;
class mail{ public static void Main(){ Console.WriteLi ne("** INIT **"); TcpClient tcp = new TcpClient(); try{ tcp.Connect("12 7.0.0.1", 9001 ); }catch( Exception e ){ Console.Write( e ); } } }
Generates the Exception you see below.
System.Security .SecurityExcept ion: Anmodningen om tilladelsen af typen System.Ne t.SocketPermiss ion, System, Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9 mislykkedes. at System.Net.Sock ets.TcpClient.C onnect(String hostname, Int32 port) at mail.Main() in i:\CSharpDev\Ma il\main.cs:line
Does any one know why? As far as I have been able to figure out, it has something to do whith the C:\WINNT\Micros oft.NET\Framewo rk\v1.1.4322\ms corcfg settings, but no matter what I try, I still get the same error.
Im running on win2000 and have administrators rigths to my machine.
The context in which this code is running does not have the right to
open a socket; are you executing this from a network share or from an
internet resource?
Although it doesn't elevate the privileges, it makes sense to mark your
application with the appropriate code access security attributes - this
means that the application will not start at all unless the
appropriate permissions are available for the application.
In the case of your code:
[assembly:Socket Permission(Secu rityAction.Requ estMinimum, Access =
"Connect", Host = "127.0.0.1" , Transport = "Tcp", Port = "9001")]
or
[assembly:Socket Permission(Secu rityAction.Requ estMinimum, Unrestricted =
true)]
--
Ed Courtenay
[MCP, MCSD] http://www.edcourtenay.co.uk
Kristian,
Are you running your code in ASP.NET by chance? If so, then by default,
code in ASP.NET runs under the ASPNET local account, which does not have
rights to the network. You will have to change the user that the page runs
under, or you will have to impersonate the user.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Kristian" <kr******@detan detfirma.dk> wrote in message
news:c9******** *************** ***@posting.goo gle.com... Hi All.
This test code:
using System.Net.Sock ets; using System.Net; using System;
class mail{ public static void Main(){ Console.WriteLi ne("** INIT **"); TcpClient tcp = new TcpClient(); try{ tcp.Connect("12 7.0.0.1", 9001 ); }catch( Exception e ){ Console.Write( e ); } } }
Generates the Exception you see below.
System.Security .SecurityExcept ion: Anmodningen om tilladelsen af typen System.Ne t.SocketPermiss ion, System, Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9 mislykkedes. at System.Net.Sock ets.TcpClient.C onnect(String hostname, Int32 port) at mail.Main() in i:\CSharpDev\Ma il\main.cs:line
Does any one know why? As far as I have been able to figure out, it has something to do whith the C:\WINNT\Micros oft.NET\Framewo rk\v1.1.4322\ms corcfg settings, but no matter what I try, I still get the same error.
Im running on win2000 and have administrators rigths to my machine.
Ed Courtenay <re************ *************** **@edcourtenay. co.uk> wrote in message news:<uv******* *******@TK2MSFT NGP12.phx.gbl>. .. Kristian wrote:
Hi All.
This test code:
using System.Net.Sock ets; using System.Net; using System;
class mail{ public static void Main(){ Console.WriteLi ne("** INIT **"); TcpClient tcp = new TcpClient(); try{ tcp.Connect("12 7.0.0.1", 9001 ); }catch( Exception e ){ Console.Write( e ); } } }
Generates the Exception you see below.
System.Security .SecurityExcept ion: Anmodningen om tilladelsen af typen System.Ne t.SocketPermiss ion, System, Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9 mislykkedes. at System.Net.Sock ets.TcpClient.C onnect(String hostname, Int32 port) at mail.Main() in i:\CSharpDev\Ma il\main.cs:line
Does any one know why? As far as I have been able to figure out, it has something to do whith the C:\WINNT\Micros oft.NET\Framewo rk\v1.1.4322\ms corcfg settings, but no matter what I try, I still get the same error.
Im running on win2000 and have administrators rigths to my machine.
The context in which this code is running does not have the right to open a socket; are you executing this from a network share or from an internet resource?
Although it doesn't elevate the privileges, it makes sense to mark your application with the appropriate code access security attributes - this means that the application will not start at all unless the appropriate permissions are available for the application.
In the case of your code:
[assembly:Socket Permission(Secu rityAction.Requ estMinimum, Access = "Connect", Host = "127.0.0.1" , Transport = "Tcp", Port = "9001")]
or
[assembly:Socket Permission(Secu rityAction.Requ estMinimum, Unrestricted = true)]
Hi Ed.
I tryed to move the .csc files from my dev drive and to my C: drive,
by doing this there was no exception thrown, so I guess your rigth, I
am running from a network share. Ill try to add the code you entered,
just to check what happens.
Thank you for your reply
/Kristian
Nicholas ,
Account privileges do not apply to (non raw)sockets.
Willy.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:Oo******** ******@TK2MSFTN GP12.phx.gbl... Kristian,
Are you running your code in ASP.NET by chance? If so, then by default, code in ASP.NET runs under the ASPNET local account, which does not have rights to the network. You will have to change the user that the page runs under, or you will have to impersonate the user.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Kristian" <kr******@detan detfirma.dk> wrote in message news:c9******** *************** ***@posting.goo gle.com... Hi All.
This test code:
using System.Net.Sock ets; using System.Net; using System;
class mail{ public static void Main(){ Console.WriteLi ne("** INIT **"); TcpClient tcp = new TcpClient(); try{ tcp.Connect("12 7.0.0.1", 9001 ); }catch( Exception e ){ Console.Write( e ); } } }
Generates the Exception you see below.
System.Security .SecurityExcept ion: Anmodningen om tilladelsen af typen System.Ne t.SocketPermiss ion, System, Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9 mislykkedes. at System.Net.Sock ets.TcpClient.C onnect(String hostname, Int32 port) at mail.Main() in i:\CSharpDev\Ma il\main.cs:line
Does any one know why? As far as I have been able to figure out, it has something to do whith the C:\WINNT\Micros oft.NET\Framewo rk\v1.1.4322\ms corcfg settings, but no matter what I try, I still get the same error.
Im running on win2000 and have administrators rigths to my machine.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert A. van Ginkel |
last post by:
I have a strange C# problem. Is the following a bug? Because it should be
possible to run unsafe code. How can I accomplish this? And where can I read
more about this, because documentation on this is rare.
I have a project where i need to use some internal calls. In this project I
have 'Allow unsafe code blocks' set to true.
And in my class i have:
extern private static IntPtr GetInvalidHandle();
|
by: Horst Walter |
last post by:
What is wrong here?
IPAddress ipAddress = IPAddress.Parse("10.10.20.1");
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, this.port);
this.tcpClient = new TcpClient(ipEndPoint); // PROBLEM HERE
=> Exception: "The requested address is not valid in its context"
This works:
|
by: Chua Wen Ching |
last post by:
Hi there,
I had applied this security permissions in my class library based on fxcop
standards.
Before namespace:
using System.Runtime.InteropServices;
using System.Security.Permissions;
|
by: Sagaert Johan |
last post by:
Hi
Ii have a simple server thread in an app that listens for connections, for
some unclear reason an exception is thrown
every now and then : 'A blocking operation was interrupted by a call to
WSACancelBlockingCall '
Any suggestion why this may happen ?
The Exception is thrown by the svr.AcceptTcpClient() method
See source below.
|
by: Diego F. |
last post by:
I think I'll never come across that error. It happens when running code from
a DLL that tries to write to disk. I added permissions in the project
folder, the wwwroot and in IIS to NETWORK_SERVICE and Everyone, with Full
Control to see if it's a permissions problem.
The project is hosted in a Windows 2003 Server and developed from PCs in a
domain, developing with Visual Studio 2005 Beta 1.
--
Regards,
| |
by: Rik |
last post by:
Hello Experts,
I have a communication server in VB.NET.
It was working fine from last 6 months, but now start giving error message
like that.
21-03-2005 07:58:27 DoListenSystem.Net.Sockets.SocketException: A blocking
operation was interrupted by a call to WSACancelBlockingCall
at System.Net.Sockets.Socket.Accept()
at System.Net.Sockets.TcpListener.AcceptTcpClient()
at ProjectCommServer.CommServer.DoListen()
|
by: anonymous_c |
last post by:
Hey guys. I'm creating a file transfer app. Anyways, I'm using this
code...
SERVER
<code>Dim Hostname As String = Dns.GetHostName
Dim IP As String =
Dns.GetHostByName(Hostname).AddressList(0).ToString
Public Sub RunServer()
Dim listener As TcpListener
|
by: Ryan Liu |
last post by:
Hi,
Why TcpClient has a method TcpClient.GetStream(), not just a read only
property?
By implementing it as a method, does that mean, each time GetStream() could
return a different stream? In other words, is that safe I only call
GetStream() once and set it to a class' variable and reuse it later?
And sometime I see TcpClient.GetStream() throws
|
by: keithseah |
last post by:
Hi all,
i've been having this problem and its kiiling me! i'm a newbie at this so i hope someone would be able to help me.
picture link: http://i98.photobucket.com/albums/l272/rachelyeo/ErrorWebApplication2.jpg
this pops up whenever i click on the Disconnect button after i have connected.
these are the following codes for the program.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |