I have an app that worked just fine in VB6.I have ported all over to VB.net. What I am having troubles with is making a call into a dll upon start up. When I make the call I get the following error:Attempted to "read or write protected memory. This is often an indication that other memory is corrupt.". If I take the exact same code and create a button to fire off the code it works ok. SO how can I make the call to the dll upon startup? If the code works behind a button why won't it work in the Sub Main?