为什么图像开头有不需要的额外字节?

2023-12-01

问题:

我为我兄弟制作了一个主页,可以在这里访问:
http://www.daniel-steiger.ch

它在 Linux 上使用 Microsoft ASP.NET MVC3 和 mono 3,通过 fastcgi 和 nginx(加上我自己的 DNS 服务器)。

现在我知道这是一个不寻常的星座,但到目前为止,一切都很好。
然而,我遇到了一个非常微妙的小错误。

当在图库中单击缩略图时,我想通过图库控制器的 FullImage 方法在新选项卡中显示全尺寸图像。
例如,这个直接网址:
http://www.daniel-steiger.ch/gallery/FullImage/001.jpg


在 Internet Explorer 中,我将图像改为文本。
在所有其他浏览器中显示“无效图像”消息。
我通过直接文件 URL 调用图像解决了这个问题,效果很好:
http://www.daniel-steiger.ch/Content/images/gallery/001.jpg?LastWriteTimeUTC=1358694795000

随后,我向 mono 邮件列表报告了该错误
http://mono.1490590.n4.nabble.com/Bug-in-mono-3-0-1-MVC3-File-FileResult-td4658382.html

现在我得到的答复是,这都是我的错,因为我设置了错误的图像 MIME 类型,这是真的。
然而,我发现奇怪的是,如果是这样的话,相同的代码在 Windows 上运行得很好,而且像 Chrome 这样的智能浏览器通常会检测到错误的 MIME 设置并使用正确的设置。

因此,我将 mime-type 从“image/jpg”更改为“image/jpeg”,并将项目重新部署到服务器。
我还使用文件实用程序检查了该图像是否实际上是 jpeg 图像,确实如此。

奇怪的是,它仍然没有显示图像。
在 Internet Explorer 上,我现在得到“不可用”。
在所有其他浏览器上,我得到:图像无法显示,因为它包含错误。

我现在从图像包含错误的 URL 中 wget 图像。
wget http://www.daniel-steiger.ch/gallery/fullimage/001.jpg

然后我在无效文件和原始文件之间进行了二进制比较:

cmp -l 001.jpg 001a.jpg   | awk '{printf "%08X %02X %02X\n", $1, strtonum(0$2), strtonum(0$3)}' >> comparison.txt

这是比较结果:

BinDiff What springs into my eye, is that the image that internet explorer says he cannot find is actually 1.7 MB in size, and contains the extra bytes:

31 39 36 62 36 38 0D 0A 

一开始...
任何人都知道这里出了什么问题/这些字节可能来自哪里(除了它很可能来自 mono/fastcgi 中的错误这一事实之外)?

顺便说一句,这是新的控制器代码:

namespace Homepage.Controllers
{


    public class GalleryController : Controller
    {


        protected static string GetImageDirectory()
        {
            string bd = AppDomain.CurrentDomain.BaseDirectory;
            string strImageDirectory = System.IO.Path.Combine(bd,
            "Content");
            strImageDirectory =
            System.IO.Path.Combine(strImageDirectory, "images");
            strImageDirectory =
            System.IO.Path.Combine(strImageDirectory, "gallery");

            return strImageDirectory;
        } // End Function GetImageDirectory


        protected static string strImageDirectory = GetImageDirectory();


        public FileResult FullImage(string id)
        {
            string strFileName =
            System.IO.Path.Combine(strImageDirectory, id);

            //return new FilePathResult("CorrectFullPathAndFileName", "CorrectMime");
            //return File(strFileName, "image/jpg"); // Old
            return File(strFileName, "image/jpeg"); // New
        } // End Action FullImage



