[DllImport("Channel.dll", EntryPoint = "CAPI_Channel", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
        public static extern channel_output CAPI_Channel(int a, double[] b, int c); //EntryPoint = "CAPI_Channel",函数是 CAPI_Channel没有错,EntryPoint出错,请教各位?? 

解决方案 »

  1.   

    dll的名称、位置、内容正确吗?
      

  2.   

    CharSet = CharSet.Ansi, 
    CallingConvention = CallingConvention.StdCall如果C里的定义不是stdcall的,就去掉
      

  3.   

    我用Depends来看这个dll文件, 发现还有个函数名是这样的
    "?CAPI_Channel@@YA?AUchannel_output@@HPANH@Z",
    我把EntryPoint改了下,发现不报错,但是算出来的结果是错误的
    不知道为什么?我在C++下调用是没有问题的
      

  4.   

    不知道,我就只有二个文件,lib跟dll
      

  5.   

    #pragma comment(lib,"Channel.lib")_declspec (dllimport) channel_output CAPI_Channel(int, double *, int);//我是这样用的
      

  6.   

    [DllImport("Channel.dll", EntryPoint = "CAPI_Channel", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] 
            public static extern channel_output CAPI_Channel(int a, double[] b, int c); //EntryPoint = "CAPI_Channel", 
    CharSet = CharSet.Auto  改为CharSet.Unicode 试试看
      

  7.   

    DLL 中没加 extern "C" 又没加 stdcall (WINAPI 之类的) 啊
    EntryPoint 只能用那一长串“乱码”CallingConvention 得用 Cdecl
      

  8.   

    VC 6.0自带的查看DLL 的工具 如果能查看你所调用的DLL 有内容的话,那应该能找到入口点。
    如果内容为空的话,就不行。C#里调用的DLL应该是标准库文件。
      

  9.   

    那个double*是传递ref double还是double[],这要看参数的具体说明了
      

  10.   

    这个怎么看啊?我用ref double 试了下,结果还是一样的...
      

  11.   

    channel_output 是什么返回类型,c#没这个类型啊
      

  12.   

    channel_output是我定义的结构体啊
      

  13.   

    什么意思?这个是vc++6.0的时候生成的,现在用的是vs2005
      

  14.   

    c++中
    定义:
    #pragma comment(lib,"Channel.lib")
    _declspec (dllimport) channel_output CAPI_Channel(int, double *, int);
    结构体typedef struct
    {

    int zc;  // 声速分布分层数(2-254)
    double z[256],c[256];  // 深度(0.-xxxxx.)、声速(xxxx.)
    double CoeffSurfaceReflection; 
    double SeaWaterDensity;
    double SeaWaterVelocity; 
    double SeaFloorDensity; 
    double SeaFloorVelocity;  // 接收机位置
    double ReceiverRange; 
    double ReceiverDepth; 
    double SourceRange; 
    double SourceDepth; 
    double VerticalDirectionMin; 
    double VerticalDirectionMax; 
    double FrequencyMin; 
    double FrequencyMax; 
             double CentreFrequency; 
    double SamplingFrequency; 
    double SignalImpluseWidth; 
    int ChannelOption; 
    } channel_input;typedef struct
    {
    double t_tmin; 
             double t_Amax;
             double TL; 
    } channel_output;C#中:
    定义
     [DllImport("Channel.dll", EntryPoint = "?CAPI_Channel@@YA?AUchannel_output@@HPANH@Z")] 
            public static extern channel_output CAPI_Channel(int a, double[] b, int c); //EntryPoint = "CAPI_Channel",
    结构体:
    public struct channel_input
        {
        public int zc;  
       public double[] z ;
               public double[] c ;  
       public double CoeffSurfaceReflection; 
       public double SeaWaterDensity; 
       public double SeaWaterVelocity; 
       public double SeaFloorDensity; 
       public double SeaFloorVelocity;
       public double ReceiverRange; 
       public double ReceiverDepth; 
       public double SourceRange; 
       public double SourceDepth; 
       public double VerticalDirectionMin; 
       public double VerticalDirectionMax; 
       public double FrequencyMin; 
       public double FrequencyMax; 
       public double CentreFrequency; 
       public  double SamplingFrequency; 
       public  double SignalImpluseWidth; 
       public int ChannelOption;
        }
       [StructLayout(LayoutKind.Sequential)] 
        public struct channel_output
        {
       public double t_tmin; 
        public double t_Amax;   
                 public double TL;   
        } 
    就这样,我觉得这个关系不大,主要是参数的输入输出有问题
      

  15.   

    结构体看来没问题。
    double[] b这个参数到底是用来传入还是传出数据?如果是传出的,那么它的实参分配了足够大的内存吗?
      

  16.   

    b[]是用来输入的啊,跟输出无关的,输出的是channel_output结构体
      

  17.   

    在visual6.0中编译的dll文件,在c#中是不一定能够调用地,要用.net的函数库才行,看看是不是这个原因哈!