Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

dll - Which is called first, DllMain() or global static object constructor? -


i writing dll defines global static object.

in object's constructor doing initialization may or may not succeed.

is possible signal success or failure of initialization process in dllmain() ? of 2 called first ?

thank you.

msdn's dllmain documentation says:

if dll linked c run-time library (crt), entry point provided crt calls constructors , destructors global , static c++ objects. therefore, these restrictions dllmain apply constructors , destructors , code called them.

since code within dllmain may use static objects, static objects must constructed before dllmain run dll_process_attach, , destroyed after run dll_process_detach.

you can verify simple test exe , test dll.

exe:

int _tmain(int argc, _tchar* argv[]) {     wprintf(l"main, loading library\n");     hmodule h = loadlibrary(l"test.dll");      if (h)     {         wprintf(l"main, freeing library\n");         freelibrary(h);     }      wprintf(l"main, exiting\n");     return 0; } 

dll:

struct moo {     moo() { wprintf(l"moo, constructor\n"); }     ~moo() { wprintf(l"moo, destructor\n"); } };  moo m;  bool apientry dllmain( hmodule hmodule,                        dword  ul_reason_for_call,                        lpvoid lpreserved) {     switch (ul_reason_for_call)     {     case dll_process_attach:         wprintf(l"dllmain, dll_process_attach\n");         break;     case dll_thread_attach:         wprintf(l"dllmain, dll_thread_attach\n");         break;     case dll_thread_detach:         wprintf(l"dllmain, dll_thread_detach\n");         break;     case dll_process_detach:         wprintf(l"dllmain, dll_process_detach\n");         break;     default:         wprintf(l"dllmain, ????\n");         break;     }     return true; } 

together print:

main, loading library moo, constructor dllmain, dll_process_attach main, freeing library dllmain, dll_process_detach moo, destructor main, exiting 

as can see, static object constructed before dllmain(...,dll_process_attach,...) , destroyed after dllmain(...,dll_process_detach,...)


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -