Solution to error 1 error c1189: # error: "include 'stdafx. H' before including this file
If this error occurs in. DLL, but compile. DLL no problem, when. this error occurs when the DLL is included in project B to which it is to be used and the project containing it is compiled.
If you have added the following content to the stdafx. h file in Project BCode: You can.
# Pragma once
# DEFINE _ afxdll
# Include "targetver. H"
# Include <stdio. h>
# Include <tchar. h>
// Todo: Reference additional headers your program requires here
// Stdafx. h: Include File for standard system include files,
// Or project specific include files that are used frequently,
// Are changed infrequently
# Ifndef vc_extralean
# Define vc_extralean // exclude rarely-used stuff from Windows Headers
# Endif
# Include "targetver. H"
# DEFINE _ atl_cstring_explicit_constructors // some cstring constructors will be explicit
# Include <afxwin. h> // MFC core and standard components
# Include <afxext. h> // MFC extensions
# Ifndef _ afx_no_ole_support
# Include <afxole. h> // MFC Ole classes
# Include <afxodlgs. h> // mfc ole Dialog classes
# Include <afxdisp. h> // MFC automation classes
# Endif // _ afx_no_ole_support
# Ifndef _ afx_no_db_support
# Include <afxdb. h> // mfc odbc database classes
# Endif // _ afx_no_db_support
# Ifndef _ afx_no_dao_support
# Include <afxdao. h> // mfc dao database classes
# Endif // _ afx_no_dao_support
# Ifndef _ afx_no_ole_support
# Include <afxdtctl. h> // MFC support for Internet Explorer 4 common controls
# Endif
# Ifndef _ afx_no_afxcmn_support
# Include <afxcmn. h> // MFC support for Windows Common controls
# Endif // _ afx_no_afxcmn_support
# Include <afxcontrolbars. h>
/*
// Stdafx. h: Include File for standard system include files,
// Or project specific include files that are used frequently,
// Are changed infrequently
# Pragma once
# Ifndef vc_extralean
# Define vc_extralean // exclude rarely-used stuff from Windows Headers
# Endif
# Include "targetver. H"
# DEFINE _ atl_cstring_explicit_constructors // some cstring constructors will be explicit
# Include <afxwin. h> // MFC core and standard components
# Include <afxext. h> // MFC extensions
# Ifndef _ afx_no_ole_support
# Include <afxole. h> // MFC Ole classes
# Include <afxodlgs. h> // mfc ole Dialog classes
# Include <afxdisp. h> // MFC automation classes
# Endif // _ afx_no_ole_support
# Ifndef _ afx_no_db_support
# Include <afxdb. h> // mfc odbc database classes
# Endif // _ afx_no_db_support
# Ifndef _ afx_no_dao_support
# Include <afxdao. h> // mfc dao database classes
# Endif // _ afx_no_dao_support
# Ifndef _ afx_no_ole_support
# Include <afxdtctl. h> // MFC support for Internet Explorer 4 common controls
# Endif
# Ifndef _ afx_no_afxcmn_support
# Include <afxcmn. h> // MFC support for Windows Common controls
# Endif // _ afx_no_afxcmn_support
*/