Invalid Cast Exception On One Machine Given Same Assembly & Data

112 Views Asked by At

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.

Specifically, the exception thrown within the WF is:

Invalid cast from 'System.Double' to 'System.Nullable`1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'

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).

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.

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.

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.

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.

0

There are 0 best solutions below