小编Jas*_*idi的帖子

关闭套接字,然后从.net中的同一端口重新打开它

好吧,我想知道是否有人可以帮助解决我遇到的问题....

我想关闭一个套接字,然后从同一个端口重新运行.这就是我在做的......

开盘:

    UdpServer = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
    UdpServerIpEndPoint = new IPEndPoint(IPAddress.Any, 9050);
    UdpEndPoint = (EndPoint)UdpServerIpEndPoint;
    UdpServer.Bind(UdpServerIpEndPoint);
Run Code Online (Sandbox Code Playgroud)

closeing:

        UdpServer.Shutdown(SocketShutdown.Both);
        UdpServer.Disconnect(true);
        UdpServer.Close();
Run Code Online (Sandbox Code Playgroud)

我关闭它之后.并且我尝试使用与上面相同的代码重新连接它,我收到错误:

附加信息:通常只允许使用每个套接字地址(协议/网络地址/端口)

我关闭期间检查异常,但我没有得到任何,我猜他们是正确关闭,所以实际上,是什么原因造成这个问题?请帮忙!

.net c# sockets

8
推荐指数
2
解决办法
1万
查看次数

SQL CLR执行错误

我正在使用visual studio 2012和MS SQL Server 2012.我创建了SQL CLR项目,并按照以下链接执行了以下步骤 :http://blogs.interfacett.com/how-create-net-stored-procedure-sql-server

现在,当我在附加触发器的表中插入数据时,会插入数据,但是我收到以下错误." 请求类型'System.Net.WebPermission,System,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的权限失败. "

谁能告诉我,我怎么能解决它?

提前致谢.

.net sql sql-server clr sqlclr

3
推荐指数
1
解决办法
4414
查看次数

收集被修改; 枚举操作可能无法执行.C#

我需要帮助.我正在和一个arraylist一起工作,突然间我得到了这个错误.

mscorlib.dll中发生了未处理的"System.InvalidOperationException"类型异常

附加信息:收集已修改; 枚举操作可能无法执行.

这是显示异常的代码...

foreach (PC_list x in onlinelist) {
  if ((nowtime.Subtract(x.time)).TotalSeconds > 5) {
    Invoke(new MethodInvoker(delegate {
      index = Main_ListBox.FindString(x.PcName);
      if(index != ListBox.NoMatches)
      Main_ListBox.Items.RemoveAt(index);
    }));
    onlinelist.Remove(x);
    //Thread.Sleep(500);
  }
}
Run Code Online (Sandbox Code Playgroud)

哪里

public class PC_list {
    public string PcName;
    public string ip;
    public string status;
    public string NickName;
    public DateTime time;

}
Run Code Online (Sandbox Code Playgroud)

笔记:

  • 在线列表是一个arraylist
  • nowtime和x.time是DateTime.

调用堆栈

mscorlib.dll!System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext() + 0x122 bytes    
BlueBall.exe!BlueBall.BlueBall.clean_arraylist() Line 74 + 0x1a8 bytes  C#
BlueBall.exe!BlueBall.BlueBall.server() Line 61 + 0x8 bytes C#
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x63 bytes   
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext …
Run Code Online (Sandbox Code Playgroud)

.net c# multithreading invoke

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

.net ×3

c# ×2

clr ×1

invoke ×1

multithreading ×1

sockets ×1

sql ×1

sql-server ×1

sqlclr ×1