简体   繁体   中英

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

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>

Guid.TryParse是.NET 4的一部分。确保你是在构建和运行.NET 4,它应该没问题。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM