Today
Total
Recent Posts
Recent Comments
Archives
05-19 03:21
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
반응형
관리 메뉴

UD_park's IT story

[Error] CS0103 'Process' 이름이 현재 컨텍스트에 없습니다. 본문

IT - For Data/Error

[Error] CS0103 'Process' 이름이 현재 컨텍스트에 없습니다.

kingllzn 2018. 7. 13. 15:33
반응형
SMALL

이번에 다룰 오류는

 

CS0103 'Process' 이름이 현재 컨텍스트에 없습니다.

 

입니다

 

비교적 간단한 오류이니 일단

소스부터 보시면서 얼른 설명하고

넘어가보겠습니다

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinformLabelExam01
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label3_Click(object sender, EventArgs e)
        {
            label3.BackColor = (label3.BackColor == Color.Blue) ?
                        Color.Azure : Color.Blue;
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start("http://www.csharpstudy.com");
        }
    }
}

 

위 소스에서 바로 28번 줄인

Process.Start에서 에러가 났습니다

 

오류의 원인과 해결은 간단합니다

 

 

왜냐하면 Process라는 함수를 쓰기 위해선

using System.Diagnostics;를

입력해서 Diagnostics에서

Process라는 함수를 가져오고 난 후에야

28번 줄 소스가 에러없이 돌아갈 수 있기

때문입니다

 

쉽게 얘기하자면 요리를 하려는데

도마 위에 재료없이 허공에 칼질하려니

에러가 발생하는 것이라고 생각하시면

될 것같습니다

 

그렇기 때문에 요리하기 전에

재료를 세팅해주는 보조 역할을 수행하는

using System.Diagnostics;를

코드에 윗부분 추가하여

재료를 가져와야 에러가 해결이 됩니다

 

그럼 아래의 오류를 해결한 소스코드를

보여드리겠습니다

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;

namespace WinformLabelExam01
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label3_Click(object sender, EventArgs e)
        {
            label3.BackColor = (label3.BackColor == Color.Blue) ?
                        Color.Azure : Color.Blue;
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start("http://www.csharpstudy.com");
        }
    }
}

 

항상 컨텍스트가 없다고 오류가

발생한다면 using으로 미리 선언해야

할 것들 중에서 빼먹은게 있는지

꼭 체크 해주시면

위와 같은 오류 발생이

훨씬 줄어들것으로 생각됩니다

 

 

그럼 이상으로

CS0103 'Process' 이름이 현재 컨텍스트에 없습니다.

오류에 대한 포스팅을 마치도록 하겠습니다

 

 

 

혹시 다른것에 대해 궁금하신게

있으시다면

댓글에 달아주세요

 

아는것이면 친절하게 쉽게

모르는것이면 또 제가 알아내서

친절하게 쉽게 포스팅해서

설명해드리겠습니다

 

 

 

 

 

반응형
LIST
Comments