组件如何调用
我是新手,把ubbcode.cs编译成ubbcode.dll文件后,我在viewmsg.aspx文件这样调用的,<%@ Register Assembly="ubcode" Namespace="ubb" TagPrefix="ub1"%>
编译器错误信息: CS0433: 类型“ubb.ubbcode”同时存在于“c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\netmsg\7d66c4c3\90de3056\assembly\dl3\6af245c1\0ca32b34_0f30c901\ub.DLL”和“c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\netmsg\7d66c4c3\90de3056\App_Code.i54cavin.dll”中
源错误:
行 57: <div class="time"><%# DataBinder.Eval(Container.DataItem, "AddTime")%>发表</div>
行 58: </div>
行 59: <div class="msgcontent" id="q<%# DataBinder.Eval(Container.DataItem, "id")%>"><%# ubbcode.UBBToHTML(DataBinder.Eval(Container.DataItem, "content").ToString())%></div>
行 60: <div class="function">
行 61: <img src="images/icon_1.gif" style="cursor:pointer" onclick="blogquote('q<%# DataBinder.Eval(Container.DataItem,"id") %>','<%# DataBinder.Eval(Container.DataItem,"username") %>','<%# DataBinder.Eval(Container.DataItem,"Addtime") %>');" width="16" height="16" hspace="5" align="absmiddle" border="0" />引用
源文件: d:\Work\FoosunCMS_32sp1_Free\NetMsg\ViewMsg.aspx 行: 59
请问大家问题出在哪里了,请指教 --------------------编程问答-------------------- 这是我的ubbcode.cs的源代码
using System;
using System.Text;
using System.Text.RegularExpressions;
/// <summary>
/// ubbcode 的摘要说明
/// </summary>
namespace ubb
{
public class ubbcode
{
public ubbcode()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static String UBBToHTML(string sDetail)
{
Regex r;
Match m;
#region 处理空格
sDetail = sDetail.Replace(" ", " ");
#endregion
#region HTML标记符
sDetail = sDetail.Replace("<", "<");
sDetail = sDetail.Replace(">", ">");
#endregion
#region 处标记
r = new Regex(@"(\[b\])([ \S\t]*?)(\[\/b\])", RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(), "<B>" + m.Groups[2].ToString() + "</B>");
}
#endregion
#region 处标记
r = new Regex(@"(\[i\])([ \S\t]*?)(\[\/i\])", RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(), "<I>" + m.Groups[2].ToString() + "</I>");
}
#endregion
#region 处标记
r = new Regex(@"(\[U\])([ \S\t]*?)(\[\/U\])", RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(), "<U>" + m.Groups[2].ToString() + "</U>");
}
#endregion
#region 处理[align=x][/align]
//处理[align=x][/align]
r = new Regex(@"(\[align=([\S]+)\])([ \S\t]*?)(\[\/align\])", RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<P align=" + m.Groups[2].ToString() + ">" +
m.Groups[3].ToString() + "</P>");
}
#endregion
#region 处[H=x][/H]标记
//处[H=x][/H]标记
r = new Regex(@"(\[H=([1-6])\])([ \S\t]*?)(\[\/H\])", RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<H" + m.Groups[2].ToString() + ">" +
m.Groups[3].ToString() + "</H" + m.Groups[2].ToString() + ">");
}
#endregion
#region 处理[list=x][*][/list]
//处理[list=x][*][/list]
r = new Regex(@"(\[list(=(A|a|I|i| ))?\]([ \S\t]*)\r\n)((\[\*\]([ \S\t]*\r\n))*?)(\[\/list\])", RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
string strLI = m.Groups[5].ToString();
Regex rLI = new Regex(@"\[\*\]([ \S\t]*\r\n?)", RegexOptions.IgnoreCase);
Match mLI;
for (mLI = rLI.Match(strLI); mLI.Success; mLI = mLI.NextMatch())
{
strLI = strLI.Replace(mLI.Groups[0].ToString(), "<LI>" + mLI.Groups[1]);
}
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<UL TYPE=\"" + m.Groups[3].ToString() + "\"><B>" + m.Groups[4].ToString() + "</B>" +
strLI + "</UL>");
}
#endregion
#region 处理换行
//处理换行,在每个新行的前面添加两个全角空格
r = new Regex(@"(\r\n(( )| )+)(?<正文>\S+)", RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(), "<BR> " + m.Groups["正文"].ToString());
}
//处理换行,在每个新行的前面添加两个全角空格
sDetail = sDetail.Replace("\r\n", "<BR>");
#endregion
#region 处理引用
r = new Regex(@"(\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\])", RegexOptions.IgnoreCase);
sDetail = sDetail.Replace(sDetail, "<table border='0' width='90%' cellspacing='0' cellpadding='0' align='center'><tr><td>引用内容:</td></tr><tr><td><table border='0' width='100%' cellspacing='1' cellpadding='10'><tr><td width='100%' bgcolor='#FFFFFF' class='code'>$1</td></tr></table></td></tr></table>");
#endregion
return sDetail;
}
}
}
--------------------编程问答-------------------- 不用回复了,我已经解决了
补充:.NET技术 , ASP.NET