开发者

IIS .net application, possible to host a .vb file inside a c# app?

I have an application that I've set default languag开发者_如何学运维e to c#, is it possible to run a .vb class inside of this IIS application?


One option is to add the file containing the class to a sub directory of the App_Code directory and set compilation to VB for that folder: http://shailkpatel.blogspot.com/2007/10/multiple-programming-languages-in.html

Assuming it's a web site and not a web application


You have to write your vb class on a different assembly. Then you can instance it from c# code.


You could have aspx pages mixing c# and VB.NET in the same site:

defaultVB.aspx:

<%@ Page Language="VB" %>
<script type="text/VB" runat="server">
    Protected Sub Page_Load(sender as Object, e as EventArgs)

    End Sub
</script>

<!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>
    </div>
    </form>
</body>
</html>

defaultCSharp.aspx:

<%@ Page Language="C#" %>
<script type="text/C#" runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {

    }
</script>

<!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>

    </div>
    </form>
</body>
</html>

Of course this assumes that you don't use code behind files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