This project has moved. For the latest updates, please go here.

[SOLVED] "TypeInitializationExeption" when trying to instatiate a Distribution

Nov 23, 2011 at 10:39 PM
Edited Nov 23, 2011 at 11:15 PM

Solved: I had not added a reference to zlib.dll, as I thought it was optional, I guess this wouldn't have happened if this page was working '^^: http://numerics.mathdotnet.com/quickstart-vs10-cs/

Hello everyone, I'm trying out MathNet's capabilities for generating random numbers according to specific distributions, but I can't get past this error when I try to instantiate a new Exponential distribution (or any other distribution):

System.TypeInitializationException was unhandled
  Message=The type initializer for 'MathNet.Numerics.Control' threw an exception.
  Source=MathNet.Numerics
  TypeName=MathNet.Numerics.Control
  StackTrace:
       at MathNet.Numerics.Control.get_CheckDistributionParameters()
       at MathNet.Numerics.Distributions.Exponential.SetParameters(Double lambda)
       at MathNet.Numerics.Distributions.Exponential..ctor(Double lambda)
       at Simulador_y_Analizador_de_Colas.EjecutarSimulacionProceso.Ejecutar() in C:\Users\Seba\Desktop\Simulador y Analizador de Colas\Simulador y Analizador de Colas\EjecutarSimulacionProceso.cs:line 35
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.IO.FileNotFoundException
       Message=Could not load file or assembly 'System.Numerics, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. El sistema no puede encontrar el archivo especificado.
       Source=MathNet.Numerics
       FileName=System.Numerics, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
       FusionLog==== Pre-bind state information ===
LOG: User = PHENOM-SERVER64\Seba
LOG: DisplayName = System.Numerics, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/Users/Seba/Desktop/Simulador y Analizador de Colas/Simulador y Analizador de Colas/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : MathNet.Numerics, Version=2011.4.17.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Numerics, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Users/Seba/Desktop/Simulador y Analizador de Colas/Simulador y Analizador de Colas/bin/Debug/System.Numerics.DLL.
LOG: Attempting download of new URL file:///C:/Users/Seba/Desktop/Simulador y Analizador de Colas/Simulador y Analizador de Colas/bin/Debug/System.Numerics/System.Numerics.DLL.
LOG: Attempting download of new URL file:///C:/Users/Seba/Desktop/Simulador y Analizador de Colas/Simulador y Analizador de Colas/bin/Debug/System.Numerics.EXE.
LOG: Attempting download of new URL file:///C:/Users/Seba/Desktop/Simulador y Analizador de Colas/Simulador y Analizador de Colas/bin/Debug/System.Numerics/System.Numerics.EXE.

       StackTrace:
            at MathNet.Numerics.Control..cctor()
       InnerException: 

My code looks like:

MathNet.Numerics.Distributions.Normal myNormal = new MathNet.Numerics.Distributions.Normal(average, standarDeviation);

On a related note: I use the full path there because if I put an "using MathNet.Numerics" I can't get "Distributions" to be recognized, let alone "Distributions.Normal" nor anything else, although if I put "using MathNet.Numerics.Distributions" I get direct access to "Normal" and all the distributions, but that gets intellisense to be quite bothersome (beecause of some of the names I'm using in my application).

I'm really puzzled as to what is happening, never had this error before with any external library. Please help me! Big thanks just for reading that ;)