>>561
コンパイルすら通らないんですが。。
//test.cpp
extern "C" __declspec(dllexport) int f()
{
 return 777;
}
//test.def
LIBRARY "testdll"
EXPORTS
 f
//test.cs
using System;
using System.Runtime.InteropServices;
namespace Test
{
 class Test
 {
  [DllImport("testdll")]
  static extern int f();
  static void Main()
  {
   Console.WriteLine(f());
  }
}
こうですか?
それでも例外出ますね。