小编Kja*_*tan的帖子

如何使用 StubX509Certificate2 修复假货生成

我无法编译使用 Microsoft fakes 的单元测试项目。尝试这样做时,我遇到了以下错误。

严重性代码描述项目文件行抑制状态错误 CS0115 'StubX509Certificate2.GetCertHash(HashAlgorithmName)':找不到合适的方法来覆盖 [C:\path\ServerAPI.UnitTest\obj\Debug\Fakes\s\f.csproj] ServerAPI.UnitTest C:\path\ServerAPI.UnitTest\f.cs 137304 活动

我正在使用 Visual Studio 2019(企业版)并针对 .NET 4.6.2。我不确定为什么会发生这种情况,并尝试将以下代码添加到 mscorlib.fakes。

<StubGeneration>
<Remove FullName="System.Security.Cryptography"/>
</StubGeneration>
Run Code Online (Sandbox Code Playgroud)

即使删除了假程序集引用和 .fakes 配置文件,我仍然收到此错误。

c# shim visual-studio microsoft-fakes

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

无法安装 Service Fabric 运行时

更新

通过查看任务管理器下的进程,我能够找到 Service Fabric Runtime 的安装程序(下面尝试安装的两个组件中的第一个,显然是失败的一个)。

我找到了该文件并尝试从 Powershell 运行它(在首先删除我之前尝试期间创建的 Service Fabric 文件夹之后)。结果如下所示: 显然它开始安装过程,然后冻结并停止,并在 10 分钟后超时,没有进一步的解释。

c:\Appl>MicrosoftServiceFabric.8.2.1363.9590.exe /accepteula /force
20.01.2022 08:26:11,Info,Installing Service Fabric Runtime. Logs written to C:\WINDOWS\TEMP\InstallFabricRuntime_637782675714458610.log
20.01.2022 08:26:11,Info,Running extract in parallel.
20.01.2022 08:26:11,Info,Unpackaging autoextractor...
20.01.2022 08:26:11,Info,20.01.2022 09:26:11 Running Process: powershell.exe -NoProfile -Command Get-ExecutionPolicy -Scope CurrentUser with timeout 00:01:00
20.01.2022 08:26:12,Info,Creating temporary runtime directory C:\Program Files\Microsoft Service Fabric.pxl3wsxg.zi0.
20.01.2022 08:26:12,Info,Extracting runtime cab to C:\Program Files\Microsoft Service Fabric.pxl3wsxg.zi0...
20.01.2022 08:26:12,Info,20.01.2022 09:26:12 Running Process: C:\WINDOWS\TEMP\MicrosoftServiceFabricAutoextractor.exe /L "C:\Program Files\Microsoft Service Fabric.pxl3wsxg.zi0" /E /Y …
Run Code Online (Sandbox Code Playgroud)

.net c# powershell azure azure-service-fabric

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

将字符串从android发送到visual basic 2010

我想从Android发送一个字符串到我的电脑(visual basic 2010)我试试这个,但它不起作用.请有人帮帮我..

我从以下网站获取我的Android代码:http: //thinkandroid.wordpress.com/2010/03/27/incorporating-socket-programming-into-your-applications/

它的外观:

package com.zelacroix.bukumenu;
import java.io.*;
import java.net.*;
import android.app.Activity;
import android.os.*;
import android.util.*;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;
public class TesKirim extends Activity {

        private EditText serverIp;

        private Button connectPhones;

        private String serverIpAddress = "192.168.1.2";

        private boolean connected = false;

        private Handler handler = new Handler();

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.teskirim);

            serverIp = (EditText) findViewById(R.id.server_ip);
            connectPhones = (Button) findViewById(R.id.connect_phones);

            connectPhones.setOnClickListener(new OnClickListener() {
            @Override
                public void onClick(View v) {
                    if …
Run Code Online (Sandbox Code Playgroud)

android visual-studio-2010 wifi android-wifi

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

Opera Extension xmlhttp.send(); 错误

我在使用我的Opera扩展连接到java应用程序时遇到问题我已经在chrome中使用了这个扩展.

这是popup.html中javascritp中的代码

function AtribuirID(){

    if (window.XMLHttpRequest)
    {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }

    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            var texto = xmlhttp.responseText;
            var splitagem=texto.split("(user)"); 
            localStorage.setItem('ID',splitagem[0]);
            localStorage.setItem('Auxiliar',splitagem[1]);
        }
    }

    xmlhttp.open("GET","http://localhost:10002?z=AtribuirID",true);
    xmlhttp.send();
}
Run Code Online (Sandbox Code Playgroud)

问题是我收到错误未捕获异常:DOMException:xmlhttp.send()中的NETWORK_ERR,我无法访问我的应用程序在java中,假设是服务器部分.我已经将network ="public private"放在config.xml中,但它没有用

opera

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

正则表达困扰C#

尝试使用以下正则表达式时遇到问题:

string profileConfig = File.ReadAllText(str);

string startIndex = "user_pref(\"network.proxy.autoconfig_url\", \"";
string endIndex = "\"";

var regex = startIndex + "(.*)" + endIndex;
// Here we call Regex.Match.
Match match = Regex.Match(profileConfig, 
                          regex,
                          RegexOptions.IgnoreCase);

// Here we check the Match instance.
if (match.Success)
{
    // Finally, we get the Group value and display it.
    string key = match.Groups[1].Value;
    MessageBox.Show(key);
}
Run Code Online (Sandbox Code Playgroud)

我收到错误:

附加信息:解析"user_pref("network.proxy.autoconfig_url","(.*)"" - 还不够).

