我刚刚升级到VS2017,但马上就关闭了,我的项目无法再生成,因为我收到了一堆当我使用VS15时不存在的奇怪编译器错误。Visual Studio 2017编译器错误
错误如:
Syntax Error; value expected
Invalid Expression Term '['
Invalid Expression Term 'byte'
Using the generic type requires 1 type arguments
编辑1:
- 就创建了一个小型控制台应用程序,并复制了一些代码,并在相同的编译器错误(S)的出现
using System;
using System.Runtime.InteropServices;
namespace Error
{
class Program
{
static void Main()
{
Array array2D = null;
if (array2D is Bgra <byte>[,])
{
}
}
}
public interface IColor { }
public interface IColor<T> : IColor
where T : struct
{ }
public interface IColor2 : IColor { }
public interface IColor2<T> : IColor2, IColor<T>
where T : struct
{ }
public interface IColor3 : IColor { }
public interface IColor3<T> : IColor3, IColor<T>
where T : struct
{ }
public interface IColor4 : IColor { }
public interface IColor4<T> : IColor4, IColor<T>
where T : struct
{ }
[StructLayout(LayoutKind.Sequential)]
public struct Bgra<T> : IColor4<T>
where T : struct
{
public Bgra(T b, T g, T r, T a)
{
B = b;
G = g;
R = r;
A = a;
}
public T B;
public T G;
public T R;
public T A;
public override string ToString()
{
return $"B: {B}, G: {G}, R: {R}, A: {A}";
}
public const int IDX_B = 0;
public const int IDX_G = 1;
public const int IDX_R = 2;
public const int IDX_A = 3;
}
}
需要注意的是完全相同的项目编译在VS15甚至VS13没关系。
你可以在一个小程序中重现错误? –
它是否指定了一行代码“语法错误”应该是,如果是这样的行? –
@MthetheWWatson#编辑 –