Aslinda tum olay MFC projesinde GDI+ kullanmayla basladi. GDI+ kullanmaya basladiginizda Gdiplus::GdiplusStartup, isiniz bittiginde Gdiplus::GdiplusShutdown fonksiyonlarini cagirmalisiniz. Projede devamli GDI+ kullandigim icin InitInstance() icinde start, ExitInstance() icinde stop yaptim.

 

////////////////////////////////////////////////////////////////////////////
// GDI+ Start Stop functions
ULONG_PTR gdiplusToken;
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartupOutput gdiplusStartupOutput;
BOOL StartGdiPlus()
{
	if (Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL))
	{
		MessageBox(NULLTEXT("GDI+ failed to start up!"), TEXT("Error!"), MB_ICONERROR);
		return FALSE;
	}
	return TRUE;
}
void StopGdiPlus()
{
	Gdiplus::GdiplusShutdown(gdiplusToken);
}

////////////////////////////////////////////////////////////////////////////
// CActivexApp::InitInstance - DLL initialization

BOOL CActivexApp::InitInstance()
{
	BOOL bInit = COleControlModule::InitInstance();

	if (bInit)
	{
		CoInitialize(NULL);
		StartGdiPlus();

	}

	return bInit;
}

////////////////////////////////////////////////////////////////////////////
// CActivexApp::ExitInstance - DLL termination

int CActivexApp::ExitInstance()
{
	// TODO: Add your own module termination code here.
	StopGdiPlus();
	CoUninitialize();
	return COleControlModule::ExitInstance();
}

/////////////////////////////////////////////////////////////////////////////

 

Buraya kadar hersey normal. Compile ederken de herhangi bir sorun yok. Regsvr32.exe ile register ederken “DllRegisterServer in ActiveX.ocx succeeded” mesajini da aldim. Fakat Task Manager dan baktigimda Regsvr32.exe nin bir turlu sonlanmadigini gordum. Bir kac denemeden sonra init edilen ActiveX in bir turlu FreeLibrary ile bir turlu sonlandirmadigini farkettim.

Muhtemelen Regsvr32.exe birden fazla instance aliyor, boylece birden fazla StartGdiPlus() calisiyor. Sorunun ana kaynagi bu.

Bu konuyu cozmek icin sadece tek instance alinmasini saglamak gerekti. Bunun icin static bir boolean degisken yetti. Tum sorunlar cozuldu.

Son hali asagidadir.

 

////////////////////////////////////////////////////////////////////////////
// GDI+ Start Stop functions
ULONG_PTR gdiplusToken;
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartupOutput gdiplusStartupOutput;
static bool isGdiplusAlreadyStarted = false;
BOOL StartGdiPlus()
{
	if (isGdiplusAlreadyStarted == false)
	{
		return FALSE;
	}
	if (Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL))
	{
		MessageBox(NULLTEXT("GDI+ failed to start up!"), TEXT("Error!"), MB_ICONERROR);
		return FALSE;
	}
	return TRUE;
}
void StopGdiPlus()
{
	Gdiplus::GdiplusShutdown(gdiplusToken);
}

////////////////////////////////////////////////////////////////////////////
// CActivexApp::InitInstance - DLL initialization

BOOL CActivexApp::InitInstance()
{
	BOOL bInit = COleControlModule::InitInstance();

	if (bInit)
	{
		CoInitialize(NULL);
		StartGdiPlus();

	}

	return bInit;
}
////////////////////////////////////////////////////////////////////////////
// CActivexApp::ExitInstance - DLL termination

int CActivexApp::ExitInstance()
{
	// TODO: Add your own module termination code here.
	StopGdiPlus();
	CoUninitialize();
	return COleControlModule::ExitInstance();
}

/////////////////////////////////////////////////////////////////////////////

Pointer i eger asagidaki gibi loop bittikten sonra sileyim derseniz cok fena yanilirsiniz. Memory siser, siser, siser. Eger GDI object ise cok beklemenize de gerek kalmaz 🙂