我的正则表达式在某种程度上是否格式错误?

.net c# windows

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

从asp.net读取配置文件

我正在创建一个 Web 应用程序,它调用一个 DLL 来运行单元测试,我还有另一个 DLL(DataAccessLayer),它执行连接并执行对引用主 DLL 的 SQL 的查询。这两个 DLL 使用相同的配置文件来读取设置。

从 VS 运行应用程序时,应用程序工作正常。但是,当 Web 应用程序部署到 IIS 时,DLL 似乎无法从配置文件中读取设置。

经过一番研究,我发现我可能必须在 web.config 文件中明确定义配置元素,但是我不知道如何实现这一点。有人可以指出我正确的方向吗?

我实际上是通过以下代码使用 ConfigurationManager 检索设置:-

   public string GetValue(string key)
   {
       var appConfig = ConfigurationManager.OpenExeConfiguration("path to dll");
       strKeyValue = appConfig.AppSettings.Settings[key].Value;



       return strKeyValue;
   }
Run Code Online (Sandbox Code Playgroud)

谢谢。

.net c# asp.net configurationmanager config

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

在C#中创建LostFocus事件后,GotFocus事件未到来

如果我的表单,我只想清除剪贴板文本LostFocus.我的意思是,如果用户使用键盘或鼠标复制某些内容,必须在LostFocus事件中清除它,那么如果我的表单再次获得焦点,我需要恢复我的文本.我怎样才能做到这一点?

string sValue = "";
public Form1()
{
    InitializeComponent();
    this.LostFocus += new EventHandler(Form1_LostFocus);
    this.GotFocus += new EventHandler(Form1_GotFocus);
}

void Form1_GotFocus(object sender, EventArgs e)
{
    Clipboard.SetText(sValue);
    textBox1.Text = Clipboard.GetText();
}

void Form1_LostFocus(object sender, EventArgs e)
{
    sValue = textBox1.Text;
    Clipboard.Clear();
}
Run Code Online (Sandbox Code Playgroud)

这不起作用; 该LostFocus事件被调用,但GotFocus没有被调用.我怎么解决这个问题?

c# clipboard events

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

visual basic等效于"rectangle a = new a(){width = 1; height = 2;}"

rectangle a=new a() { width=1; height=2; }
Run Code Online (Sandbox Code Playgroud)

我曾经构建过像这样的对象,在visual basic中有类似的方法吗?对不起,我无法真正标记这项技术.

c# vb.net initialization object-initializers

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

NullReferenceException 未在 catch 块中捕获(Array.Sort 方法)

try
{
    Array.Sort(PokeArray, (x1, x2) => x1.Name.CompareTo(x2.Name));
}
catch (NullReferenceException R)
{
    throw R;
}
Run Code Online (Sandbox Code Playgroud)

然而,这是一行简单的代码,用于对我创建的对象数组进行排序;如果有空值,则抛出异常。该try catch块似乎不起作用。

异常发生在这个特定区域x1.Name.CompareTo(x2.Name),Catch 块是否放错了位置?

谢谢!

更新: 截取自以下评论的截图: 在此处输入图片说明

c# msdn exception

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

该进程无法访问文件“D:.txt”,因为它正被 c# 中的另一个进程使用

我有一个 pdf 文件,我正在尝试使用 itext 在 c# 中读取和写入文本文件。现在我创建了一个文本文件并尝试将我的 pdf 值写入其中,但出现以下错误..

该进程无法访问文件“D:\9008028901.txt”,因为它正被另一个进程使用。

这是我在 c# 中的代码..

public bool ExtractText(string inFileName, string outFileName)
{
    StreamWriter outFile = null;
    try
    {
       // Create a reader for the given PDF file
       PdfReader reader = new PdfReader(inFileName);
       outFile = File.CreateText(outFileName);

       outFile = new StreamWriter(outFileName, false, System.Text.Encoding.UTF8);
Run Code Online (Sandbox Code Playgroud)

在我的代码中,正在创建文本文件,但我无法在其中写入任何内容。我的文本文件是空白的。请帮我..

c# itext file-handling text-files

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