小编Tea*_*ild的帖子

我会失去什么功能将jQuery从2.0降级到1.10?

我们正在实施一个新网站,该网站将与现有系统一起使用.当前系统使用IE8,但在设置新站点时,已使用jQuery2.0.

如果我们将jQuery降级到1.10,我们会丢失任何功能吗?

博客(http://blog.jquery.com/2013/07/03/jquery-1-10-2-and-2-0-3-released/)不是很清楚.

降级是否会成为一项复杂的工作?

jquery

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

C#使用System.Security.Cryptography.Aes进行AES256加密的示例

我需要实现AES 256加密/解密,我无法找到一个正常工作的示例.

MSDN建议我应该使用AES类.

Rijndael类是Aes算法的前身.您应该使用Aes算法而不是Rijndael.有关更多信息,请参阅.NET安全博客中的Rijndael和AES之间的条目.

有没有人能指出我使用AES类AES256的好例子?

为了增加一点清晰度:

我有一个密码文件,其中包含共享密钥和一串加密文本.我需要解密文本然后验证它.

我见过的所有示例都希望至少有2个参数来执行加密/解密.

我是否能够从密码文件中的文本推断出初始化向量和密钥?

这是我的密码文件中保存的文本示例:

ÊÚḱÌráƒ@†²;Ä;öDWnªóª©¨¨L

c# encryption aes

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

如何筛选与模式匹配的字符串列表

我有一个字符串列表(实际上是文件名),我只想保留那些匹配过滤器表达式的字符串,如:\*_Test.txt.

实现这一目标最好的是什么?

以下是我提出的答案:

List<string> files = new List<string>();
files.Add("MyFile1.csv");
files.Add("MyFile1_Test.txt");
files.Add("MyFile2.csv");
files.Add("MyFile2_Test.txt");
files.Add("MyFile3.csv");
files.Add("MyFile3_Test.txt");
files.Add("MyFile_Testtxttxt.txt");

// Define a filter
string filter = "*_Test.txt";

// Make the filter regex safe
foreach (char x in @"\+?|{[()^$.#")
    filter = filter.Replace(x.ToString(), @"\" + x.ToString());

filter = string.Format("^{0}$",filter.Replace("*", ".*"));

// Old School
List<string> resultList1 = files.FindAll(delegate(string s) { return Regex.IsMatch(s, filter, RegexOptions.IgnoreCase); });

// Version using LINQ
List<string> resultList2 = files.Where(x =>  Regex.IsMatch(x, filter, RegexOptions.IgnoreCase) == true ).ToList();
Run Code Online (Sandbox Code Playgroud)

c# pattern-matching

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

解析XDocument而不必继续指定默认命名空间

我有一些XML数据(类似于下面的示例),我想读取代码中的值.

为什么我被迫指定默认名称空间来访问每个元素?我原本期望默认命名空间用于所有元素.

有没有更合理的方法来实现我的目标?

示例XML:

<?xml version="1.0" encoding="UTF-8"?>
<ReceiptsBatch xmlns="http://www.secretsonline.gov.uk/secrets">
    <MessageHeader>
        <MessageID>00000173</MessageID>
        <Timestamp>2009-10-28T16:50:01</Timestamp>
        <MessageCheck>BX4f+RmNCVCsT5g</MessageCheck>
    </MessageHeader>
    <Receipts>
        <Receipt>
            <Status>OK</Status>
        </Receipt>
    </Receipts>
</ReceiptsBatch>
Run Code Online (Sandbox Code Playgroud)

用于读取我之后的xml元素的代码:

XDocument xDoc = XDocument.Load( FileInPath );

XNamespace ns = "http://www.secretsonline.gov.uk/secrets";

XElement MessageCheck = xDoc.Element(ns+ "MessageHeader").Element(ns+"MessageCheck");
XElement MessageBody = xDoc.Element("Receipts");
Run Code Online (Sandbox Code Playgroud)

c# xml linq-to-xml xnamespace

12
推荐指数
3
解决办法
6172
查看次数

在Visual Studio 2008中使用自定义安装程序时出现错误1001

我创建了一个简单的winforms应用程序和一个自定义安装程序.这看起来很简单,但我在事件日志中得到以下弹出窗口和错误详细信息.

运行自定义操作代码之前显示错误消息框

无法找到源MsiInstaller的事件ID 11001的描述.引发此事件的组件未安装在本地计算机上,或者安装已损坏.您可以在本地计算机上安装或修复该组件.

如果事件源自另一台计算机,则必须随事件一起保存显示信息.

活动中包含以下信息:

产品:自定义操作测试程序 - 错误1001.错误1001.初始化安装时发生异常:System.IO.FileNotFoundException:无法加载文件或程序集'file:/// C:\ Windows\system32\Action'或其中一个它的依赖关系.系统找不到指定的文件..(NULL)(NULL)(NULL)(NULL)(NULL)

消息资源存在但在字符串/消息表中找不到该消息

我检查了C:\ Windows\system32,没有名为Action的文件或文件夹,但有3个文件叫做ActionCenter.dll,ActionCenterCPL.dllActionQueue.dll

我有什么想法解决这个错误?

编辑:

根据cosmin-pirvu的建议,我使用日志记录运行安装程序.它出现错误的区域如下所示,但我仍然不知道如何解决问题.

MSI (s) (40:7C) [09:34:26:523]: Executing op: CustomActionSchedule(Action=_FBC0CC84_D5B4_41F9_A3EC_98A13BC7E73E.install,ActionType=3073,Source=BinaryData,Target=ManagedInstall,CustomActionData=/installtype=notransaction /action=install /LogFile= /targetdir="C:\Test\Custom Action Tester\" /Param1="C:\Test\TestFile.txt" /Param2="C:\Test\" "C:\Test\Custom Action Tester\ConfigSetup.dll" "C:\Users\wildb\AppData\Local\Temp\CFG66BE.tmp")
MSI (s) (40:94) [09:34:26:525]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI85A8.tmp, Entrypoint: ManagedInstall
MSI (s) (40:F0) [09:34:26:525]: Generating random cookie.
MSI (s) (40:F0) [09:34:26:557]: Created Custom Action Server with PID 6492 (0x195C).
MSI (s) (40:D4) [09:34:26:586]: Running as a service. …
Run Code Online (Sandbox Code Playgroud)

custom-action visual-studio-2008

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

HttpWebRequest与HttpClient

我有一大堆代码使用HttpWebRequestHttpWebResponse,但我想将其转换为使用HttpClientHttpResponseMessage.

这是有效的代码块...

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(serviceReq);

request.Method = "POST";
request.ContentType = "text/xml";
string xml = @"<?xml version=""1.0""?><root><login><user>flibble</user>" + 
    @"<pwd></pwd></login></root>";
request.ContentLength = xml.Length;
using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream()))
{
    dataStream.Write(xml);
    dataStream.Close();
}

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Run Code Online (Sandbox Code Playgroud)

这是我想要替换它的代码,只要我能使它工作.

/// <summary>
/// Validate the user credentials held as member variables
/// </summary>
/// <returns>True if the user credentials are valid, else false</returns>
public bool ValidateUser()
{
    bool valid = false;

    try
    {
        // Create …
Run Code Online (Sandbox Code Playgroud)

c# wcf httpclient httpwebrequest

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

在异常处理方面删除文件的最有效方法是什么?

MSDN告诉我们,当你调用"File.Delete(path);"时 在不存在的文件上生成异常.

在执行删除之前调用delete方法并使用try/catch块来避免错误或验证文件的存在会更有效吗?

我倾向于认为避免try/catch块更好.当您知道如何检查错误时,为什么会发生错误.

无论如何,这里是一些示例代码:

// Option 1: Just delete the file and ignore any exceptions

/// <summary>
/// Remove the files from the local server if the DeleteAfterTransfer flag has been set
/// </summary>
/// <param name="FilesToSend">a list of full file paths to be removed from the local server</param>
private void RemoveLocalFiles(List<string> LocalFiles)
{
    // Ensure there is something to process
    if (LocalFiles != null && LocalFiles.Count > 0 && m_DeleteAfterTransfer == true)
    {
        foreach (string file in LocalFiles) …
Run Code Online (Sandbox Code Playgroud)

c# file-io exception-handling

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

Linq将字符串转换为Dictionary <string,string>

我正在使用字典来保存一些参数,我发现不可能序列化任何实现IDictionary的东西(无法序列化IDictionary).

作为一种解决方法,我想将字典转换为字符串以进行序列化,然后在需要时转换回字典.

因为我正在努力改进我的LINQ,这似乎是一个很好的地方,但我不知道如何开始.

这是我在没有LINQ的情况下实现的方法:

/// <summary>
/// Get / Set the extended properties of the FTPS processor
/// </summary>
/// <remarks>Can't serialize the Dictionary object so convert to a string (http://msdn.microsoft.com/en-us/library/ms950721.aspx)</remarks>
public Dictionary<string, string> FtpsExtendedProperties
{
    get 
    {
        Dictionary<string, string> dict = new Dictionary<string, string>();

        // Get the Key value pairs from the string
        string[] kvpArray = m_FtpsExtendedProperties.Split('|');

        foreach (string kvp in kvpArray)
        {
            // Seperate the key and value to build the dictionary
            string[] pair = kvp.Split(','); …
Run Code Online (Sandbox Code Playgroud)

c# linq dictionary

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

反编译C#.Net 1.1应用程序的最佳工具

可能重复:
.net反汇编程序/反编译器
是否有.NET Reflector的"免费"替代?

很久以前,我们为客户编写了C#.NET 1.1应用程序,在办公室搬迁和裁员过程中,源代码未检入Source Safe.

客户现在报告了一个问题,我们不想从头开始重写应用程序.

我相信我们应该能够通过反编译可执行文件来获取源代码.任何人都可以推荐一个好的工具(最好是免费的).

当我们首先编写应用程序时,我不认为反编译会有任何法律问题,但如果我错了请纠正我.

c# .net-1.1 decompiler

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

Noobie WPF命名空间和转换器问题

请原谅noob问题,但我要围成一圈,需要答案......

无论如何,我一直在看这篇文章WPF:如何将RadioButtons绑定到枚举?但我无法在XAML文件中识别转换器.

<Window x:Class="Widget.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
    Title="Widget" Height="366" Width="588" WindowStyle="SingleBorderWindow">
    <Window.Resources>
        <EnumBooleanConverter x:Key="enumBooleanConverter" />
    </Window.Resources>
...
Run Code Online (Sandbox Code Playgroud)

我有一个单独的文件持有EnumBooleanConverter类但上面的引用给我以下错误:

错误1 XML名称空间" http://schemas.microsoft.com/winfx/2006/xaml/presentation " 中不存在标记"EnumBooleanConverter ".

我已经尝试添加对程序集的引用,然后将标记附加到XAML但无济于事.

<Window x:Class="Widget.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:local="clr-namespace:Widget;assembly=Widget"
    Title="Widget" Height="366" Width="588" WindowStyle="SingleBorderWindow">
    <Window.Resources>
        <local:EnumBooleanConverter x:Key="enumBooleanConverter" />
    </Window.Resources>
...
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

.net wpf xaml namespaces converter

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