        public FileResult Thumb(string id)
        {
            //return Redirect(id);

            string strFileName =
            System.IO.Path.Combine(strImageDirectory, id);

            System.IO.Stream ms =
            Tools.Imaging.GetThumbnailStream(strFileName,
            System.Drawing.Imaging.ImageFormat.Png);
            return File(ms, "image/png");
            /*
            using (System.IO.Stream ms =
            Tools.Imaging.GetThumbnailStream(strFileName,
            System.Drawing.Imaging.ImageFormat.Png))
            {
                return File(ms, "image/png");
            }*/
        } // End Action Thumb


    } // End Class GalleryController : Controller


} // End Namespace Homepage.Controllers

Edit:
它变得陌生:
还有一个额外的序列

0d 0a 0d 0a 30 0d 0a 0d  0a 

在最后...

我刚刚做了十六进制转储,发现原始文件的文件大小(屏住呼吸):

00196b68

这里是十六进制转储(每个 8 MB):

规范格式(hexdump -C 001.jpg > 001.txt):
原始文件:http://www.daniel-steiger.ch/001.txt
损坏的文件:http://www.daniel-steiger.ch/001a.txt

纯转储(hexdump 001.jpg > 001_1.txt):
原始文件:http://www.daniel-steiger.ch/001_1.txt
损坏的文件:http://www.daniel-steiger.ch/001a_1.txt

嗯,损坏文件的十六进制转储为 5 MB,原始文件的十六进制转储为 8.2 MB...

我使用最新的稳定版 nginx:

sudo -s
nginx=stable # use nginx=development for latest development version
add-apt-repository ppa:nginx/$nginx
apt-get update 
apt-get install nginx

Tools.Imaging 的完整代码(同时将 Tools 重命名为 MvcTools,以匹配程序集命名空间)

using System;
using System.Text;


namespace MvcTools
{


    public class Imaging
    {

        //public static System.Drawing.Size m_sMaxThumbNailDimensions = new System.Drawing.Size(200, 200);
        public static System.Drawing.Size m_sMaxThumbNailDimensions = new System.Drawing.Size(300, 300);

        public static System.IO.Stream GetImageAsStream(
                                                 string strOrgFileName
                                                , System.Drawing.Imaging.ImageFormat ifOutputFormat
                                           )
        {
            return GetImageAsStream(strOrgFileName, ifOutputFormat, 1024);
        } // End Function GetImage


        public static System.IO.Stream GetImageAsStream(
                                                 string strOrgFileName
                                                ,System.Drawing.Imaging.ImageFormat ifOutputFormat
                                                ,int rez
                                           )
        {
            System.IO.MemoryStream ms = null;

            if (!System.IO.File.Exists(strOrgFileName))
                throw new System.IO.FileNotFoundException(strOrgFileName);

            try
            {

                using (System.Drawing.Image imgSourceImage = System.Drawing.Image.FromFile(strOrgFileName))
                {

                    ms = new System.IO.MemoryStream();
                    imgSourceImage.Save(ms, ifOutputFormat);
                    ms.Position = 0;
                } // End Using imgSourceImage

            } // End Try
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.GetType().ToString());
                System.Windows.Forms.MessageBox.Show(ex.Message);
                //Response.Write(ex.Message);
            } // End Catch