Yanlis
  1. Brush* brush;
  2. for (int i = 0; i < 100; i++)
  3. {
  4.      brush = new Brush(Color.Red, 1.0f);
  5. }
  6. delete brush;

Dogrusu pointer i her kullanimdan sonra, loop icinde, silmektir.

Dogru
  1. Brush* brush;
  2. for (int i = 0; i < 100; i++)
  3. {
  4.     brush = new Brush(Color.Red, 1.0f);
  5.     delete brush;
  6. }

— Disable all the constraints in database
EXEC sp_msforeachtable “ALTER TABLE ? NOCHECK CONSTRAINT all”

EXEC sp_msforeachtable “delete from ? ”

— Enable all the constraints in database
EXEC sp_msforeachtable “ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all”


";
?>


";
}
else{
echo "Directory can't created
";
}
}
else{
echo "Directory already exists
";
}
$archname = $path.'/'.$domainName.'_files_' . date("Y-m-d-H-i-s") . '.tar.gz';

$command .= 'tar -cvj ./* | split -b 15m -d - "' . $archname . '."';
/*
$command = 'tar -';
$command .= '-exclude ' . $archname . ' -czf ' . $archname . ' .';
*/
$output = shell_exec($command);
echo $command;
//$output = shell_exec($command);
echo $output.'
';
//$size = round(filesize($archname)/1000);

echo "File backup finished
";// size: ".$size."
";
echo "Database backup started
";

$backupFile = $path.'/'.$domainName.'_db_' . date("Y-m-d-H-i-s") . '.tar.gz';
$command = "mysqldump --opt -h localhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";
shell_exec($command);
echo "Database backup finished
";

?>

Primary interop assembly

Office 2013 Component ID

Office 2013 Component ID [64 bit]

Excel

{C8A65ABE-3270-4FD7-B854-50C8082C8F39}

{E3BD1151-B9CA-4D45-A77E-51A6E0ED322A}

InfoPath

{0F825A16-25B2-4771-A497-FC8AF3B355D8}

{C5BBD36E-B320-47EF-A512-556B99CB7E41}

Outlook

{F9F828D5-9F0B-46F9-9E3E-9C59F3C5E136}

{7824A03F-28CC-4371-BC54-93D15EFC1E7F}

PowerPoint

{813139AD-6DAB-4DDD-8C6D-0CA30D073B41}

{05758318-BCFD-4288-AD8D-81185841C235}

Visio

{C1713368-12A8-41F1-ACA1-934B01AD6EEB}

{2CC0B221-22D2-4C15-A9FB-DE818E51AF75}

Word

{9FE736B7-B1EE-410C-8D07-082891C3DAC8}

{13C07AF5-B206-4A48-BB5B-B8022333E3CA}

Microsoft Forms 2.0

{B2279272-3FD2-434D-B94E-E4E0F8561AC4}

{A5A30117-2D2A-4C5C-B3C8-8897AC32C2AC}

Microsoft Graph

{52DA4B37-B8EB-4B7F-89C1-824654CE4C70}

{24706F33-F0CE-4EB4-BC91-9E935394F510}

Smart Tag

{487A7921-EB3A-4262-BB5B-A5736B732486}

{74EFC1F9-747D-4867-B951-EFCF29F51AF7}

Office Shared

{6A174BDB-0049-4D1C-86EF-3114CB0C4C4E}

{76601EBB-44A7-49EE-8DE3-7B7B9D7EBB05}

Project

{1C50E422-24FA-44A9-A120-E88280C8C341}

{706D7F44-8231-489D-9B25-3025ADE9F114}

 

 

 

Primary interop assembly

Office 2013 Component ID

Office 2013 Component ID [64 bit]

Excel

{C8A65ABE-3270-4FD7-B854-50C8082C8F39}

{E3BD1151-B9CA-4D45-A77E-51A6E0ED322A}

InfoPath

{0F825A16-25B2-4771-A497-FC8AF3B355D8}

