将bindingRedirect添加到.Net标准库(Adding a bindingRedirect to a .Net Standard library)
我有一个.Net标准库,我在尝试使用其中一个依赖库时遇到错误,我认为这是一个版本冲突。 在旧式.Net类库中,我可能会添加如下内容:
<?xml version="1.0" encoding="utf-8"?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
但是,我显然不能在Net Standard库中这样做; 所以,我的问题是,在.Net标准世界中解决此类问题的策略是什么?
I have a .Net Standard library, and I'm getting an error when trying to use one of the dependant libraries, which I believe is down to a version conflict. In an old style .Net Class library, I might add something like this:
<?xml version="1.0" encoding="utf-8"?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
But, I obviously can't do that in a Net Standard library; so, my question is, what is the strategy for addressing such issues in the .Net Standard world?
原文:https://stackoverflow.com/questions/46111749
最满意答案
UDP协议将始终在一个数据包中发送所有数据。 如果要发送不基于数据的包大小,则需要使用TCP。
You can use the SetBuffer() overload where you do not have to pass a byte[] buffer - just adjust the existing index and count to be used - then after the operation set count back to it's original value:
mySocketAsyncEventArgs.SetBuffer(mySocketAsyncEventArgs.Offset, numOfBytesWritten); mySocket.SendToAsync(mySocketAsyncEventArgs); ... mySocketAsyncEventArgs.SetBuffer(mySocketAsyncEventArgs.Offset, originalBufferSize);
相关问答
更多-
没有人会从阅读GPS航点列表中获得攀登珠穆朗玛峰的激情,无论是短期还是长期...... 因此,在没有事先了解基本概念的情况下, 不要阅读代码示例。 正确的方式 ZeroMQ的设计具有一定的格式 - 零阻塞 ,零共享 ,零拷贝 ,零代理,最小延迟 ,消息传递框架 。 人们应该把它视为一个框架,依靠建立一个快速,半持久的F ormal- S caleable- C ommunication- P attern Layer (不是一套耗材一次性用品) 虽然没有人可以限制你使用Msg和Frame的混合以及消息套接字 ...
-
我可以读取确切的号码。 我发送的字节数? 如果您发送任意字节而没有任何形式的编码,那么您需要发送一个长度(第一个),或者您需要在写入最后一个字节后关闭套接字流。 如果您可以对字节1进行编码,或者如果您保证某些字节永远不会出现,那么客户端可以在数组的最后一个字节之后发送一个特殊的“字节结束数组”标记。 AFAIK,没有其他可靠的解决方案2 。 1 - 例如,编码可以像将256个可能的字节值中的一个保留为“转义”字节一样简单,并且当您想要将其作为数据发送时使用两个转义来表示该值。 2 - 考虑这个“解决方案”。 ...
-
UDP协议将始终在一个数据包中发送所有数据。 如果要发送不基于数据的包大小,则需要使用TCP。 You can use the SetBuffer() overload where you do not have to pass a byte[] buffer - just adjust the existing index and count to be used - then after the operation set count back to it's original value: mySoc ...
-
根据sendto命令,UDP将发送与发送长度中指定的数据量相同的数据; 第三个参数是发送长度: http : //linux.die.net/man/2/sendto 。 示例是指定sizeof(缓冲区),因为发送长度和sizeof(缓冲区)是5000.因此,UDP从缓冲区(实际上是整个缓冲区)发送5000个字节。 如果我们想要发送文件中存在的确切字节数,那么我们应该读取文件中的字节数,并将其作为发送长度传递。 numbytes = sendto(sockfd, buffer, sizeof(buffer) ...
-
由对等体重置套接字意味着另一端不正确地断开。 检查您的客户端是否正确地保持插座打开。 编辑:假设你使用的代码看起来像这样,你不应该使用DataInputStream。 如果你想使用readByte来接收数据,你必须在发送端使用writeByte 。 您的套接字重置可能会发生,因为readByte调用没有得到它期望的SOMETHING。 不要使用DataInputStream:使用BufferedInputStream并使用read方法。 Socket reset by peer means the othe ...
-
在python中使用字节(Work with bytes in python)[2022-12-09]
使用struct模块 : >>> import struct >>> id, first, second = 5, 42, 58 >>> struct.pack('>bhb', id, first, second) b'\x05\x00*:' 你可能想知道你的数据是否是小数或大数,以及b)是有符号还是无符号的; 上面的例子使用了big-endian排序和签名值。 结果(在python 3中)是一个bytes对象。 Use the struct module: >>> import struct >>> i ... -
是否可以读取为TCP写入套接字缓冲的字节数?(Is it possible to read the number of bytes buffered for a TCP write socket?)[2021-10-02]
您可以在Linux上使用ioctl (以及其他系统上的类似接口): #includesize_t sb_sz = sizeof(sock_buffer_size); ioctl(sock, SIOCOUTQ, &bytes_in_queue); getsockopt(sock, SOL_SOCKET, SO_SNDBUF, &sock_buffer_size, &sb_sz); size_t bytes_available = sock_buffer_size - b ... -
导致Socket.Receive返回的最小字节数是多少?(What is the minimum number of bytes that will cause Socket.Receive to return?)[2023-05-27]
假设4个字节始终可用是安全的 没有。 决不。 如果有人用telnet和键盘测试你的协议怎么办? 或者通过真正缓慢或繁忙的连接? 您可以一次接收一个字节, 也可以通过多个Receive()调用分割“长度指示符”。 这不是单元测试问题,它是导致生产问题的基本插座问题,尤其是在压力情况下。 或者我们应该继续尝试使用偏移变量获取4个字节? 是的你应该。 为方便起见,您可以使用Socket.Receive()重载,它允许您指定要读取的字节数,这样您就不会读太多。 但是请注意它可以返回少于所需的值,这是offset参数 ... -
需要通过Socket获得字节帮助(Need help on bytes via Socket)[2023-07-09]
Read对发送的内容一无所知; TCP基本上只是一个流 - 所以没有什么可以说你在一次调用Read拥有所有数据; 你可以有: 确切地说,您发送的数据量 一条消息的一部分 17条消息 一条消息的结束和下一条消息的开始 消息中的1个单独字节 您需要设计某种帧协议,让接收者知道他们何时拥有整个消息。 这可能像长度前缀一样简单,也可能更复杂。 然后,您应该将数据缓冲在内存中(或逐步处理),直到您拥有整个消息。 对Read一次调用不太可能代表单个完整的消息。 实际上,如果消息大于newstate.buffer ,则保 ... -
如果您正在使用阻止模式,则永远不会出现这种情况:send()将阻塞,直到所有数据都已发送。 这不是文档读取的方式,但它是所有已知实现的行为方式。 如果你在谈论TCP,它无论如何都没有任何区别:它是一个字节 - 蒸汽协议,而不是数据报协议。 如果你在谈论UDP,它已经在非阻塞,颂歌和阻塞模式中表现为那样,参见(1)。 If you're using blocking mode, the condition can never arise: send() will block until all the dat ...