title: Classic ASP, Cookies, and VB.NET COM+ objects
body: <p>This is tangled.</p>
  
  <p>I've been handed a web site written in classic ASP, with a lot of behind the scenes stuff done in VB6 COM+ objects called from the ASP pages via Server.ObjectCreate() instantiations. For this incarnation, the VB6 routines have been converted to VB.NET simply by running the Visual Studio 2003 converter tool on them, and then upgrading that solution file to VS 2008.  So there's a thousand and one possible sources for error.</p>
  
  <p>One of the VB6 Modules that is giving me trouble clears a bunch of Response cookies by lines of the following form:</p>
  
  <pre><code>ASPResponse.Cookies("SysUserCode") = ""
  </code></pre>
  
  <p>Where ASPResponse is defined as :</p>
  
  <pre><code>Private ASPResponse As ASPTypeLibrary.Response
  </code></pre>
  
  <p>And was set up on Object Activation by:</p>
  
  <pre><code>Set ASPResponse = objContext("Response")
  </code></pre>
  
  <p>In the VB.NET conversion of this module, those lines became</p>
  
  <pre><code>ASPResponse = ContextUtil.GetNamedProperty("Response")
  </code></pre>
  
  <p>and </p>
  
  <pre><code>ASPResponse.Cookies("SysUserCode")() = ""
  </code></pre>
  
  <p>(note the extra pair of parentheses. Not being much of a VB person, I'm not real sure what that syntax means.)</p>
  
  <p>Okay, here's the question: When this code executes on MY machine, that line is giving a VB error 13, with the Error.Description being "Specified cast is not valid."  Huh?  What cast?</p>
  
  <p>Incidentally, this module runs fine on a co-workers machine, and he cannot see any difference in the configuration of my machine and the relevant components from his.</p>
  
  <p>I'm totally at a loss here.  Googling it has given me a bunch of stuff on VB.NET cookies, or COM components with VB.NET, but nothing related to classic ASP cookies.</p>