The following code is the essential part of my program and class to reproduce the failure: 

```
using namespace System;

generic <class T>
ref class gener
{
public:
  void func1g (T value)
  {
    Console::WriteLine (value);
    int iValue = static_cast<int>(value);
    if (iValue <= 0) return;
    func2 ();
  }

  void func2 ()
  {
    T value = (T)(Object^)0;
    func1g (value);
  }
};

int main()
{
  gener<int>^ g = gcnew gener<int>;
  int iValue = 1;
  g->func1g (iValue);  // <<=== System.TypeLoadException

  return 0;
}

```

When calling `func1g`, I get a `System.TypeLoadException`. I just don't understand why.  

Is it because `func2` does not have a generic parameter?

Here's the full error message (in german, but it just says 'unhandled exception' and 'could not be loaded'; no details):  

[![enter image description here](https://i.stack.imgur.com/PSnbl.png)](https://i.stack.imgur.com/PSnbl.png)

The equivalent code in C# works: 

```
public class gener<T>
{
  public void func1g(T value)
  {
    Console.WriteLine(value);
    int iValue = Convert.ToInt32(value);
    if (iValue <= 0) return;
    func2();
  }

  public void func2()
  {
    T value = (T)(object)0;
    func1g(value);
  }
};

internal class Program
{
  private static void Main()
  {
    gener<int> g = new gener<int>();
    int iValue = 1;
    g.func1g(iValue);

    return;
  }
}

```

EDIT
----

I found a kind of 'workaround', see my answer below, but I don't know why this works.  

I would appreciate it if someone could explain me the reason of this failure and the function of the workaround.

**EDIT 2**  

In case you want to reproduce this: I use VS 2008 SP1.  

I hope that it's not again compiler related like my last issue, although I personally expect this to be very likely...