Sockets question
-
Hello, I am using System.Net.Sockets in my app. I took some example code from MSDN for connecting a socket to a listening server, and I put it in an Windows Control (I believe same as ActiveX)... Unfortunately, the following exception is raised when I try to call: hostEntry = Dns.Resolve(server); The actual code could be found at MSDN. Exception: --------------------------- --------------------------- Exception Object Source:mscorlib Message:Request for the permission of type System.Net.DnsPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed. --------------------------- OK --------------------------- Another important fact is that I am trying to access the control through an HTML page. Help on this issue is greatly appreciated. "Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
-
Hello, I am using System.Net.Sockets in my app. I took some example code from MSDN for connecting a socket to a listening server, and I put it in an Windows Control (I believe same as ActiveX)... Unfortunately, the following exception is raised when I try to call: hostEntry = Dns.Resolve(server); The actual code could be found at MSDN. Exception: --------------------------- --------------------------- Exception Object Source:mscorlib Message:Request for the permission of type System.Net.DnsPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed. --------------------------- OK --------------------------- Another important fact is that I am trying to access the control through an HTML page. Help on this issue is greatly appreciated. "Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
Are you by any chance running your app from a link in a web browser?
-
Are you by any chance running your app from a link in a web browser?
Hello, Yes, I attempt to run my ActiveX control through a web page (with the html tag)... Hope it gives any clues to the problem. "Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
-
Hello, Yes, I attempt to run my ActiveX control through a web page (with the html tag)... Hope it gives any clues to the problem. "Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
You need to make sure you have a code group set up in the .NET Framework Configuration (the code access security groups) for your control. You should use Site or Url evidence (host evidence) that matches the site or url from where your control runs (the hosting page URL isn't a factory - only the URL of the control). You should make sure that the
DnsPermission
is granted, or just cop-out and grant that code group FullTrust permissions. .NET Code Access Security (CAS) is an important part of the .NET Framework. It's a much better sandbox than what you find in Java, and many, many times better than what's available for ActiveX. For a good article on .NET CAS, see Understanding .NET Code Access Security[^]. For more information, also see an old article of mine describing the entire process of hosting .NET controls in Internet Explorer, User Controls for Windows and the Web[^].Microsoft MVP, Visual C# My Articles