Again, some of the code is missing because the template parameters (for CArray) are wiped out by the HTML interpreter. The easiest way to avoid it is to put a space after the opening bracket and before the closing bracket: CArray< type1, type2 >. Here are some points to consider: 1. The memory leak I already explained why it occurs. 2. The access violation I'm still not sure of, since it's not clear where m_pCommandArray is created and if your CViapcDlg::Close() is being called multiple times. A word of advice, after deleting a pointer variable, always set it to NULL. This ensures that if you delete it again, it's not pointing to bogus memory and the program doesn't blow up. 3. The question of whether or not to use a DLL in this case is best answered by you. Is the code in the DLL reusable by other apps? Or perhaps, do you intend to "plug in" a different set of source code into your app at run-time, similar to a driver? If the answer to either of these is Yes, then a DLL is the way to go. If not, then it's not worth it. You'll only complicate your life unnecessarily, as you're seeing now. Regards, Alvaro
Well done is better than well said. -- Benjamin Franklin (I actually prefer medium-well.)