Click here to Skip to main content
15,902,112 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I have a problem with vshost.exe. At the beginning of my using this code, the program runs properly, but after I copy the program, now comes a warning like this: vshost.exe has stopped working
What makes this happen? code as follows:

YIQprocess2 YIQ2 = new YIQprocess2();
YIQ2.Image = EditImage;
YIQ2.YIQmethod2();
//this.Invalidate();
cetakgambar();


This is my class :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;

namespace SkinCancerR01.BusinessRule
{
    public class YIQprocess2
    {
        public Bitmap Image { get; set; }
        public int seed, t, nilaikecil, nilaibesar, sementara;

        public void YIQmethod2()
        {
            Bitmap EditImage = this.Image;
            // GDI+ still lies to us - the return format is BGR, NOT RGB.
            BitmapData bmData = EditImage.LockBits(new Rectangle(0, 0, EditImage.Width, EditImage.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            int stride = bmData.Stride;
            System.IntPtr Scan0 = bmData.Scan0;

            unsafe
            {
                byte* p = (byte*)(void*)Scan0;

                int nOffset = stride - EditImage.Width * 3;

                byte red, green, blue, Yx, Ix, Qx;

                for (int y = 0; y < EditImage.Height; ++y)
                {
                    for (int x = 0; x < EditImage.Width; ++x)
                    {
                        blue = p[x];
                        green = p[x + 1];
                        red = p[x + 2];
                        Yx = (byte)(.299 * red + .587 * green + .114 * blue);
                        Ix = (byte)(.596 * red - .275 * green - .321 * blue);
                        Qx = (byte)(.212 * red - .528 * green + .311 * blue);

                        if ((y == 0) && (x == 0))
                        {
                            nilaikecil = Yx;
                            nilaibesar = Yx;
                        }
                        else
                        {
                            if (Yx < nilaikecil)
                            {
                                nilaikecil = Yx;
                            }
                            else if (Yx > nilaibesar)
                            {
                                nilaibesar = Yx;
                            }
                        }
                        p += 3;
                    }
                    p += nOffset;
                }
            }

            t = (nilaibesar - nilaikecil) / 3;

            unsafe
            {
                byte* p = (byte*)(void*)Scan0;

                int nOffset = stride - EditImage.Width * 3;

                byte red, green, blue, Yx, Ix, Qx;

                for (int y = 0; y < EditImage.Height; ++y)
                {
                    for (int x = 0; x < EditImage.Width; ++x)
                    {
                        blue = p[x];
                        green = p[x + 1];
                        red = p[x + 2];
                        Yx = (byte)(.299 * red + .587 * green + .114 * blue);
                        Ix = (byte)(.596 * red - .275 * green - .321 * blue);
                        Qx = (byte)(.212 * red - .528 * green + .311 * blue);

                        //supaya setiap y baru seed juga baru
                        if ((x == 0) || (seed == 0))
                        {
                            //mengambil value seed
                            seed = Yx;
                        }
                        else
                        {
                            sementara = Yx - seed;
                            sementara = Math.Abs(sementara);
                            if (sementara >= t)
                            {
                                for (int i = 0; i < 2; ++i)
                                {
                                    p[x] = p[x + 1] = p[x + 2] = 255;
                                    ++x;
                                }

                                seed = 0;
                            }
                        }

                        p += 3;
                    }
                    p += nOffset;
                }
            }

            EditImage.UnlockBits(bmData);
        }
    }
}
Posted
Updated 12-Jul-17 17:18pm
v3
Comments
Indivara 21-Jan-11 8:52am    
Minor edit - formatting & title
gunkrr 21-Jan-11 9:44am    
thank you

You should find this vshost.exe under the bin folder or the debug folder of your application.This is not required when you deploy the application.Hence try deleting this & then run again.

You can configure Visual Studio so that the vshost.exe file is not created by the following steps.
1. Right Click on Project in Solution Explorer and Select Properties

2. Click on the Debug Tab if it’s not already selected.

3. Uncheck the Enable the Visual Studio Hosting Process checkbox under the Enable Debuggers Section
 
Share this answer
 
Comments
Nish Nishant 21-Jan-11 12:50pm    
Voted 5, proposed as answer.
Anupama Roy 21-Jan-11 12:52pm    
Thank you!
Espen Harlinn 21-Jan-11 13:32pm    
Interesting - 5+ - isn't this the process that enables debugging of 64-bit processes using 32-bit Visual Studio?
AjitRaje 22-Apr-13 2:15am    
thanks friends for proper solution
Dhiren M 27-Mar-18 3:23am    
Solved my problem. I tried some other solutions from other articles but didnt work. This solution is working for me.
I've re-created a project based on your code -- it's working.

You should have supplied more code, because your main code lines did not compile. I had to add some bitmap instead of EditImage and remove cetakgambar() which is missing. This does not matter: the code runs under Visual Studio.

Steps: 1) new project created; 2) added reference System.Drawing; 3) added your class; 4) added your main code with changed (see above); 5) in project options, allowed unsafe.

That's it. You need to do few things:
1) For now, just re-created you project.
2) Learn how to move projects around and support then; I hope you know the most, still there must be a catch, so:
2a) Learn how to work with all path names relative to the location of your project file; no absolute names;
2b) Sort out true source code from everything else, intermediate, user-specific, binaries, etc... Always delete non-source code before you move, copy, pack, submit your project. A hint: with C# project, remove "bin", "obj", "*.user", "*.suo".
2c) From the other hand, when garbage is removed, move all file structure accurately as is.
3) Stop working without revision control system -- free, open source, local (or not), easy to use. It will safe you a lot of time and keep out of major trouble.

So, I don't know the exact answer on what happened (because you did not share detail on how you messed up), but I explained how recover and to avoid the problem in future.

Good luck.
 
Share this answer
 
v3
Comments
Espen Harlinn 21-Jan-11 13:21pm    
5+ Good approach
Sergey Alexandrovich Kryukov 22-May-12 10:57am    
Thank you, Espen.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900