Reputation: 1198
i am using MVC 6 and i have referred the following name space,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Syncfusion.JavaScript.Shared.Serializer;
using System.Reflection;
here is my code,
static bool CanConvertTo<T>(string s) {
TypeConverter converter = TypeDescriptor.GetConverter(typeof(T));
return converter.IsValid(s);
}
it throw the error like this,
'TypeConverter' does not contain a definition for 'IsValid' and no extension method 'IsValid' accepting a first argument of type 'TypeConverter' could be found (are you missing a using directive or an assembly reference?)
this was reproduced only in MVC6
how to resolve this and there is any alternate solution for this?
Upvotes: 0
Views: 368
Reputation: 3439
There is IsValid
method in System, Version=4.0.0.0
:
namespace System.ComponentModel
{
public class TypeConverter
{
// other members
public bool IsValid(object value)
{
// some implementation
}
}
}
There are two frameworks in your configuration: dnx451
and dnxcore50
. I'm not sure the method IsValid
exists in dnxcore50
.
If you use only dnx451
framework, I recommend you try it:
1) Switch the project framework to dnx451
(or delete dnxcore50
section from project.json
). If it's useless then:
2) Update the project to MVC 6 beta 7
and use next configuration in project.jso
n:
"dependencies": {
"EntityFramework.SqlServer": "7.0.0-beta7",
"EntityFramework.Commands": "7.0.0-beta7",
"Microsoft.AspNet.Mvc": "6.0.0-beta7",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta7",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.Google": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta7",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta7",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta7",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta7",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta7",
"Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta7",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta7",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta7",
"Microsoft.Framework.Logging": "1.0.0-beta7",
"Microsoft.Framework.Logging.Console": "1.0.0-beta7",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta7"
},
"frameworks": {
"dnx451": { }
}
I tried your example code in a project with this configuration and there are not any problems. My solution DNX SDK version is 1.0.0-beta7
.
Upvotes: 0