Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# .NET的Rhino授权正在抛出LicenseExpiredException_C#_.net_Winforms_Visual Studio 2015_Rhino Licensing - Fatal编程技术网

C# .NET的Rhino授权正在抛出LicenseExpiredException

C# .NET的Rhino授权正在抛出LicenseExpiredException,c#,.net,winforms,visual-studio-2015,rhino-licensing,C#,.net,Winforms,Visual Studio 2015,Rhino Licensing,我正在使用带有最新.NET内核的Windows8.1,以及VisualStudio2015。我按照James Gregory的建议创建了一个Winform应用程序。但是,当我声明许可证时,它给出了以下错误:Rhino.Licensing.LicenseExpiredException未处理 HResult=-2146233088 消息=到期日期:2016年6月16日12:00:00 AM Source=Rhino.Licensing 堆栈跟踪: 位于Rhino.Licensing.Abstrac

我正在使用带有最新.NET内核的
Windows8.1
,以及
VisualStudio2015
。我按照James Gregory的建议创建了一个Winform应用程序。但是,当我声明许可证时,它给出了以下错误:
Rhino.Licensing.LicenseExpiredException未处理
HResult=-2146233088
消息=到期日期:2016年6月16日12:00:00 AM
Source=Rhino.Licensing
堆栈跟踪:
位于Rhino.Licensing.AbstractLicenseValidator.HasExistingLicense()处
位于Rhino.Licensing.AbstractLicenseValidator.AssertValidLicense()
在Rhino.Licensing.LicenseValidator.AssertValidLicense()上
在Winfrm_RhinoTest.Form1.ApplyLicense()…

该代码于2016年6月15日运行,失效日期设置为2016年6月16日

生成许可证的C代码如下所示:

string publicKey = File.ReadAllText("publicKey.xml");
            new LicenseValidator(publicKey, @"C:\Users\Public\license.xml").AssertValidLicense();
<?xml version="1.0" encoding="utf-8"?>
<license id="b45c43a5-a639-4fa4-8bf7-38531b19072e" expiration="2016-06-16T00:00:00.0000000" type="Trial">
  <name>Bilbo</name>
  <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    <SignedInfo>
      <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
      <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
      <Reference URI="">
        <Transforms>
          <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
        </Transforms>
        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
        <DigestValue>d+eI2/Bdp/VYJ8pi/ufmJGeRW6k=</DigestValue>
      </Reference>
    </SignedInfo>
    <SignatureValue>Zd2oTinP0zE4/4haA5e4810MdG3upx1LlzkXALsTJYDgXLacDoc96diObTkxDipUBMUeFuf3ARBPtFRHGIqHjEfhn/FqZD+CrcsvjhbMSIROpaqqcOpzFwOamjQ+jPLW+BOf5qvMA0n4LNCm8B5qnifc/08zTXTSUpAqLiCY8zk=</SignatureValue>
  </Signature>
</license>
生成license.xml文件并在代码中使用,如下所示:

string publicKey = File.ReadAllText("publicKey.xml");
            new LicenseValidator(publicKey, @"C:\Users\Public\license.xml").AssertValidLicense();
<?xml version="1.0" encoding="utf-8"?>
<license id="b45c43a5-a639-4fa4-8bf7-38531b19072e" expiration="2016-06-16T00:00:00.0000000" type="Trial">
  <name>Bilbo</name>
  <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    <SignedInfo>
      <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
      <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
      <Reference URI="">
        <Transforms>
          <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
        </Transforms>
        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
        <DigestValue>d+eI2/Bdp/VYJ8pi/ufmJGeRW6k=</DigestValue>
      </Reference>
    </SignedInfo>
    <SignatureValue>Zd2oTinP0zE4/4haA5e4810MdG3upx1LlzkXALsTJYDgXLacDoc96diObTkxDipUBMUeFuf3ARBPtFRHGIqHjEfhn/FqZD+CrcsvjhbMSIROpaqqcOpzFwOamjQ+jPLW+BOf5qvMA0n4LNCm8B5qnifc/08zTXTSUpAqLiCY8zk=</SignatureValue>
  </Signature>
</license>

比尔博
d+eI2/Bdp/VYJ8pi/ufmJGeRW6k=
Zd2oTinP0zE4/4HAA5E4810MDG3UPX1LLZKXALSTJYDGXLACDOC96DIOBTKXDIPMUEFUF3ARPTFRHGIQHJEFHN/FqZD+CrcsvjhbMSIROpaqqcOpzFwOamjQ+jPLW+BOf5qvMA0n4LNCm8B5qnifc/08zTXTSUpAqLiCY8zk=
在中,日期比较以UTC为单位

result = DateTime.UtcNow < ExpirationDate;
由于您显示的例外情况表明过期日期是6月16日开始,最可能的原因是您在时区中的6月15日运行代码,实际上已经是UTC的6月16日,这在本文发布时已经是19小时。

在中,日期比较是在UTC中完成的

result = DateTime.UtcNow < ExpirationDate;

由于您显示的例外情况表明过期日期是6月16日开始,最可能的原因是您正在时区6月15日运行代码,实际上已经是UTC的6月16日,在本文发布时已经是19小时。

感谢
对错误原因的详细解释
以及对读者的帮助(包括我自己)我在2016年6月15日美国东部时间晚上11:30左右进行了测试,比UTC时区晚了4小时。我在美国复活节时间6月16日上午10:30左右测试了相同的代码,并将到期日期设置为6月17日,自6月17日以来没有抛出错误,UTC上午12点仍然比美国复活节时间上午10:30提前了足够多。谢谢u为
解释错误原因并帮助读者(包括我自己)我在2016年6月15日美国东部时间晚上11:30左右执行了测试,比UTC时区晚了4小时。我在美国复活节时间6月16日上午10:30左右测试了相同的代码,并将到期日期设置为6月17日,它没有抛出错误,因为6月17日上午12:00 UTC仍然比美国复活节时间早10:30。