title: Invalid Cast Exception On One Machine Given Same Assembly & Data
body: <p>I have encountered an unusual situation where the same code is behaving differently on a particular machine. The program is written in VB.NET and WF4. The workflow XAML is read from a database at runtime and compiled on the fly. I mention this only to give context to my question in case of relevancy.</p>
  
  <p>Specifically, the exception thrown within the WF is:</p>
  
  <p>Invalid cast from 'System.Double' to 'System.Nullable`1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'</p>
  
  <p>It is difficult to debug the program since the machine is owned by another organization and the user has little time to assist me. I believe the exception occurs when a WF variable of type double is passed to a method I have written and exposed through a WF argument. The method parameter is of type Nullable(Of Double). </p>
  
  <p>The code in question is installed and is run regularly on as many as 100 computers in several different organizations. It is only on this one particular machine that it behaves differently.</p>
  
  <p>I wonder if the compile options Option Explicit, Option Strict and Option Infer could be the source of the exception. Is it possible that the values for one or more of these Compile Options is being overridden on this problematic machine due to some specific configuration change made to the .net framework deployment on this machine? The behavior of these options and any effect they may have on the JIT compiler at runtime is not an area of the framework I am particularly knowledgeable of.</p>
  
  <p>The assemblies target .net 4.0 and were compiled using VS2010 SP1. The machine in question is running Win7 64bit. The assembly is compiled for release and x64 platform. </p>
  
  <p>This is my first question posted to this site, although I have used it with great success for many years. Thank you in advance for any advice. </p>