将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);

相关问答

更多

如何使用ZeroMQ将字节数组发送到套接字?(How to send byte array to socket using ZeroMQ?)

没有人会从阅读GPS航点列表中获得攀登珠穆朗玛峰的激情,无论是短期还是长期...... 因此,在没有事先了解基本概念的情况下, 不要阅读代码示例。 正确的方式 ZeroMQ的设计具有一定的格式 - 零阻塞 ,零共享 ,零拷贝 ,零代理,最小延迟 ,消息传递框架 。 人们应该把它视为一个框架,依靠建立一个快速,半持久的F ormal- S caleable- C ommunication- P attern Layer (不是一套耗材一次性用品) 虽然没有人可以限制你使用Msg和Frame的混合以及...

通过套接字java发送字节数组而不发送长度(Sending byte array through socket java without sending length)

我可以读取确切的号码。 我发送的字节数? 如果您发送任意字节而没有任何形式的编码,那么您需要发送一个长度(第一个),或者您需要在写入最后一个字节后关闭套接字流。 如果您可以对字节1进行编码,或者如果您保证某些字节永远不会出现,那么客户端可以在数组的最后一个字节之后发送一个特殊的“字节结束数组”标记。 AFAIK,没有其他可靠的解决方案2 。 1 - 例如,编码可以像将256个可能的字节值中的一个保留为“转义”字节一样简单,并且当您想要将其作为数据发送时使用两个转义来表示该值。 2 - 考虑这个“解...

如何指定使用Socket.SendToAsync()时要发送的字节数?(How to specify the number of bytes to send when using Socket.SendToAsync()?)

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: ...

UDP发送文件确切的字节数(UDP Send File Exact Number of Bytes)

根据sendto命令,UDP将发送与发送长度中指定的数据量相同的数据; 第三个参数是发送长度: http : //linux.die.net/man/2/sendto 。 示例是指定sizeof(缓冲区),因为发送长度和sizeof(缓冲区)是5000.因此,UDP从缓冲区(实际上是整个缓冲区)发送5000个字节。 如果我们想要发送文件中存在的确切字节数,那么我们应该读取文件中的字节数,并将其作为发送长度传递。 numbytes = sendto(sockfd, buffer, sizeof(bu...

Java TCP Socket发送字节数组(Java TCP Socket send byte array)

由对等体重置套接字意味着另一端不正确地断开。 检查您的客户端是否正确地保持插座打开。 编辑:假设你使用的代码看起来像这样,你不应该使用DataInputStream。 如果你想使用readByte来接收数据,你必须在发送端使用writeByte 。 您的套接字重置可能会发生,因为readByte调用没有得到它期望的SOMETHING。 不要使用DataInputStream:使用BufferedInputStream并使用read方法。 Socket reset by peer means the...

在python中使用字节(Work with bytes in python)

使用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 ...

是否可以读取为TCP写入套接字缓冲的字节数?(Is it possible to read the number of bytes buffered for a TCP write socket?)

您可以在Linux上使用ioctl (以及其他系统上的类似接口): #include <linux/sockios.h> 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_siz...

导致Socket.Receive返回的最小字节数是多少?(What is the minimum number of bytes that will cause Socket.Receive to return?)

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

需要通过Socket获得字节帮助(Need help on bytes via Socket)

Read对发送的内容一无所知; TCP基本上只是一个流 - 所以没有什么可以说你在一次调用Read拥有所有数据; 你可以有: 确切地说,您发送的数据量 一条消息的一部分 17条消息 一条消息的结束和下一条消息的开始 消息中的1个单独字节 您需要设计某种帧协议,让接收者知道他们何时拥有整个消息。 这可能像长度前缀一样简单,也可能更复杂。 然后,您应该将数据缓冲在内存中(或逐步处理),直到您拥有整个消息。 对Read一次调用不太可能代表单个完整的消息。 实际上,如果消息大于newstate.buffe...

如何将特定数量的字节写入/发送到套接字完全但不是部分?(how to write/send a specific number of bytes to a socket totally but not partially?)

如果您正在使用阻止模式,则永远不会出现这种情况:send()将阻塞,直到所有数据都已发送。 这不是文档读取的方式,但它是所有已知实现的行为方式。 如果你在谈论TCP,它无论如何都没有任何区别:它是一个字节 - 蒸汽协议,而不是数据报协议。 如果你在谈论UDP,它已经在非阻塞,颂歌和阻塞模式中表现为那样,参见(1)。 If you're using blocking mode, the condition can never arise: send() will block until all th...

相关文章

更多

Becoming a data scientist

Data Week: Becoming a data scientist Data Pointed, ...

Spring Data: a new perspective of data operations

Spring Data: a new perspective of data operations ...

A Great List of Windows Tools

Windowsis an extremely effective and a an efficient ...

[转]So You Want To Be A Producer

pro-du-cer n. 1. Someone from a game publisher who ...

《数据结构与STL》(Data Structures and the Standard Template Library)扫描版[PDF]

中文名: 数据结构与STL 原名: Data Structures and the Standa ...

Stack Overflow Architecture Update - Now At 95 Million Page Views A Month

A lot has happened since my first article on theSta ...

按钮样式

网页上有很多功能是通过链接方式传递参数,这种功能链接普通样式就是一个超链接退出,如果将超链接的样式变成 ...

Securing Solr on Tomcat access using a user account

Open [Tomcat install dir]\tomcat-users.xmlfor editi ...

Solr: a custom Search RequestHandler

As you know, I've been playing with Solr lately, tr ...

Drupal Forums instead of phpBB or vBulletin: A casestudy

5th Jan, 10 Drupal drupal advanced forum drupa ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本