VB.NET Excel Program Leaves EXCEL.EXE floating after completion

Below is code that works for me (NOTE order that I release objects, which is important) xlWorkBook.Close() xlApp.Quit() ReleaseObject(xlWorkSheet) ReleaseObject(xlWorkBook) ReleaseObject(xlApp) Private Sub ReleaseObject(ByVal obj As Object) Try System.Runtime.InteropServices.Marshal.ReleaseComObject(obj) obj = Nothing Catch ex As Exception obj = Nothing Finally GC.Collect() End Try End Sub

How do I specify the equivalent of volatile in VB.net?

There’s no equivalent of C#’s volatile keyword in VB.NET. Instead what’s often recommended is the use of MemoryBarrier. Helper methods could also be written: Function VolatileRead(Of T)(ByRef Address As T) As T VolatileRead = Address Threading.Thread.MemoryBarrier() End Function Sub VolatileWrite(Of T)(ByRef Address As T, ByVal Value As T) Threading.Thread.MemoryBarrier() Address = Value End Sub Also … Read more

Objects implicitly instantiated in vb.net?

Yes that is legacy behavior. Classes did not show up in VB until v4, before that Form1.Show was The Way to show forms. In order to keep previous code compatible (VB3 was also very popular), the old method was maintained. It is still supported in .NET as a legal means to show forms. Initially, this … Read more

VB Detect Idle time

This is done easiest by implementing the IMessageFilter interface in your main form. It lets you sniff at input messages before they are dispatched. Restart a timer when you see the user operating the mouse or keyboard. Drop a timer on the main form and set the Interval property to the timeout. Start with 2000 … Read more

How to securely store a connection string in a WinForms application?

Simply , the .net framework allows you to do that , see http://msdn.microsoft.com/en-us/library/89211k9b(v=vs.80).aspx Relevant information: This goes into the machine.config file: <configProtectedData defaultProvider=”RsaProtectedConfigurationProvider”> <providers> <add name=”RsaProtectedConfigurationProvider” type=”System.Configuration.RsaProtectedConfigurationProvider, … /> <add name=”DataProtectionConfigurationProvider” type=”System.Configuration.DpapiProtectedConfigurationProvider, … /> </providers> </configProtectedData> And this is the application code: Shared Sub ToggleConfigEncryption(ByVal exeConfigName As String) ‘ Takes the executable file name without … Read more