简体   繁体   English

为什么会收到“编译器错误消息:CS1002:; 预期”错误消息在站点?

[英]Why do I get a “Compiler Error Message: CS1002: ; expected” error message at site?

Works fine at my dev. 我的开发人员工作正常。 PC, However once I run it on the site I get: PC,但是一旦我在网站上运行它,我就会得到:

Compiler Error Message: CS1002: ; 编译器错误消息:CS1002:; expected 预期

byte[] keyBytes = new Rfc2898DeriveBytes(PasswordHash, Encoding.ASCII.GetBytes(SaltKey)).GetBytes(256 / 8);

var symmetricKey = new RijndaelManaged() { Mode = CipherMode.CBC, Padding = PaddingMode.Zeros };

var encryptor = symmetricKey.CreateEncryptor(keyBytes, Encoding.ASCII.GetBytes(VIKey));

You'll get this if you're using a machine that only has .NET 2.0 or .NET 3.0 installed, and thus only a C# 2 compiler. 如果您使用的机器仅安装了.NET 2.0或.NET 3.0,因此仅安装了C#2编译器,则将获得此信息。

This code: 这段代码:

var symmetricKey = new RijndaelManaged() { Mode = CipherMode.CBC, ... };

... uses an object initializer which was introduced into C# 3. (It also uses var , which was introduced at the same time.) ...使用了C#3中引入的对象初始化器 。(它还使用了同时引入的var 。)

I suspect you just need to upgrade your web site to a more recent version of .NET. 我怀疑您只需要将您的网站升级到.NET的最新版本。

You could validate that this is the problem by simply having a statement of: 您可以通过简单地声明以下内容来验证这是问题所在:

var x = "";

I suspect you'll find that fails with an error that the compiler can't find the var type - whereas the C# 3+ compiler will use implicit typing instead. 我怀疑您会发现失败的原因是编译器找不到var类型-而C#3+编译器将改用隐式类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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