问题的扩展方法:IXmlLineInfo方法、问题、IXmlLineInfo

2023-09-07 09:31:46 作者:老子单身照样嗨

当我尝试使用任何扩展方法上我的课在ASCX控制:

When I try to use any extension method to my class in ascx-control:

<%@ Import Namespace="VfmElita.Page.Stat" %>
<%=new MyTestClass().ExtMethod() %>

,这里是世界上最简单的方法:

and here is the simplest method in the world:

namespace VfmElita.Page.Stat
{
public static class TestExtention
{
    public static string ExtMethod(this MyTestClass test)
    {
        return "Hope for result";
    }
}
}

(它位于控制ascx.cs文件

(it is located in ascx.cs-file of the control

我得到了以下错误:

错误CS0012:类型System.Xml.IXmlLineInfo在未被引用的程序集中定义。您必须添加一个引用程序集的System.Xml,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e'。

error CS0012: The type 'System.Xml.IXmlLineInfo' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.

如果我换成 ExtMethod()与任何财产

<%= Team.GetTeamById(2).PropOk %>

例如,一切都很好...

for example, everything is fine...

为什么呢?我怎样才能prevent呢?

Why? How can I prevent this?

P.S。好像问题是重复的一个我的previous 或的另一个。但是,当前有更具体和pretty的详细介绍。

P.S. It seems like question is duplicate to one of my previous or another one. But the current one is more specific and pretty detailed.

P.S。我试图添加引用手动网站,VisualStuido告诉它具有一定的参考已经...

P.S. I've tried to add reference to web-site manually, VisualStuido tells that it has reference already...

推荐答案

我不知道什么是这种奇怪的行为的来源......一切都很好与此扩展方法......对另一个问题的回答上(http: //stackoverflow.com/questions/4665475/problem-with-system-xml-ixmllineinfo/4719876#4719876)解决当前的问题了。

I don't know what is a source of such strange behavior... everything is fine with this Extension Method... answer for another question (http://stackoverflow.com/questions/4665475/problem-with-system-xml-ixmllineinfo/4719876#4719876) resolved current question too.