{C5BBD36E-B320-47EF-A512-556B99CB7E41}

Outlook

{F9F828D5-9F0B-46F9-9E3E-9C59F3C5E136}

{7824A03F-28CC-4371-BC54-93D15EFC1E7F}

PowerPoint

{813139AD-6DAB-4DDD-8C6D-0CA30D073B41}

{05758318-BCFD-4288-AD8D-81185841C235}

Visio

{C1713368-12A8-41F1-ACA1-934B01AD6EEB}

{2CC0B221-22D2-4C15-A9FB-DE818E51AF75}

Word

{9FE736B7-B1EE-410C-8D07-082891C3DAC8}

{13C07AF5-B206-4A48-BB5B-B8022333E3CA}

Microsoft Forms 2.0

{B2279272-3FD2-434D-B94E-E4E0F8561AC4}

{A5A30117-2D2A-4C5C-B3C8-8897AC32C2AC}

Microsoft Graph

{52DA4B37-B8EB-4B7F-89C1-824654CE4C70}

{24706F33-F0CE-4EB4-BC91-9E935394F510}

Smart Tag

{487A7921-EB3A-4262-BB5B-A5736B732486}

{74EFC1F9-747D-4867-B951-EFCF29F51AF7}

Office Shared

{6A174BDB-0049-4D1C-86EF-3114CB0C4C4E}

{76601EBB-44A7-49EE-8DE3-7B7B9D7EBB05}

Project

{1C50E422-24FA-44A9-A120-E88280C8C341}

{706D7F44-8231-489D-9B25-3025ADE9F114}

 

Eger siz de benim gibi bir sekilde Windows Driver Kit (WDK) yuklemisseniz bilgisayari da debug mode a almissiniz demektir. Skype ile ne alakasi var demeyin. Windows debug mode a iken Skype bilgisayari hic iz birakmadan kilitliyor. Cozumu su; eger WDK ile isiniz bittiyse msconfig ten debug mode u kapatin. Bilgisayari yeniden baslatin.


SQL Server veye SQLExpress kurdunuz ama database olusturamiyorsunuz ya da yedekten geri donemiyorsunuz. Oncelikli olarak Management Studio’yu “Run as Admin” ile calistirip deneyin. Bu ise yaramazsa http://archive.msdn.microsoft.com/addselftosqlsysadmin/ adresinden SQL scriptini indirin ve bir klasore kopyalayin. “Run as Admin” ile bir command prompt acin ve komut satirinda addselftosqlsysadmin.cmd dbinsancename domain\username seklinde calistirin, duzelecektir.

Gridview’de sayfadaki son kaydi silince gridview yok oluyor. Sanirim bir bug. Cozumu ise oldukca basit, iki kere databind() yapmak.

GridView kontrolüne Entity Data Source ile data bind ettiniz. Sonra RowDataBound event’inde e.Row.DataItem‘i entity class a erişmek istediniz. O da ne, Unable to cast object of type ‘System.Data.Objects.MaterializedDataRecord’ to type ‘ProjectEntities.User’ diye bir hata aldınız. Çözümü aşağıda:

Önce Configure Entity Data Source ekranını açın ve orada EntityTypeFilter olarak erişmek istediğiniz class’ı seçin.

Daha sonra aşağıdaki extension method’u projenize ekleyin.

        public static TEntity GetItemObject<TEntity>(object dataItem)
            where TEntity : class
        {
            var entity = dataItem as TEntity;
            if (entity != null)
            {
                return entity;
            }
            var td = dataItem as ICustomTypeDescriptor;
            if (td != null)
            {
                return (TEntity)td.GetPropertyOwner(null);
            }
            return null;
        }

Artık RowDatabound eventi’nde dönüştürmeyi yapabilirsiniz.

        protected void grdUsers_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ProjectEntities.User user = GetItemObject<ProjectEntities.User>(e.Row.DataItem);
            }
        }
RowDataBound
RowDataBound
top