小编Ars*_*ray的帖子

如何使用makecert创建WCF接受的X509证书

任何人都可以向我提供有关如何创建自签名证书的示例,该证书将被以下代码接受:

        ServiceHost svh = new ServiceHost(typeof(MyClass));

        var tcpbinding = new NetTcpBinding(SecurityMode.TransportWithMessageCredential, true);
        //security
        tcpbinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
        svh.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new BWUserNamePasswordValidator();
        svh.Credentials.UserNameAuthentication.UserNamePasswordValidationMode =UserNamePasswordValidationMode.Custom;
        svh.Credentials.ServiceCertificate.Certificate = BookmarkWizSettings.TcpBindingCertificate;
        ....
        svh.Open();
Run Code Online (Sandbox Code Playgroud)

我用过

makecert -pe myCertificate
Run Code Online (Sandbox Code Playgroud)

makecert -sv SignRoot.pvk -cy authority -r signroot.cer -a sha1 -n "CN=Dev Certification Authority" -ss my -sr localmachine
Run Code Online (Sandbox Code Playgroud)

makecert -r -pe -n "CN=Client" -ss MyApp -sky Exchange
Run Code Online (Sandbox Code Playgroud)

我试图用BouncyCastle生成证书,但每次我都得到以下异常:

It is likely that certificate 'CN=Dev Certification Authority' may not have a 
private key that is capable of key exchange …
Run Code Online (Sandbox Code Playgroud)

c# security wcf makecert x509

8
推荐指数
1
解决办法
3882
查看次数

如何为fiddler核心手动设置上游代理?

我希望能够通过上游代理重定向来自fiddler代码的http请求,我希望能够在运行时指定这些代理.

我查看了FiddlerApplication函数,我没有看到任何可能适合的内容,以及我在文档中找不到任何匹配项(除了您可以指定启动标志以使用系统的代理作为上游代理).

在运行时指定/更改fiddler核心代理的最佳方法是什么?

c# fiddler fiddlercore

8
推荐指数
1
解决办法
3971
查看次数

是否可以使用javascript检查Firefox DNT的值?

我正在开发一个javascript广告引擎,我希望它能够尊重Firefox DNT标题.

有什么方法javascript可以检查用户是否在没有得到服务器帮助的情况下在firefox中设置DNT为开启或关闭(或者没有设置首选项)?

javascript firefox do-not-track

8
推荐指数
1
解决办法
2072
查看次数

在java中处理大型String列表

我有一个任务,我需要通过几十亿字符串并检查每个是否是唯一的.所有线路本身都不能容纳在PC的RAM存储器中.此外,行数可能大于Integer.MAX_VALUE.

我假设来处理该数据量的最好办法就是把每个字符串的哈希码成某种哈希表的.

所以,这是我的问题:

  1. 我该怎么用而不是String.hashCode()?(返回值为int,但我可能需要很长时间)
  2. 使用此大小的列表的最快方法/框架是什么?我最需要的是能够快速检查列表是否包含元素

java hashset bigdata data-structures

7
推荐指数
1
解决办法
1281
查看次数

如何在XPath中检查多个属性?

我想在XHTML文档中选择样式表,它不仅包含描述,还包含href.

例如

<link rel="stylesheet" href="123"/> 
Run Code Online (Sandbox Code Playgroud)

应该选择,和

<link rel="stylesheet"/>  
Run Code Online (Sandbox Code Playgroud)

不应该.

目前,我这样做:

foreach (XmlNode n in xml.SelectNodes(@"//link[@rel='stylesheet']"))
{
    if (n.Attributes["href"]==null||n.Attributes[""].Value==null)
    {
        continue;
    }
    var l = Web.RelativeUrlToAbsoluteUrl(stuffLocation, n.Attributes["href"].Value);
}
Run Code Online (Sandbox Code Playgroud)

但我怀疑有更好的方法可以做到这一点.在那儿?

c# xml xpath

7
推荐指数
1
解决办法
6905
查看次数

找不到文件'Microsoft.Windows.Common-Controls,Version = 6.0.0.0,Culture =*,PublicKeyToken = 6595b64144ccf1df,

我正在尝试将此库集成到我的应用程序中.

起初它崩溃了

Unable to find an entry point named 'TaskDialogIndirect' in DLL 'ComCtl32'.
Run Code Online (Sandbox Code Playgroud)

所以我没有注释

<dependentAssembly>
  <assemblyIdentity
      type="win32"
      name="Microsoft.Windows.Common-Controls"
      version="6.0.0.0"
      processorArchitecture="*"
      publicKeyToken="6595b64144ccf1df"
      language="*"
    />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)

正如这里推荐的那样.

现在应用程序将无法使用以下消息进行编译:

Could not find file 'Microsoft.Windows.Common-Controls, Version=6.0.0.0, Culture=*, 
    PublicKeyToken=6595b64144ccf1df, ProcessorArchitecture=*, Type=win32'
Run Code Online (Sandbox Code Playgroud)

删除app.manifest会导致应用崩溃,因为我正在使用Microsoft功能区.

我该如何解决这个错误?

c# wpf manifest common-controls

7
推荐指数
1
解决办法
1万
查看次数

c#的ObservableDictionary

