日期:2014-05-18  浏览次数:20421 次

能给个asp.net调用dll的Hallo World例子吗,感谢
想用c#的语法写asp.net的网页,要调用一个dll。

在这里搜索了很久,没找到能运行的例子。能写个Hallo   World的例子吗?会了后马上结贴

多谢

------解决方案--------------------
要求调用什么样的dll
win32 普通的?
com 的?
托管的?

------解决方案--------------------
自己写个类编译一下就会生成一个dll,

------解决方案--------------------
新建项目-类库HalloWorld 新建一类HalloWorld.cs
namespace HalloWorld
{
public class HalloWorld
{
public string getHalloWorld()
{
return "Hallo World ";
}
}
}
生成dll
新建一网站 添加引用 HalloWorld.dll
新建test.aspx页面调用HalloWorld
HalloWorld.HalloWorld halloWorld = new HalloWorld.HalloWorld();
Response.Write(halloWorld.getHalloWorld());
------解决方案--------------------
添加引用 helloworld.dll

后天使用时候 使用一下语法
hellwprld.hellworld()

或者
using hellworld;

----》
helloworld();
------解决方案--------------------
调用外部 DLL

const string strDLLPath = "FBSDK.dll ";

// 系统函数
[DllImport(strDLLPath, EntryPoint= "Login ")] // 登录系统
public static extern int pLogin(string data, int length, byte[] errorMsg);

[DllImport(strDLLPath, EntryPoint= "Logout ")] // 退出系统
public static extern int pLogout(byte[] errorMsg);

[DllImport(strDLLPath, EntryPoint= "GetAccInfoA ")] // 查询账户详细信息
public static extern int pGetAccInfoA(string query, out IntPtr data, Int32[] length, byte[] errorMsg);

以后使用就直接使用 pLogin(...),和其他函数使用没有什么区别
------解决方案--------------------
照3楼的写法试试,没问题
多动手试试,一个解决方案中的cs文件,编译后就是一个DLL