            return ms;
        } // End Function GetImageAsStream


        public static System.Drawing.Size GetThumbnailSize(string strOrgFileName)
        {
            System.Drawing.Size sThumbNailSizeToUse = new System.Drawing.Size();

            try
            {

                using (System.Drawing.Image imgSourceImage = System.Drawing.Image.FromFile(strOrgFileName))
                {
                    decimal decPixToSubstract = 0;
                    decimal decPercentage;

                    if (m_sMaxThumbNailDimensions.Width < imgSourceImage.Size.Width || m_sMaxThumbNailDimensions.Height < imgSourceImage.Size.Height)
                    {
                        if (imgSourceImage.Size.Width > imgSourceImage.Size.Height)
                        {
                            decPercentage = (((decimal)imgSourceImage.Size.Width - (decimal)m_sMaxThumbNailDimensions.Width) / (decimal)imgSourceImage.Size.Width);
                            decPixToSubstract = decPercentage * imgSourceImage.Size.Height;
                            sThumbNailSizeToUse.Width = m_sMaxThumbNailDimensions.Width;
                            sThumbNailSizeToUse.Height = imgSourceImage.Size.Height - (int)decPixToSubstract;
                        } // End if (imgSourceImage.Size.Width > imgSourceImage.Size.Height)
                        else
                        {
                            decPercentage = (((decimal)imgSourceImage.Size.Height - (decimal)m_sMaxThumbNailDimensions.Height) / (decimal)imgSourceImage.Size.Height);
                            decPixToSubstract = decPercentage * (decimal)imgSourceImage.Size.Width;
                            sThumbNailSizeToUse.Height = m_sMaxThumbNailDimensions.Height;
                            sThumbNailSizeToUse.Width = imgSourceImage.Size.Width - (int)decPixToSubstract;
                        } // End else of if (imgSourceImage.Size.Width > imgSourceImage.Size.Height)

                    } // End if (m_sMaxThumbNailDimensions.Width < imgSourceImage.Size.Width || m_sMaxThumbNailDimensions.Height < imgSourceImage.Size.Height)
                    else
                    {
                        sThumbNailSizeToUse.Width = imgSourceImage.Size.Width;
                        sThumbNailSizeToUse.Height = imgSourceImage.Size.Height;
                    } // End else of if (m_sMaxThumbNailDimensions.Width < imgSourceImage.Size.Width || m_sMaxThumbNailDimensions.Height < imgSourceImage.Size.Height)

                } // End Using imgSourceImage

            } // End Try
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                //Response.Write(ex.Message);
            } // End Catch

            return sThumbNailSizeToUse;
        } // End Sub GetThumbnailSize(string strOrgFileName)


        // http://stackoverflow.com/questions/7319842/mvc3-razor-thumbnail-resize-image-ideas
        // http://stackoverflow.com/questions/1528525/alternatives-to-system-drawing-for-use-with-asp-net/1528908#1528908
        public static void GenerateThumbnailFile(
                                        string strPhysicalPath,
                                        string strOrgFileName, string strThumbnailFileName,
                                        System.Drawing.Imaging.ImageFormat ifOutputFormat, int rez
                                     )
        {

            try
            {

                using (System.Drawing.Image imgSourceImage = System.Drawing.Image.FromFile(strOrgFileName))
                {
                    //System.Drawing.Image oImg = System.Drawing.Image.FromStream(fil.InputStream);

                    decimal decPixToSubstract = 0;
                    decimal decPercentage;

                    //default
                    System.Drawing.Size sThumbNailSizeToUse = new System.Drawing.Size();
                    if (m_sMaxThumbNailDimensions.Width < imgSourceImage.Size.Width || m_sMaxThumbNailDimensions.Height < imgSourceImage.Size.Height)
                    {
                        if (imgSourceImage.Size.Width > imgSourceImage.Size.Height)
                        {
                            decPercentage = (((decimal)imgSourceImage.Size.Width - (decimal)m_sMaxThumbNailDimensions.Width) / (decimal)imgSourceImage.Size.Width);
                            decPixToSubstract = decPercentage * imgSourceImage.Size.Height;
                            sThumbNailSizeToUse.Width = m_sMaxThumbNailDimensions.Width;
                            sThumbNailSizeToUse.Height = imgSourceImage.Size.Height - (int)decPixToSubstract;
                        } // End if (imgSourceImage.Size.Width > imgSourceImage.Size.Height)
                        else
                        {
                            decPercentage = (((decimal)imgSourceImage.Size.Height - (decimal)m_sMaxThumbNailDimensions.Height) / (decimal)imgSourceImage.Size.Height);
                            decPixToSubstract = decPercentage * (decimal)imgSourceImage.Size.Width;
                            sThumbNailSizeToUse.Height = m_sMaxThumbNailDimensions.Height;
                            sThumbNailSizeToUse.Width = imgSourceImage.Size.Width - (int)decPixToSubstract;
                        } // End else of if (imgSourceImage.Size.Width > imgSourceImage.Size.Height)

                    } // End if (m_sMaxThumbNailDimensions.Width < imgSourceImage.Size.Width || m_sMaxThumbNailDimensions.Height < imgSourceImage.Size.Height)
                    else
                    {
                        sThumbNailSizeToUse.Width = imgSourceImage.Size.Width;
                        sThumbNailSizeToUse.Height = imgSourceImage.Size.Height;
                    } // End else of if (m_sMaxThumbNailDimensions.Width < imgSourceImage.Size.Width || m_sMaxThumbNailDimensions.Height < imgSourceImage.Size.Height)

                    using (System.Drawing.Bitmap bmpThumbnail = new System.Drawing.Bitmap(sThumbNailSizeToUse.Width, sThumbNailSizeToUse.Height))
                    {
                        bmpThumbnail.SetResolution(rez, rez);
                        using (System.Drawing.Image imgThumbNail = bmpThumbnail)
                        {

                            using (System.Drawing.Graphics gGraphicsContext = System.Drawing.Graphics.FromImage(imgThumbNail))
                            {
                                gGraphicsContext.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                                gGraphicsContext.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                                gGraphicsContext.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                                System.Drawing.Rectangle rThumbnailDimension = new System.Drawing.Rectangle(0, 0, sThumbNailSizeToUse.Width, sThumbNailSizeToUse.Height);
                                gGraphicsContext.DrawImage(imgSourceImage, rThumbnailDimension);
                            } // End Using gGraphicsContext

                            imgThumbNail.Save(System.IO.Path.Combine(strPhysicalPath, strThumbnailFileName), ifOutputFormat);
                        } // End Using imgThumbNail

                    } // End Using bmpThumbnail

                } // End Using imgSourceImage

            } // End Try
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                //Response.Write(ex.Message);
            } // End Catch

        } // End Function GenerateThumbNail


        public static System.IO.Stream GetThumbnailStream(
                                                               string strOrgFileName
                                                             , System.Drawing.Imaging.ImageFormat ifOutputFormat
                                                         )
        {
            return GetThumbnailStream(strOrgFileName, ifOutputFormat, 1024);
        } // End Function GetThumbnailStream


        public static System.IO.Stream GetThumbnailStream(
                                      string strOrgFileName
                                     ,System.Drawing.Imaging.ImageFormat ifOutputFormat
                                     ,int rez
                                  )
        {

            System.IO.MemoryStream ms = null;

            try
            {

                using (System.Drawing.Image imgSourceImage = System.Drawing.Image.FromFile(strOrgFileName))
                {
                    decimal decPixToSubstract = 0;
                    decimal decPercentage;

                    System.Drawing.Size sThumbNailSizeToUse = new System.Drawing.Size();
                    if (m_sMaxThumbNailDimensions.Width < imgSourceImage.Size.Width || m_sMaxThumbNailDimensions.Height < imgSourceImage.Size.Height)
                    {
                        if (imgSourceImage.Size.Width > imgSourceImage.Size.Height)
                        {
                            decPercentage = (((decimal)imgSourceImage.Size.Width - (decimal)m_sMaxThumbNailDimensions.Width) / (decimal)imgSourceImage.Size.Width);
                            decPixToSubstract = decPercentage * imgSourceImage.Size.Height;
                            sThumbNailSizeToUse.Width = m_sMaxThumbNailDimensions.Width;
                            sThumbNailSizeToUse.Height = imgSourceImage.Size.Height - (int)decPixToSubstract;
                        } // End if (imgSourceImage.Size.Width > imgSourceImage.Size.Height)
                        else
                        {
                            decPercentage = (((decimal)imgSourceImage.Size.Height - (decimal)m_sMaxThumbNailDimensions.Height) / (decimal)imgSourceImage.Size.Height);
                            decPixToSubstract = decPercentage * (decimal)imgSourceImage.Size.Width;
                            sThumbNailSizeToUse.Height = m_sMaxThumbNailDimensions.Height;
                            sThumbNailSizeToUse.Width = imgSourceImage.Size.Width - (int)decPixToSubstract;
                        } // End else of if (imgSourceImage.Size.Width > imgSourceImage.Size.Height)

                    } // End if (m_sMaxThumbNailDimensions.Width < imgSourceImage.Size.Width || m_sMaxThumbNailDimensions.Height < imgSourceImage.Size.Height)
                    else
                    {
                        sThumbNailSizeToUse.Width = imgSourceImage.Size.Width;
                        sThumbNailSizeToUse.Height = imgSourceImage.Size.Height;
                    } // End else of if (m_sMaxThumbNailDimensions.Width < imgSourceImage.Size.Width || m_sMaxThumbNailDimensions.Height < imgSourceImage.Size.Height)


                    using (System.Drawing.Bitmap bmpThumbnail = new System.Drawing.Bitmap(sThumbNailSizeToUse.Width, sThumbNailSizeToUse.Height))
                    {
                        bmpThumbnail.SetResolution(rez, rez);
                        using (System.Drawing.Image imgThumbNail = bmpThumbnail)
                        {

                            using (System.Drawing.Graphics gGraphicsContext = System.Drawing.Graphics.FromImage(imgThumbNail))
                            {
                                gGraphicsContext.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                                gGraphicsContext.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                                gGraphicsContext.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                                System.Drawing.Rectangle rThumbnailDimension = new System.Drawing.Rectangle(0, 0, sThumbNailSizeToUse.Width, sThumbNailSizeToUse.Height);
                                gGraphicsContext.DrawImage(imgSourceImage, rThumbnailDimension);

                                ms = new System.IO.MemoryStream();
                                imgThumbNail.Save(ms, ifOutputFormat);
                                ms.Position = 0;
                            } // End Using gGraphicsContext

                        } // End Using imgThumbNail

                    } // End Using bmpThumbnail


                    /*
                    byte[] buffer = null;
                    using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
                    {
                        imgThumbNail.Save(ms, ifOutputFormat);
                        buffer = ms.ToArray();
                    }
                    */

                    // Exerts from Page_Load method 
                    //Response.ContentType = "image/" + extension;
                    //Response.OutputStream.Write(pBuffer, 0, pBuffer.Length);
                    //Response.End();

                    //imgThumbNail.Save(System.IO.Path.Combine(strPhysicalPath, strThumbnailFileName), ifOutputFormat);
                } // End Using imgSourceImage

            } // End Try
            catch (Exception ex)
            {
                //Console.WriteLine(ex.Message);
                System.Windows.Forms.MessageBox.Show(ex.Message);
                //Response.Write(ex.Message);
            } // End Catch

            //System.Windows.Forms.MessageBox.Show("image/" + ifOutputFormat.ToString().ToLower());
            return ms;
        } // End Function GenerateThumbNail


    } // End Class Imaging


} // End Namespace Tools

