困扰了我很长一段时间了。在webservice中加载a.dll并调用其中的函数。
a.dll使用时需要跟该dll相关的一个data文件夹 dll_data,在dll.conf文件中有该
dll使用data的配置信息。之前有人成功使用过该dll.调用该dll。Import该dll的代码段:public class test
{
private const string path=@".\a.dll";
[DllImport(path,CharSet=CharSet.Ansi,EntryPoint="?aaaa@@bbbb@cccc")]
public static extern int aaaa(string);
}该dll文件的资源引用配置文件dll.conf信息:Dll_dataFolder=./dll_data/dll的data文件夹dll_data以及dll.conf配置文件与该dll放置于同一目录下。在c#的win32 console application项目中,将dll, dll_data, dll.conf文件同时
置于工程文件夹的debug子目录下,能正常调用加载dll并执行函数。但是在c# webservice或者网站中,可以加载该dll(因为没有提示错误:加载dll模块
失败。) 但是引用dll方法一个也不执行,但是不提示错误。建立c# webservice或者网站在调用函数aaaa时,
test.aaaa(testString);不会报错,但是运行该函数没有相应的结果。
也即加载dll成功,调用方法失败。想知道这里test.cs文件中 private const string path=@".\a.dll";
这里的当前目录,在console application中是指 debug目录,
那在webservice中是指什么呢?与asmx文件同一个目录,还是windows\system32?
还是VS的IDE目录?
dll的配置文件dll.conf中也有Dll_dataFolder=./dll_data/ 这个当前目录又是哪个呢?
~~
我在windows\system32中和VS的IDE目录下同时都放了dll,data,conf文件,
在asmx同目录下也放了dll,data,conf文件,但是还是无济于事。不知道怎么样才能正确地在webservice和网站中加载该dll.
不知道dll文件应该放哪里,data,conf文件又应该放在哪里,该dll才能正确地被
调用。
a.dll使用时需要跟该dll相关的一个data文件夹 dll_data,在dll.conf文件中有该
dll使用data的配置信息。之前有人成功使用过该dll.调用该dll。Import该dll的代码段:public class test
{
private const string path=@".\a.dll";
[DllImport(path,CharSet=CharSet.Ansi,EntryPoint="?aaaa@@bbbb@cccc")]
public static extern int aaaa(string);
}该dll文件的资源引用配置文件dll.conf信息:Dll_dataFolder=./dll_data/dll的data文件夹dll_data以及dll.conf配置文件与该dll放置于同一目录下。在c#的win32 console application项目中,将dll, dll_data, dll.conf文件同时
置于工程文件夹的debug子目录下,能正常调用加载dll并执行函数。但是在c# webservice或者网站中,可以加载该dll(因为没有提示错误:加载dll模块
失败。) 但是引用dll方法一个也不执行,但是不提示错误。建立c# webservice或者网站在调用函数aaaa时,
test.aaaa(testString);不会报错,但是运行该函数没有相应的结果。
也即加载dll成功,调用方法失败。想知道这里test.cs文件中 private const string path=@".\a.dll";
这里的当前目录,在console application中是指 debug目录,
那在webservice中是指什么呢?与asmx文件同一个目录,还是windows\system32?
还是VS的IDE目录?
dll的配置文件dll.conf中也有Dll_dataFolder=./dll_data/ 这个当前目录又是哪个呢?
~~
我在windows\system32中和VS的IDE目录下同时都放了dll,data,conf文件,
在asmx同目录下也放了dll,data,conf文件,但是还是无济于事。不知道怎么样才能正确地在webservice和网站中加载该dll.
不知道dll文件应该放哪里,data,conf文件又应该放在哪里,该dll才能正确地被
调用。
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices; //[DllImport]namespace DllDemoCSharp
{
public partial class Form1 : Form
{ public struct CvPoint
{
int x;
int y;
}
[DllImport("DllDemo.dll",EntryPoint="Add")] public static extern int Add(int a,int b);
[DllImport("win32Console.dll")]
public static extern CvPoint OpenCVFindEdge(String imageName, int tnY, int m, int tnThresh);
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
int test,test2,test3;
test = Add(1,2);
test2 = Add(3,4);
CvPoint Point;
String imageName;
imageName = "c:\\temp\\testpic.bmp";
Point = OpenCVFindEdge(imageName,50, 1, 125);
test3 = Add(3,4);
}
}
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zhjh632/archive/2009/06/05/4245579.aspx