小编Nim*_*oud的帖子

为什么try-catch块无法处理异常?

FSDKCam.GetVideoFormatList是来自外部.NET dll的方法.当您看到图像时,它会在try-catch块中抛出异常.

try
{
    FSDKCam.GetVideoFormatList(ref cameraList[0], out formatList, out count);
    if (count > 0) cmbCameraList.Items.Add(cam);
}
catch { }
Run Code Online (Sandbox Code Playgroud)

截图:

在此输入图像描述

c# exception-handling access-violation

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

如何使用IN sql关键字构建参数化查询?

这就是我尝试过的和失败的:

      string sql = "... WHERE [personID] IN (@sqlIn) ...";
      string sqlIn = "1,2,3,4,5";
      SqlCeCommand cmd.Parameters.Add("@sqlIn", SqlDbType.NText).Value = sqlIn;

      SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);
      da.Fill(ds); // > Error
Run Code Online (Sandbox Code Playgroud)

错误详情:

ntext和image数据类型不能在WHERE,HAVING,GROUP BY,ON或IN子句中使用,除非这些数据类型与LIKE或IS NULL谓词一起使用.

我不能将所有ID作为一个参数传递吗?我应该逐个添加所有ID吗?

PS:注意SqlCE

c# sql-server-ce

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

typeof&GetType

我序列化下面的一个类,该方法需要对象类型作为参数.

string xml = SerializeObject(data, typeof(ClassData));
Run Code Online (Sandbox Code Playgroud)

我认为第二个参数是没有必要的.如何删除第二个参数?我怎样才能得到的类型数据类型

c#

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

如何在数组成员之间添加逗号等?

我只需在每个单词旁边添加逗号:

 foreach (DataRow row in ds.Tables[0].Rows)
 {                {
    sqlIn += row["personId"] + ", ";
 }
Run Code Online (Sandbox Code Playgroud)

然后我删除最后一个不需要的逗号:

 sqlIn = sqlIn.TrimEnd(' ', ',');
Run Code Online (Sandbox Code Playgroud)

而且我觉得在经典ASP的时代.我做的是什么C#版本?

c#

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

通信安全:Fiddler拦截我的谈话.我如何保护我的应用程序?

我构建了一个GData应用程序并发送了我的Google凭据以使用我的帐户.Fiddler可以轻松拦截我的通信并显示用户名和密码.

有没有办法防止窥探?如果不是,有人可以轻松揭示我的密码......

POST https://www.google.com/accounts/ClientLogin HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: www.google.com
Content-Length: 109
Expect: 100-continue
Connection: Keep-Alive

Email=xxxxxxxxxx%40gmail.com&Passwd=veryhigh-secure-ultra-strenght-passord-is-this-HHDGdgddhdyhghdeeehdeg^3h37373dE^^^+--XXXxxx123123h37ddg3g36dhjfhfg6373udbgd634t&source=database&service=writely&accountType=HOSTED_OR_GOOGLE
Run Code Online (Sandbox Code Playgroud)

附加: 我们了解Google Docs的公共SSL证书.我们可以检查它是在客户端的PC上使用还是有假的?有帮助吗?

在此输入图像描述

更新和结论:

Fiddler充当中间人并在Windows的受信任的根证书中注入假根证书.商店.然后为目标站点生成假证书.浏览器使用伪造的认证 - 公共密钥 - 并加密和发送数据给Fiddler本身.Fiddler使用伪根证书-private密钥解密数据.然后使用远程站点的原始认证并加密数据并发送到目标站点.对响应浏览器反向重复相同的操作.

我只是问如何在另一个问题上检测这些假证明.如果我使用.NET构建一个简单的应用程序,应用程序将依赖并使用Windows的"默认/存储"认证用于目标站点.如果没有,Fiddler将动态生成一个.

所以...

  1. 我不依赖Windows上的证书并直接从目标站点获取真实证书/或者我必须在我的应用程序中包含有效的目标站点证书.

  2. 我必须修改Google Data API的源代码,以便在我的https通信中使用我附带的-authentic one-SSL证书 - 一个简单的.crt文件.因此,数据将在我的应用程序中加密,并仅在目标站点解密.

  3. 保护记忆 - 使事情变得更难 - 是下一步.

我已经把这些东西写成了未来的参考,以便谁来研究相同的主题并得到你的认可.

谢谢.

有人已经提到假证书:

  1. 用DNS探测中间人攻击作者:Jason Coombs,2003年12月18日

c# security https fiddler

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

如何在iTextSharp PDF Stamper中使用UTF-8编码?

我想使用UTF-8而不是CP1250来显示国家字符.我找到了支持UTF-8的AddParagraph方法,但我找不到任何压模示例.

这是CP1250的代码片段:

        PdfReader reader = new PdfReader(templatePath);
        byte[] bytes;
        using (MemoryStream ms = new MemoryStream())
        {
            using (PdfStamper stamper = new PdfStamper(reader, ms))
            {
                PdfContentByte cb = stamper.GetOverContent(1);

                BaseFont bf = BaseFont.CreateFont(
                   BaseFont.COURIER_BOLD, 
                   BaseFont.CP1250, 
                   true);

                //Begin text command
                cb.BeginText();
                //Set the font information                        
                cb.SetFontAndSize(bf,12f);

                //Position the cursor for drawing
                cb.MoveText(field.X, field.Y);
                //Write some text
                cb.ShowText(field.Text);
                //End text command
                cb.EndText();

                //Flush the PdfStamper's buffer
                stamper.Close();
                //Get the raw bytes of the PDF
                bytes = ms.ToArray();
            }
        }
Run Code Online (Sandbox Code Playgroud)

我怎样才能使用UTF-8?

c# pdf utf-8 itext itextsharp

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

WPF绑定:属性与变量

我已经将公共属性转换为公共变量,以使代码更简单,现在组合框的绑定机制将无法工作.我不能使用变量而不是属性?

工作代码:作为财产

    internal class Utility
    {
        #region ReportOf
        public enum ReportOf
        {
            Choose, All, Group, Person
        }

        private static Dictionary<ReportOf, string> _dictReportOf;
        public static Dictionary<ReportOf, string> ReportOfCollection
        {
            get { return _dictReportOf; }
        }
        #endregion ReportOf


        static Utility()
        {
            //initialize the collection with user friendly strings for each enum
            _dictReportOf = new Dictionary<ReportOf, string>(){
                {ReportOf.Choose, "Lütfen seçiniz..."},        
                {ReportOf.All, "Herkes"},
                {ReportOf.Group, "Grup"},
                {ReportOf.Person, "?ah?s"}};

        }
    }
Run Code Online (Sandbox Code Playgroud)

非工作端口:作为变量

    internal class Utility
    {
        #region ReportOf
        public enum ReportOf
        {
            Choose,
            All,
            Group,
            Person …
Run Code Online (Sandbox Code Playgroud)

c# wpf binding

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