title: How to get a return value from unmanaged code via COM Automation in Silverlight?
body: <p>I am currently trying to invoke some unmanaged code from a Silverlight 4 Out-Of-browser application with elevated privileges.</p>
  
  <p>My simple test code fails with an ArgumentException.</p>
  
  <pre><code>try
  {
      dynamic watch = AutomationFactory.CreateObject("WatchCOMLib.HighPerformanceWatch");                
  
      // Displays ...AutomationMetaObjectProvider
      MessageBox.Show(watch.ToString());  
  
  
      // Fails with ArgumentException: Could not convert an argument for the call to GetTimestamp
      ulong tsc;
      watch.GetTimestamp(out tsc);  
  
      MessageBox.Show(tsc.ToString());
  }
  catch (Exception ex) { MessageBox.Show(ex.ToString()); }
  </code></pre>
  
  <p>I have created the COM library by using the Visual Studio 2010 ATL Template Wizard; the method looks like</p>
  
  <pre><code>STDMETHODIMP CHighPerformanceWatch::GetTimestamp(ULONGLONG* tsc)
  {
      // ....
      *tsc = result; // result is unsigned __int64
      return S_OK;
  }
  </code></pre>
  
  <p>When I simply pass tsc into GetTimestamp without specifying the out keyword, no exception is thrown, but tsc is unchanged.
  Now... how can I get a value back from the unmanaged library?</p>
  
  <p>Now, there may be plenty of information missing. I've followed a few Hello-World tutorials for creating this COM library, but I don't really have a clue whats goig on there. =)
  Please ask for anything you need!</p>