首页 \ 问答 \ 将bindingRedirect添加到.Net标准库(Adding a bindingRedirect to a .Net Standard library)

将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
更新时间:2024-04-24 20:04

最满意答案

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 ...
  • 使用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 ...
  • 您可以在Linux上使用ioctl (以及其他系统上的类似接口): #include size_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 ...
  • 假设4个字节始终可用是安全的 没有。 决不。 如果有人用telnet和键盘测试你的协议怎么办? 或者通过真正缓慢或繁忙的连接? 您可以一次接收一个字节, 也可以通过多个Receive()调用分割“长度指示符”。 这不是单元测试问题,它是导致生产问题的基本插座问题,尤其是在压力情况下。 或者我们应该继续尝试使用偏移变量获取4个字节? 是的你应该。 为方便起见,您可以使用Socket.Receive()重载,它允许您指定要读取的字节数,这样您就不会读太多。 但是请注意它可以返回少于所需的值,这是offset参数 ...
  • 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 ...

相关文章

更多

最新问答

更多
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • linux的常用命令干什么用的
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • Java中的不可变类(Immutable class in Java)
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • 绑定属性设置器未被调用(Bound Property Setter not getting Called)
  • linux ubuntu14.04版没有那个文件或目录
  • 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
  • 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
  • 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
  • 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
  • 如何按部门显示报告(How to display a report by Department wise)
  • Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
  • Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
  • WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)