这似乎是一个涉及的错误分块传输编码 in

Class: System.Web.HttpResponse (or one of its dependencies)
Method: TransmitFile(string filename)

Edit:
构造函数中有这样一段代码:

if (worker_request != null)
      use_chunked = (worker_request.GetHttpVersion () == "HTTP/1.1");

修补它以检查 CGI(如果是 CGI,则服务器处理文件传输,因此可能没有从 FastCGI 服务器返回的分块编码)RFC 3875.

        internal HttpResponse (HttpWorkerRequest worker_request, HttpContext context) : this ()
        {
            WorkerRequest = worker_request;
            this.context = context;

#if !TARGET_J2EE
            if (worker_request != null)
            {

                if(worker_request.GetHttpVersion () == "HTTP/1.1")
                {
                    string GatewayIface = context.Request.ServerVariables["GATEWAY_INTERFACE"];
                    use_chunked = (GatewayIface == null || !GatewayIface.StartsWith("CGI"));
                }
                else
                    use_chunked = false;

            }
#endif
            writer = new HttpWriter (this);
        }

添加了补丁https://bugzilla.xamarin.com/show_bug.cgi?id=10001
在单声道 3.2.3 中已修复

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么图像开头有不需要的额外字节? 的相关文章

  • c和java语言中的换行符

    现在行分隔符取决于系统 但在 C 程序中我使用 n 作为行分隔符 无论我在 Windows 还是 Linux 中运行它都可以正常工作 为什么 在java中 我们必须使用 n 因为它与系统相关 那么为什么我们在c中使用 n 作为新行 而不管我
  • 如何读取扩展文件属性/文件元数据

    因此 我按照教程使用 ASP net core 将文件 上传 到本地路径 这是代码 public IActionResult About IList
  • Unix网络编程澄清

    我正在翻阅这本经典书籍Unix网络编程 https rads stackoverflow com amzn click com 0139498761 当我偶然发现这个程序时 第 6 8 节 第 179 180 页 include unp h
  • 将 System.Windows.Input.KeyEventArgs 键转换为 char

    我需要将事件参数作为char 但是当我尝试转换 Key 枚举时 我得到的字母和符号与传入的字母和符号完全不同 如何正确地将密钥转换为字符 这是我尝试过的 ObserveKeyStroke this new ObervableKeyStrok
  • 存储来自其他程序的事件

    我想将其他应用程序的事件存储在我自己的应用程序中 事件示例 打开 最小化 Word 或打开文件时 这样的事可能吗 运行程序 http msdn microsoft com en us library ms813609 aspx and 打开
  • 无法在 Windows 运行时组件库的 UserControl 中创建依赖项属性

    我想在用户控件内创建数据可绑定属性 这个用户控件包含一个 Windows 运行时组件 项目 我使用下面的代码来创建属性 public MyItem CurrentItem get return MyItem GetValue Current
  • ASP.NET:获取自 1970 年 1 月 1 日以来的毫秒数

    我有一个 ASP NET VB NET 日期 我试图获取自 1970 年 1 月 1 日以来的毫秒数 我尝试在 MSDN 中寻找方法 但找不到任何东西 有谁知道如何做到这一点 从 NET 4 6 开始 该方法ToUnixTimeMillis
  • Rx 中是否有与 Task.ContinueWith 运算符等效的操作?

    Rx 中是否有与 Task ContinueWith 运算符等效的操作 我正在将 Rx 与 Silverlight 一起使用 我正在使用 FromAsyncPattern 方法进行两个 Web 服务调用 并且我想这样做同步地 var o1
  • PlaySound 可在 Visual Studio 中运行,但不能在独立 exe 中运行

    我正在尝试使用 Visual Studio 在 C 中播放 wav 文件 我将文件 my wav 放入项目目录中并使用代码 PlaySound TEXT my wav NULL SND FILENAME SND SYNC 我按下播放按钮 或
  • 如何使用 watin 中的 FileUploadDialogHandler 访问文件上传对话框

    我正在使用 IE8 和 watin 并尝试通过我的网页测试上传文件 我不能简单地使用 set 方法设置上传文件 例如 ie FileUpload Find ById someId Set C Desktop image jpg 因为上传文本
  • 批量更新 SQL Server C#

    我有一个 270k 行的数据库 带有主键mid和一个名为value 我有一个包含中值和值的文本文件 现在我想更新表格 以便将每个值分配给正确的中间值 我当前的方法是从 C 读取文本文件 并为我读取的每一行更新表中的一行 必须有更快的方法来做
  • 上下文敏感与歧义

    我对上下文敏感性和歧义如何相互影响感到困惑 我认为正确的是 歧义 歧义语法会导致使用左推导或右推导构建多个解析树 所有可能的语法都是二义性的语言是二义性语言 例如 C 是一种不明确的语言 因为 x y 总是可以表示两个不同的事物 如下所述
  • 如何使用 Mongodb C# 驱动程序连接多个集合

    我需要将 3 个集合与多个集合合并在一起 lookup我在 C 驱动程序中尝试过 它允许我 lookup用户采集但无法执行秒 lookup用于设置集合 有人可以帮忙吗 db Transactions aggregate lookup fro
  • 将 log4net 与 Autofac 结合使用

    我正在尝试将 log4net 与 Autofac 一起使用 我粘贴了这段代码http autofac readthedocs org en latest examples log4net html http autofac readthed
  • CheckboxFor 不与嵌套对象绑定

    当模型中嵌套的对象中定义属性时 CheckBoxFor 不受限制 这是一个例子 我有一个SearchOptions模型包含一个List
  • C++ 密码屏蔽

    我正在编写一个代码来接收密码输入 下面是我的代码 程序运行良好 但问题是除了数字和字母字符之外的其他键也被读取 例如删除 插入等 我知道如何避免它吗 特q string pw char c while c 13 Loop until Ent
  • 为什么在setsid()之前fork()

    Why fork before setsid 守护进程 基本上 如果我想将一个进程与其控制终端分离并使其成为进程组领导者 我使用setsid 之前没有分叉就这样做是行不通的 Why 首先 setsid 将使您的进程成为进程组的领导者 但它也
  • Linq-to-entities,在一个查询中获取结果+行数

    我已经看到了有关此事的多个问题 但它们已经有 2 年 或更长 的历史了 所以我想知道这方面是否有任何变化 基本思想是填充网格视图并创建自定义分页 所以 我还需要结果和行数 在 SQL 中 这将类似于 SELECT COUNT id Id N
  • 使用 GROUP 和 SUM 的 LINQ 查询

    请帮助我了解如何使用带有 GROUP 和 SUM 的 LINQ 进行查询 Query the database IEnumerable
  • 如何正确使用 std::condition_variable?

    我很困惑conditions variables以及如何 安全 使用它们 在我的应用程序中 我有一个创建 gui 线程的类 但是当 gui 是由 gui 线程构造时 主线程需要等待 情况与下面的函数相同 主线程创建互斥体 锁和conditi

