# vtkMFCWindow crashes in debug mode

**URL:** https://discourse.vtk.org/t/vtkmfcwindow-crashes-in-debug-mode/4147
**Category:** Support
**Created:** [September 4, 2020, 5:43am UTC](https://discourse.vtk.org/t/vtkmfcwindow-crashes-in-debug-mode/4147 "2020-09-04T05:43:45Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ayush.arudra](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/ed655f/32.png) [@ayush.arudra](https://discourse.vtk.org/u/ayush.arudra)
#### Post date: [September 4, 2020, 5:43am UTC](https://discourse.vtk.org/t/vtkmfcwindow-crashes-in-debug-mode/4147/1 "2020-09-04T05:43:46Z")

</div>

Hi there,

I am using vtkMFCWindow object to link vtk to MFC. I create a Cstatic object and pass it on to the constructor as in

m\_vtkmfcWindow = new vtkMFCWindow (pWnd);

This code works well in release mode, but crashes in debug mode. The following is the error message:  
Debug Assertion Failed!  
Program: Windows\system32\mfc140d.dll  
File: \agent\_work\2\s\src…\afxwin1.inl  
Line 21  
Further checking reveals the application executable has triggered a break point at line 88 of vtkMFCWindow.cpp  
BOOL created = CWnd::Create(nullptr,…)

Would be grateful for any help.

Platform Windows 10, 2004  
VTK version 8.2  
Visual Studio 2015 professional.

Thanks in advance.

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.vtk.org/u/flaviu2)
#### Post date: [September 4, 2020, 6:40am UTC](https://discourse.vtk.org/t/vtkmfcwindow-crashes-in-debug-mode/4147/2 "2020-09-04T06:40:28Z")

</div>

If you are saying that is run in release, then you need carefully check the difference settings between Debug and Release. Eventually, you can post here the code where you created and placed vtkMFCWindow on your CStatic object.

---

<div class="post-metadata">

### Author: ![ayush.arudra](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/ed655f/32.png) [@ayush.arudra](https://discourse.vtk.org/u/ayush.arudra)
#### Post date: [September 4, 2020, 9:42am UTC](https://discourse.vtk.org/t/vtkmfcwindow-crashes-in-debug-mode/4147/3 "2020-09-04T09:42:00Z")

</div>

Thanks for your prompt reply. I will check the settings and revert along with the code I used to create the window. Preliminary observation suggests the create window function returns a funny value causing the assert statement to crash.

---

<div class="post-metadata">

### Author: ![ayush.arudra](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/ed655f/32.png) [@ayush.arudra](https://discourse.vtk.org/u/ayush.arudra)
#### Post date: [September 5, 2020, 6:15am UTC](https://discourse.vtk.org/t/vtkmfcwindow-crashes-in-debug-mode/4147/4 "2020-09-05T06:15:55Z")

</div>

Thanks a lot for your advice. The problem is solved. I had to set character set under general configuration to use multi-byte character set and remove any reference to unicode from the pre compiled header file, stdafx.h.

Once again thanks a lot for your timely help.

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.vtk.org/u/flaviu2)
#### Post date: [September 6, 2020, 2:46pm UTC](https://discourse.vtk.org/t/vtkmfcwindow-crashes-in-debug-mode/4147/5 "2020-09-06T14:46:56Z")

</div>

You are wellcome 🙂
