c# System.guid does not contain a definition for Parse

拜拜、爱过 提交于 2019-12-07 05:20:47

问题


AT.Anchor = System.Guid.Parse(DataBinder.Eval(e.Item.DataItem, "Anchor").ToString());

This throws:

'System.Guid' does not contain a definition for 'Parse'

When I try and build it. But it runs fine, any idea how I can handle this better?

Edit

Here is a section of my web.config

    <compilation defaultLanguage="c#" debug="true">
        <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
            <add assembly="System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
            <add assembly="MySql.Data.Entity, Version=6.3.6.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
            <add assembly="MySql.Web, Version=6.3.6.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/></assemblies>
    </compilation>

回答1:


Guid.TryParse is part of .NET 4. Make sure you're both building and running against .NET 4, and it should be fine.




回答2:


One of the things with IIS app pools is that the first web application that starts in an app pool determines the CLR version used by that app pool.

If the first app started was built for, say, .Net v1.1, then every app started after that will run against the v1.1 runtime. If your app, which gets started next, was built for, say, the 4.0 runtime, you're unlikely to find happiness. Some might consider this to be a feature. Or not.

"Start", in this case, means "receives an HTTP request". This means that the runtime version you get is essentially random: it depends on what the clients do, and in what order, after your bounce the app pool or bounce IIS.

You need to be careful to put your web apps in appropriate app pools. Either bundle each web app in its own app pool, or set up an app pool per CLR version and be careful to put your web apps in the correct app pool.



来源:https://stackoverflow.com/questions/5757615/c-sharp-system-guid-does-not-contain-a-definition-for-parse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!