随机推荐

  • 连接 SQLite 数据库失败

    我正在尝试在 Java Applet 中访问我的 SQLite3 数据库 当我运行代码来连接到数据库时 出现此错误没有找到适合 a db 的驱动程序 我该如何修复它 现在我不完全确定我实际上已经安装了正确的驱动程序 我会告诉你我做了什么 你
  • 如何使用 DataTemplate + 触发器在视图之间切换

    我有一个要求 其中用户可以切换以树或数据网格中的文本或流程图的形式查看分层数据 用户可以通过单击切换按钮来完成此操作 该按钮显示 切换模式 我希望以这样一种方式来完成这一切 即它只能在视图中处理 因为所有三种情况下的 ViewModel 都
  • 使用php sdk扩展权限

    我正在使用 php sdk 开发 Facebook 应用程序 我想从我的应用程序的用户那里获取一些扩展权限 由于这是用户登录 Facebook 后进入的应用程序 那么当用户访问我的页面时我如何获得扩展权限 我们无法放置可以获取权限的登录按钮
  • jOOQ不生成源

    我试图将 jOOQ 包含到我的代码中 但是没有生成任何代码 执行时mvn clean generate sources 不生成任何源 我希望它创建一个Category类 其定义如下schema sql file CREATE TABLE I
  • Java 原始数据膨胀异常

    我试图在 java 中解码 JWT 有效负载 但该有效负载被压缩 放气 zip DEF java util zip DataFormatException 标头检查不正确 private static byte decompress byt
  • 空手道 - 如何从单个主要功能调用多个外部功能

    Feature Principal feature Background url http example com Scenario Feature calling def inputTable call read input table
  • LDAP 的连接字符串是什么?

    这是我需要如何使用它 string tmpDirectory String Format LDAP ou 0 dc 1 dc 2 parentOrganizationUnit domainName domainExtension 当我尝试使
  • 如何创建一个可以将按键发送到控件而不窃取焦点的按钮 - 虚拟键盘

    如何制作一个可以将键发送到 datagridview 的按钮 因此我需要以某种方式将 datagridview 返回到其失去焦点之前的状态 我来解释一下问题 我有一个带有 datagridview 和一些按钮的表单 我可以点击按钮 它会输入
  • 防止conda自动降级python包

    I had problems with pandas datareader软件包 v0 8 1 为了解决我的问题 我必须通过运行以下命令将软件包升级到较新的版本 0 9 conda install c anaconda pandas dat
  • 启用禁用表格行中的控件

    我想在选中相应的 chkView 时启用该行的编辑和删除复选框 如果未选中则禁用它们 这段代码一开始根本就没有触发 我哪里错了 http jsfiddle net 75rVH 1 HTML table tr td td tr table
  • 将 ifelse 函数应用于系统发育扇的颜色提示

    作为系统发育爱好者 我想通过应用 if 语句对提示 类似于本例中的 62 个物种 进行颜色编码 我目前正在使用以下代码 试图将与 O 相关的所有物种着色为深绿色 ColourIf ifelse LU O blue darkgreen tif
  • 检测另一个进程的位数(在 Windows 中)

    如何检测 Windows 中是否有另一个进程以 32 64 位运行 我知道如何为我自己的流程执行此操作 但不知道如何为不同的流程执行此操作 任何语言的提示或解决方案都可以 谢谢 查看是Wow64进程
  • 将列表运算符“in”与浮点值一起使用

    我有一个包含浮点数的列表 每个数字有 3 位小数 例如 474 259 如果我像这样验证列表中的号码 if 474 259 in list sample print something 然后显示消息 但如果我从另一个列表中取出数字并将其四舍
  • clojure 宏生成函数

    我正在尝试编写一个将生成 n 个函数的宏 这是我到目前为止所拥有的 only defined this because if I inline this into make placeholders it s unable to expan
  • 如何从 java 程序运行 mvn 命令?

    我正在构建一个 Java 程序 用于在服务器端自动执行一个过程 通常我 cd 到 Desktop GIT 并使用此 Maven 命令 mvn Integration test DskipTests P Interactive e 我正在构建
  • x86 masm 你好世界

    我正在尝试使用 VS 2010 附带的 ML 和 LINK 在 Windows 上编译一个 hello world MODEL FLAT STACK 4096 data msg db Hello World 0 code INCLUDELI
  • 有没有办法永久关闭 Composer 的 ANSI?

    当我在 shell 中运行 Composer 时 它会将所有文本呈现为深黄色背景色 因此几乎无法阅读 有一个选项可以提供 no ansi与我运行的每个命令争论 但这看起来确实很痛苦 有没有办法将其默认关闭 或者甚至将颜色更改为更易读的颜色
  • 如何在 D3 中的多个单独过渡多边形之间添加过渡延迟?

    原始代码可以在以下位置找到 http bl ocks org Guerino1 3a51eeb95d3a8345bc27370e8c9d5b77 我有许多多边形正在转换到 svg 画布上 从左到右 位于 HTML 页面的底部 我用来创建 V
  • SQL Server 行值作为列名数据透视表?

    我在 SQL Server 2008 中有以下视图 DEPT EMP ID EMP NAME P DATE HOURS WORKED 我希望视图是这样的 DEPT EMP ID EMP NAME 2012 09 28 2012 09 29
  • 为什么图像开头有不需要的额外字节?

    问题 我为我兄弟制作了一个主页 可以在这里访问 http www daniel steiger ch 它在 Linux 上使用 Microsoft ASP NET MVC3 和 mono 3 通过 fastcgi 和 nginx 加上我自己