作者:革斤Hero_394 | 来源:互联网 | 2023-10-11 16:11
IamtryingtomigrateawebapptoASP.NetvNextwiththeeventualaimofgettingitrunningonLin
I am trying to migrate a web app to ASP.Net vNext with the eventual aim of getting it running on Linux.
我正在尝试将Web应用程序迁移到ASP.Net vNext,最终目的是让它在Linux上运行。
The app has a lot of reflection code and I must be missing some dependencies as I am getting compile errors on code such as this
该应用程序有很多反射代码,我必须缺少一些依赖项,因为我在代码上遇到编译错误
Type.IsPrimitive, Type.GetConstructor Type.GetMethod Type.GetTypeArray Error CS1061 'Type' does not contain a definition for 'IsPrimitive' and no extension method 'IsPrimitive' accepting a first argument of type 'Type' could be found (are you missing a using directive or an assembly reference?)
Type.IsPrimitive,Type.GetConstructor Type.GetMethod Type.GetTypeArray错误CS1061'Type'不包含'IsPrimitive'的定义,并且没有扩展方法'IsPrimitive'接受类型'Type'的第一个参数可以找到(你是否遗漏了) using指令或程序集引用?)
Error CS1061 'Type' does not contain a definition for 'GetMethod' and no extension method 'GetMethod' accepting a first argument of type 'Type' could be found (are you missing a using directive or an assembly reference?)
错误CS1061'Type'不包含'GetMethod'的定义,并且没有扩展方法'GetMethod'接受类型'Type'的第一个参数(你是否缺少using指令或汇编引用?)
Error CS1061 'Type' does not contain a definition for 'GetProperties' and no extension method 'GetProperties' accepting a first argument of type 'Type' could be found (are you missing a using directive or an assembly reference?)
错误CS1061'Type'不包含'GetProperties'的定义,也没有扩展方法'GetProperties'接受类型'Type'的第一个参数(你是否缺少using指令或汇编引用?)
Error CS1061 'Type' does not contain a definition for 'GetInterface' and no extension method 'GetInterface' accepting a first argument of type 'Type' could be found (are you missing a using directive or an assembly reference?)
错误CS1061'Type'不包含'GetInterface'的定义,也没有扩展方法'GetInterface'接受类型'Type'的第一个参数(你是否缺少using指令或汇编引用?)
I have the following dependencies in my project.json files
我的project.json文件中有以下依赖项
"frameworks" : {
"aspnetcore50" : {
"dependencies": {
"System.Runtime": "4.0.20-beta-22416",
"System.Linq": "4.0.0.0-beta-22605",
"System.Reflection": "4.0.10.0-beta-22605",
"System.Reflection.Primitives": "4.0.0.0-beta-22605",
"System.Runtime.Extensions": "4.0.10.0-beta-22605",
"System.Reflection.Extensions": "4.0.0.0-beta-22605"
}
The following compiles fine under VS 2013 and .Net 4.5 but wont compile in VS 2015 using the dependencies above
以下编译在VS 2013和.Net 4.5下很好,但不会使用上面的依赖项在VS 2015中编译
using System;
using System.Reflection;
namespace Project1
{
public class Class1
{
public Class1()
{
Type lBaseArrayType = typeof(Array);
Type lStringType = typeof(string);
string[] lStringArray = new string[1];
if (lStringType.IsPrimitive)
{
}
ConstructorInfo lCOnstructor= lStringType.GetConstructor(new Type[0]);
MethodInfo lMethod = lStringType.GetMethod("Equals");
Type[] lTArray = Type.GetTypeArray(lStringArray);
PropertyInfo[] lProps = lStringType.GetProperties();
}
}
}
2 个解决方案