The name of the IApplication interface is "application" and not "main". Unlike most libraries "application.library" does not have an interface named "main" at all.dApplication.IApplication = (APTR)IExec->GetInterface((APTR)dApplication.ApplicationBase,"main",0L,NULL);
Also when using the GetInterface() function you should always specify the exact version you want (specifying 1 as version should be fine for most libraries) as there is no 0 value for "any version works" as there is with OpenLibrary().
The reason is that unlike library versions which should always try to be backwards compatible, interface versions will most likely be incompatible and a library can export more than one version of the same interface (f.e. a library might export v1 "main" interface with compatibility cludges for old applications and an improved v2 "main" for newer ones).