有人为Web Links HTTP"Link"标题创建了一个开源C#解析器吗?见:
http://tools.ietf.org/html/rfc5988.
例:
Link: <http://example.com/TheBook/chapter2>; rel="previous"; title="previous chapter"
Run Code Online (Sandbox Code Playgroud)
谢谢.
更新:结束创建我自己的解析器:https://github.com/JornWildt/Ramone/blob/master/Ramone/Utility/WebLinkParser.cs.随意使用它.
我有一个基于ASP.NET(使用.asmx)文件的旧web服务构建.我需要使用sodium.net - 不幸的是它在加载依赖的libsodium.dll文件时失败了.关于我犯错的任何想法?
我通过NuGet添加了libsodium.net.
我已将64位DLL重命名为"libsodium.dll"(以及其他命名约定).
我试图直接引用libsodium.dll,但VS拒绝它(不是有效的DLL).所以我把它添加为"内容"而不是"复制到输出".
构建后我可以看到网站/ Bin文件夹包含sodium.dll(.NET程序集)和libsodium.net.
当我尝试使用libsodium.net时,我得到:
ERROR 2015-02-02 11:14:27,118 13798ms [41] CabinetService doRequest - Caught:'Sodium.SodiumCore'的类型初始化程序引发异常.System.TypeInitializationException:'Sodium.SodiumCore'的类型初始值设定项引发了异常.---> System.DllNotFoundException:无法加载DLL'libsodium.dll':找不到指定的模块.(来自HRESULT的异常:0x8007007E)位于Sodium.SodiumCore..cctor()的DynamicDllInvokeType.sodium_init()---内部异常堆栈跟踪结束---位于Sodium.SSecretBox.Create(Byte)的Sodium.SodiumCore.LibraryName() []消息,Byte [] nonce,Byte []键)在Macaroons.SecretBoxCryptoAlgorithm.Encrypt(Byte []键,Byte [] plainText)中的c:\ Projects\Macaroons.Net\Macaroons.Net\SecretBoxCryptoAlgorithm.cs:line 58
所以它找不到"libsodium.dll",即使它在Bin文件夹中.我也尝试删除对"sodium.net"的依赖,在我收到运行时错误后说"sodium.net"丢失了 - 当我重新添加它时,该错误消失了,我得到了上面的那个(表示"sodium.net"正确加载).
所以我在"C:\ Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\cabinetservice"中打开网站shadow文件夹并搜索"sodium".唯一的结果是某些子文件夹中的"sodium.dll".没有"libsodium.dll".
显然,ASP.NET在创建网站的卷影副本时会忽略"libsodium.dll"文件.
我还尝试将libsodium.dll(32位)添加到C:\ Windows\System32,将libsodium.dll(64位)添加到C:\ Windows\SysWOW64.结果相同.
我尝试过C:\ Windows\Microsoft.NET\assembly\GAC_32\libsodium和C:\ Windows\Microsoft.NET\assembly\GAC_64\libsodium.结果相同.
如何让ASP.NET了解依赖?
给定这个"IHandle"接口和两个要处理的类:
interface IHandle<T>
{
void Handle(T m);
}
class M1
{
public int Id;
}
class MReset
{
}
Run Code Online (Sandbox Code Playgroud)
我想创建一个通用基础,负责"重置"以及管理M1实例:
class HandlerBase<T> :
IHandle<MReset>,
IHandle<T> where T : M1
{
protected int Count;
void IHandle<T>.Handle(T m)
{
++Count;
Console.WriteLine("{0}: Count = {0}", m.Id, Count);
}
void IHandle<MReset>.Handle(MReset m)
{
Count = 0;
}
}
Run Code Online (Sandbox Code Playgroud)
这不编译,因为编译器认为T可以是"MReset",因此它输出:
错误CS0695:'HandlerBase'无法实现'IHandle'和'IHandle',因为它们可能会统一某些类型参数替换
这本身就有些奇怪,因为我无法看到T可能是MReset类型,因为它必须是M1类型.但好吧,我可以接受编译器比我聪明:-)
编辑:编译器并不比我聪明:-)根据评论为什么这会导致CS0695?我们有"在确定所有可能的构造类型时不考虑约束声明".
现在我交换接口声明:
class HandlerBase<T> :
IHandle<T> where T : M1,
IHandle<MReset>
{
... same as before ..
}
Run Code Online (Sandbox Code Playgroud)
突然间我收到一条不同的错误消息,指出我无法实现IHandle.Handle(MReset m),因为类声明没有声明它正在实现该接口: …
我正在尝试将现有网站从 Rebus 0.45 升级到 Rebus 2.0,但遇到了 System.Web.ThreadContext.AssociateWithCurrentThread 因空引用崩溃的问题。我完全不知道为什么,所以我正在寻找我可以寻找的可能原因。
我唯一的跟踪是 Windows 事件日志,它在尝试发送消息时注册了以下内容:
An unhandled exception occurred and the process was terminated.
Application ID: /LM/W3SVC/1/ROOT/website
Process ID: 14460
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
StackTrace: at System.Web.ThreadContext.AssociateWithCurrentThread(Boolean setImpersonationContext)
at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext)
at System.Web.LegacyAspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state)
at System.Web.LegacyAspNetSynchronizationContext.CallCallback(SendOrPostCallback callback, Object state)
at System.Web.LegacyAspNetSynchronizationContext.Post(SendOrPostCallback callback, Object state)
at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.PostAction(Object state)
at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(ContextCallback callback, Object state, Task& currentTask)
--- End of stack trace from previous location where …Run Code Online (Sandbox Code Playgroud)