我想请问下,我有两个文件 default.aspx  和 default.aspx.cs一个是代码,一个是页面
他们的代码分别如下default.aspx代码<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>测试</title>
</head>
<body>
    <form id="form1" runat="server">
    <div><%=test()%></div>
    </form>
</body>
</html>default.aspx.cs代码如下using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
       Response.Write("测试");
    }    public string test()
    {
      //省略
    }
}我现在把这个default.aspx.cs的文件编译成了dll,比如编译成了index.dll,然后,让default.aspx,去调用这个文件,请问该怎么做呢?

解决方案 »

  1.   

    先引用dll文件,然后在using 处增加一个,具体参考msdn
      

  2.   

    添加引用这个dll文件到你项目就好了。或者用
    using System.Runtime.InteropServices; [DllImport("name.dll",
             EntryPoint = "函数name",
             CharSet = CharSet.Unicode,
             CallingConvention = CallingConvention.Winapi)]
            public static extern int 函数name(参数);
      

  3.   

    我知道编译成index.ll,然后并添加引用
    但是
    default.aspx头部
    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %> 
    这些地方该怎么写呢?
      

  4.   

    using System.Runtime.InteropServices; [DllImport("name.dll", 
            EntryPoint = "函数name", 
            CharSet = CharSet.Unicode, 
            CallingConvention = CallingConvention.Winapi)] 
            public static extern int 函数name(参数);