본문 바로가기

Programming/C#/Xna/Kinect/WPF

C# Attempted to read or write protected memory 에러 Managed Code에서 "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." 와 같은 오류가 발생하는 것은 흔하지 않다. 이것은 Native Code에서 잘못된 메모리를 참조하는 경우에 발생하는 데, 아시다시피 Managed환경에서는 포인터를 이용한 직접적인 메모리를 다루는 경우가 거의 없기 때문에 경험할 일이 없을 것이다. 하지만, PInvoke 와 같은 Interop 를 사용하는 경우라면 달라질 수 있다. 이는 결국 Native COM을 Managed 에서 사용하는 것이므로, 여전히 Native COM에서의 문제가 Managed환경으로 전달되었을 때, Access .. 더보기
RGB 색상표 (16진수) 변환 p, td, ul, ol, li { font-size:12px; line-height:140%; margin-top:0; margin-bottom:0; } body { font-size:12px; }색상표의 16진수 String 값을 Color 구조체로 변환하여 사용 string bb = "H808080";int r = Convert.ToInt32(bb.Substring(1, 2), 16);int g = Convert.ToInt32(bb.Substring(3, 2), 16);int b = Convert.ToInt32(bb.Substring(5, 2), 16); Color c = Color.FromArgb(r, g, b); pictureBox1.BackColor = c; for (KnownColor kc .. 더보기
XNAExtras로 XBOX360에 폰트를 출력해 보자!! #1 * 주의 사항 0. 이글에 대한 모든 권리는 저에게 있습니다. ( 소스에 대한 권리는 개발자 분에게 있습니다. ) 1. 이글을 퍼가실때는 아래 댓글로 어디에 퍼가시는지 반드시 알려 주십시요. 2. 개인블로그등 비상업적인 목적이라면 출처만 밝혀주시면 모두 허용하겠습니다. 단 상업적인 목적이나 상업적인 싸이트에서 게시하실 경우 저에게 연락해 주십시요. 3. 오탈자나 잘못된 부분들도 모두 아래 댓글에 달아 주십시요 ^^; 부탁드립니다. 4. 퍼가실때 이 메시지와 퍼온 주소 (http://nomoreid.egloos.com/2910890)를 빠뜨리지 말아주십시요. 5. 아래 소스틑 아직 XBOX360 에서 테스트 해보지 못했습니다. 기술적으로 안될 이유는 없어 보입니다만 혹시나 안될때는 저에게 알려 주십시요. .. 더보기
C# StreamReader 에서의 한글 Encoding 문제 오늘은 개발자 한 분이... ASP.NET 에서 한글이 포함된 HTML 텍스트를 로딩했는 데, 한글이 깨진다는 문제를 들고 왔습니다. 텍스트 파일의 특성상, 가볍게 다음과 같은 코드로 마무리를 지었던 것입니다. string fileContent = null; using ( StreamReader sr = new StreamReader( filePath ) ) { fileContent = sr.ReadToEnd(); sr.Close(); } 저 역시, 위의 코드를 보고 너무 표준적인 코드라 ^^ 문제가 없어 보였지요. .NET 에서는 문자열 처리를 명시적으로 지정하지 않는 한, 기본적으로 "System.Text.UTF8Encoding" 으로 처리를 합니다. 문제는 거기서 발생을 하지요. 해당 HTML 텍스.. 더보기
[XNA] Scrolling background images horizontally across the screen If you're working on 2D games, at some point you're going to want to know how to create a scrolling background. This tutorial will cover setting up a horizontally scrolling background that auto-scrolls behind your character. Let's go ahead and get started. Creating the new game project:We are going to be using the "Sprite" class we created in the tutorial "Creating a 2D Sprite". Instead of creat.. 더보기
[XNA] A Simple 2D Camera What is a camera? Intuitively we know what a camera is: simply a way to show the action.A Camera allows us to deal with the display of the action in a detached way from the action.ImplementationI like to start with what we are trying to achieve. For the purposes of this post, I want to have two cameras showing the same action at different zoom levels, like this:In this case we want 2 cameras, wi.. 더보기
[C#] String Split (Unity3D) string a = "文字列A";string b;b = a.Substring(「開始位置」,「取り出す文字数」);開始位置は0から始まる全角も1文字として数えられますb = a.Substring(0, 2); //先頭から2文字→文字b = a.Substring(1, 2); //2文字目から3文字→字列b = a.Substring(1); //3文字目以降全部→字列A●特定の文字列で分割string a = "文字列A\n文字列B";string[] b;string c;b = a.Split("\n"[0]); //改行コードで分割c = b[0]; //cには『文字列A』が入る区切り文字を複数にしたい場合は,配列にすれば可能ですstring a = "文字列A\n文字列B";string[] b;string c;string[] KUG.. 더보기
[Kinect] 키넥트 1.6 에서 프로그램 종료시 프리즈 되는 현상 I have the same problem.In my debugging i noticed that problem appears only when i use skeleton stream.Add this line:sensor.SkeletonStream.Disable();before:this.sensor.Stop(); this.sensor = null;Application hangs on line where Skeleton stream is disabled.I am using SDK 1.6.Interesting is that from moment error happens once, it will hang always until i reconnect camera from USB port. ->Installed .. 더보기
[C#] 컴파일러와 dll파일 초천재의 블로그 | 초천재 http://idkhs04.blog.me/401088623621. 컴파일러 프로그래밍 언어를 한답시고 컴파일러를 모른다는것은영어알파벳 자체를 모르는 사람이 가이드없이 영어권 나라에 가는 경우입니다.물론.....사람사는것은 워낙 변수가 많아서 바디 랭귀지가 가능하긋지만 그냥 받아들였으면 합니다. a. 컴파일러란 대체 뭔가? 1. 프로그래밍을 한다는것은 컴퓨터 cpu에게 명령을 하기위해서 인데, 실제적으로 은밀하게 보자면 우리는 cpu에게 우리가 직접적으로 명령문을 내리기 위해서가 아닙니다 그럼 누구에게 알아듣는 코드를 작성한다는것일까요? 컴파일러입니다. 컴파일러가 없는 프로그래밍 랭귀지는 거의 없을겁니다. 물론....초저급언어(low level language)인 어셈블리어나 기.. 더보기
[C#] ListView에서 Tag의 활용 ListViewItem li; li = new ListViewItem(); li.Text = each.c_time.ToString() + " " + "L(" + each.c_number + ") " + each.c_scale.ToString(); /* 이런식으로 Tag에 일종의 포인터를 저장해 놓을 수 있다. */li.Tag = t_add.c_noteList.ElementAt(t_add.c_noteList.Count - 1); listbox.Items.Add(li); 더보기