FireandForget delegate - c#
<p>I came across this link, <a href="http://www.eggheadcafe.com/articles/20060727.asp" rel="nofollow">link text</a></p>

<p>In the article, where the author has definition of this method</p>

<pre><code>static void WriteIt(string first, string second, int num)
</code></pre>

<p>I changed that in my test app to this</p>

<pre><code>static void WriteIt(CustomerObject Customer)
{
  fileIO.CreateFile(XMLUtil.Serialize(Customer));
}
</code></pre>

<p>Where </p>

<pre><code> public static string Serialize(object o)
    {
        System.Xml.Serialization.XmlSerializerNamespaces ns = new System.Xml.Serialization.XmlSerializerNamespaces();
        ns.Add("", "");

        return Serialize(o, ns);

    }

    public static string Serialize(object o, XmlSerializerNamespaces ns)
    {
        try
        {
            using (System.IO.MemoryStream m = new System.IO.MemoryStream())
            {

                //serialize messagelist to xml
                XmlSerializer serializer = new XmlSerializer(o.GetType(), "");

                if (ns != null)
                    serializer.Serialize(m, o, ns);
                else
                    serializer.Serialize(m, o);

                m.Position = 0;
                byte[] b = new byte[m.Length];
                m.Read(b, 0, b.Length);

                return System.Text.UTF8Encoding.UTF8.GetString(b);
            }
        }
        catch (Exception ex)
        {
            return "Ex = " + ex.ToString();
        }
    }
</code></pre>

<p>This method always gives an exception</p>

<pre><code>static void EndWrapperInvoke (IAsyncResult ar)
    {
        wrapperInstance.EndInvoke(ar); 
        ar.AsyncWaitHandle.Close();
    }
</code></pre>

<p>Stacktrace:</p>

<p>Server stack trace: </p>

<pre><code>   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct&amp; sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Delegate.DynamicInvoke(Object[] args)
   at SRC.FileMover.ThreadUtil.InvokeWrappedDelegate(Delegate d, Object[] args)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]&amp; outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]&amp; outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
   at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData&amp; msgData)
   at SRC.FileMover.ThreadUtil.DelegateWrapper.EndInvoke(IAsyncResult result)
   at SRC.FileMover.ThreadUtil.EndWrapperInvoke(IAsyncResult ar)
   at System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(IMessage msg)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
   at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall()
   at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
   at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
</code></pre>

<p>UPDATE 1:
Trying to run my app and get the full exception. It seems like its happening at different locations. I will repost my ? again shortly.  I think it may be wise if I can post my application. Can i upload a .zip file or is it better to just post the .cs code that I am using?</p>