我正在尝试使用ObservableDictionary的以下实现:ObservableDictionary(C#).

当我将字典绑定到DataGrid时使用以下代码:

ObserveableDictionary<string,string> dd=new ObserveableDictionary<string,string>();
....
dd["aa"]="bb";
....
dd["aa"]="cc";
Run Code Online (Sandbox Code Playgroud)

dd["aa"]="cc";我得到以下异常

Index was out of range. Must be non-negative and less than the size of the 
collection. Parameter name: index
Run Code Online (Sandbox Code Playgroud)

CollectionChanged(this, new NotifyCollectionChangedEventArgs(action, newItem, oldItem)在以下方法中引发此异常:

private void OnCollectionChanged(NotifyCollectionChangedAction action, KeyValuePair<TKey, TValue> newItem, KeyValuePair<TKey, TValue> oldItem)
{
  OnPropertyChanged();

  if (CollectionChanged != null) CollectionChanged(this, new NotifyCollectionChangedEventArgs(action, newItem, oldItem));
}
Run Code Online (Sandbox Code Playgroud)

这个index参数似乎对应于KeyValuePair<TKey, TValue> oldItem.

如何KeyValuePair<TKey, TValue>超出范围,我该怎么做才能使这项工作?

c# wpf binding dictionary inotifypropertychanged

7
推荐指数
2
解决办法
3万
查看次数

禁用按钮创建模糊效果

我正在尝试制作一个按钮,当禁用时它会模糊不清.

到目前为止,这就是我所拥有的:

<Style x:Key="BluredButton" TargetType="{x:Type Button}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Button}">
                <Border x:Name="Chrome" Background="{TemplateBinding Background}" SnapsToDevicePixels="true" CornerRadius="10" BorderThickness="1">
                    <Border.Effect>
                        <BlurEffect Radius="0"/>
                    </Border.Effect>
                    <Border.BorderBrush>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FF7D8F93" Offset="0"/>
                            <GradientStop Color="#FF5797A7" Offset="0.997"/>
                        </LinearGradientBrush>
                    </Border.BorderBrush>
                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </Border>
                <ControlTemplate.Triggers>
                    <EventTrigger RoutedEvent="FrameworkElement.Loaded"/>
                    <Trigger Property="IsEnabled" Value="false">
                        <Setter Property="Foreground" Value="#ADADAD"/> 
                        <!--How do I set BlurEffect.Radius here?-->
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)

按钮被禁用后,我想将模糊半径设置为3.

我怎么做?

c# wpf xaml triggers

7
推荐指数
1
解决办法
4830
查看次数

在使用fiddler修改请求时,SSL收到的记录超过了允许的最大长度

我正在尝试使用FiddlerCore实现系统内SSL服务器:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace fiddlerCoreTest
{
    using System.IO;
    using System.Threading;
    using Fiddler;

    class Program
    {
        static Proxy oSecureEndpoint;
        static string sSecureEndpointHostname = "localhost";
        static int iSecureEndpointPort = 7777;

        static void Main(string[] args)
        {
            //var tt = Fiddler.CertMaker.GetRootCertificate().GetRawCertData();
            //File.WriteAllBytes("root.crt",tt);

            Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
            {
                oS.bBufferResponse = false;               

                if ((oS.hostname == sSecureEndpointHostname)&&oS.port==7777)
                {
                    oS.utilCreateResponseAndBypassServer();
                    oS.oResponse.headers.HTTPResponseStatus = "200 Ok";
                    oS.oResponse["Content-Type"] = "text/html; charset=UTF-8";
                    oS.oResponse["Cache-Control"] = "private, max-age=0";
                    oS.utilSetResponseBody("<html><body>Request for httpS://" + sSecureEndpointHostname + ":" + …
Run Code Online (Sandbox Code Playgroud)

c# ssl fiddler fiddlercore

7
推荐指数
1
解决办法
2109
查看次数

ValueError:数据基数不明确

我正在尝试根据从 DataFrame 获取的数据训练 LSTM 网络。

这是代码:

x_lstm=x.to_numpy().reshape(1,x.shape[0],x.shape[1])

model = keras.models.Sequential([
    keras.layers.LSTM(x.shape[1], return_sequences=True, input_shape=(x_lstm.shape[1],x_lstm.shape[2])),
    keras.layers.LSTM(NORMAL_LAYER_SIZE, return_sequences=True),
    keras.layers.LSTM(NORMAL_LAYER_SIZE),
    keras.layers.Dense(y.shape[1])
])

optimizer=keras.optimizers.Adadelta()

model.compile(loss="mse", optimizer=optimizer)
for i in range(150):
    history = model.fit(x_lstm, y)
    save_model(model,'tmp.rnn')
Run Code Online (Sandbox Code Playgroud)

这失败了

ValueError: Data cardinality is ambiguous:
  x sizes: 1
  y sizes: 99
Please provide data which shares the same first dimension.
Run Code Online (Sandbox Code Playgroud)

当我将模型更改为

model = keras.models.Sequential([
    keras.layers.LSTM(x.shape[1], return_sequences=True, input_shape=x_lstm.shape),
    keras.layers.LSTM(NORMAL_LAYER_SIZE, return_sequences=True),
    keras.layers.LSTM(NORMAL_LAYER_SIZE),
    keras.layers.Dense(y.shape[1])
])
Run Code Online (Sandbox Code Playgroud)

它失败并出现以下错误:

Input 0 of layer lstm_9 is incompatible with the layer: expected ndim=3, found ndim=4. Full shape …
Run Code Online (Sandbox Code Playgroud)

python lstm keras tensorflow

7
推荐指数
1
解决办法
2万
查看次数