Win 7的IIS 7.5 System.ComponentModel.BrowseableAttribute怪异的行为 [英] Win 7 IIS 7.5 weird behavior with System.ComponentModel.BrowseableAttribute

查看:174
本文介绍了Win 7的IIS 7.5 System.ComponentModel.BrowseableAttribute怪异的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想看看其他人获得此相同的行为,我得到。

I just want to see if others get this same behavior I get.

我有一个名为GridViewEx类扩展GridView控件。一个在类中的属性具有可浏览(真)作为注解。这使得(很好,至少之前IIS 7.5的它做)的财产,以在标记进行设置。但在Windows 7 IIS 7.5,它提供了解析错误。请注意,IIS 7.5的一个双赢2008服务器上,应用程序运行得很好。

I have a class called GridViewEx which extends GridView. One of the properties in that class has Browsable(true) as an annotation. This allows (well, at least prior to IIS 7.5 it did) the property to be set in the markup. But on Windows 7 IIS 7.5, it gives a parser error. Note that on a Win 2008 server with IIS 7.5, the app ran fine.

所以我想知道如果它的一些IIS 7.5的设置在Win7被搞乱它。

So I'm wondering if it's some IIS 7.5 setting in Win7 that is messing it up.

a)创建新的ASP.Net应用程序,使用4.0 Framework版本

a) Create new ASP.Net application, use 4.0 for framework version

二)创建一个名为GridViewEx(get / set方法都只是虚设code,不重要的)新类:

b) Create a new class called GridViewEx (the get/set are just dummy code, not important):

namespace GUI.Controls
    {
        public class GridViewEx : GridView
        {
            [Browsable(true)]
            [Description("my test")]
            public int VirtualItemCount
            {
                get
                {
                    return 42;
                }
                set
                {
                    int x = value;
                    int y = x + x;
                }
            }

        }
    }

c)在Default.aspx的,注册标签preFIX(其他城市WebApplication1,无论你叫你的项目)。这条线应该去Page指令下的权利。

c) In Default.aspx, register the tag prefix (change WebApplication1 to whatever you called your project). This line should go right underneath the Page directive.

<%@ Register TagPrefix="common" Namespace="GUI.Controls" Assembly="WebApplication1" %>

d)在Default.aspx的,添加到您的内容:

d) In Default.aspx, add this to your content:

<common:GridViewEx runat="server" ID="gv" VirtualItemCount="-1">

</common:GridViewEx>


如果我在前面跑在IIS 7.0或者这个程序,我没有得到任何错误。但是,在Win 7 IIS 7.5,它提供了以下错误:


If I run this app on IIS 7.0 or earlier, I get no errors. However, on Win 7 IIS 7.5, it gives the following error:

Parser Error 
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: The 'VirtualItemCount' property cannot be set declaratively.

我不明白为什么我得到Win 7的错误IIS 7.5,但不是在早期版本的IIS,而不是一个双赢2008服务器上的IIS 7.5。任何想法?

I don't understand why I get the error on Win 7 IIS 7.5, but not on earlier IIS versions and not on IIS 7.5 on a Win 2008 server. Any ideas?

推荐答案

好吧,我发现一个黑客,使这项工作。添加这些属性 VirtualItemCount

Ok, I found a hack to make this work. Added these attributes to VirtualItemCount:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[EditorBrowsable(EditorBrowsableState.Always)]
[Bindable(true)]

现在我不再得到分析器错误。我不明白,为什么我不得不添加这些在我的Win 7的机器上工作,使,但在服务器上我测试了这些额外的属性是不需要的(包括我的Win 7的计算机和服务器都在IIS 7.5) 。我想这将仍是一个谜。

Now I no longer get the parser error. I don't understand why I had to add these to make in work on my Win 7 machine, but on the server I tested it on these extra attributes aren't needed (both my Win 7 machine and the server are on IIS 7.5). I guess that will remain a mystery.

非常感谢谁回答的人<一个href=\"http://stackoverflow.com/questions/10180736/why-wont-my-custom-controls-text-property-show-up-in-the-properties-window\">this问题,因为它把我领到了正确的方向。

Many thanks to the person who answered this question, as it steered me in the right direction.

这篇关于Win 7的IIS 7.5 System.ComponentModel.BrowseableAttribute怪异的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