编译期待右括号无开括号 [英] Compiler Expecting Closing Bracket Without Opening Bracket

查看:189
本文介绍了编译期待右括号无开括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图通过以下的认证=htt​​p://docs.cksource.com/ ckfinder3网/ howto.html#howto_custom_authenticator相对=nofollow>这个HOWTO,我写了下面的文件,保存到我的CKFinder目录:

In trying to implement authentication in CKFinder by following this "howto", I've written the following file, saved to my CKFinder directory:

<%@page codepage="65001" language="C#" lcid="6153"%>
<%
using CKSource.CKFinder.Connector.Core;
using CKSource.CKFinder.Connector.Core.Authentication;
public class MyAuthenticator:IAuthenticator{
    public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){
        return Task.FromResult((IUser)new User(true,"editor"));
    }
}
%>

然而,当我尝试加载它,我就包含第二使用线路得到一个编译器错误( CS1513 声明中指出,一个右括号(} )预计,尽管没有开括号( {)在该行之前的文件的任何地方。

However, when I try to load it, I get the a compiler error (CS1513) on the line containing the second using statement stating that a closing bracket (}) is expected, despite the fact that there is no opening bracket ({) anywhere in the file before that line.

由于我旁边没有ASP.NET知识,有人可以阐明这里发生了什么有一些启发,我将如何去解决呢?

Given that I have next to no knowledge of ASP.NET, can someone shed some light on what's happening here and how I would go about solving it?

我,尽管知道它不会工作,尝试添加一个} 到该行的末尾,看看会发生什么,它抛出一个不同的编译器错误 - CS1518 :预期类,委托,枚举,接口或结构 - 在一个完全不同的文件。App_Web_auth.aspx * 0.cs(星号这是奇怪的是,嵌套几个目录下我的%WINDIR%每重装字符)的随机字符串。在线214出现的错误,这是在以下提取第二行:

I have, despite knowing it wouldn't work, tried adding a } to the end of that line to see what would happen and it throws a different compiler error - "CS1518: Expected class, delegate, enum, interface, or struct" - in a completely different file "App_Web_auth.aspx.*.*.0.cs" (the asterisks being random strings of characters on each reload) which, strangely, is nested a few directories down in my %WINDIR%. That error occurs on line 214, which is the second line in the following extract:

[System.Diagnostics.DebuggerNonUserCodeAttribute()]
protected override void FrameworkInitialize() {
    base.FrameworkInitialize();
    this.@__BuildControlTree(this);
    this.AddWrappedFileDependencies(global::ASP.auth_aspx.@__fileDependencies);
    this.Request.ValidateInput();
}

更新1

如果我完全删除公共类,我得到另一个编译错误 - CS1003:语法错误,(预期的 - 这时候就含有的行第一个使用语句,试验和错误导致我找出了使用语句需要被封闭在parnetheses但是,在加入公共类回去后,我仍然得到有关原始错误缺少}

UPDATE 1

If I remove the public class completely, I get yet another compiler error - "CS1003: Syntax error, '(' expected" - this time on the line containing the first using statement. Trial and error led me to figure out that the using statements need to be enclosed in parnetheses but, after adding the public class back in, I still get the original error about the missing }.

<%@page codepage="65001" language="C#" lcid="6153"%>
<%
using(CKSource.CKFinder.Connector.Core);
using(CKSource.CKFinder.Connector.Core.Authentication);
public class MyAuthenticator:IAuthenticator{
    public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){
        return Task.FromResult((IUser)new User(true,"editor"));
    }
}
%>

再取出类导致另一个新的错误 - CS0119 :'CKSource.CKFinder.Connector.Core'是'命名空间,这是无效的给定上下文

Removing the class again leads to another new error - "CS0119: 'CKSource.CKFinder.Connector.Core' is a 'namespace', which is not valid in the given context"

每的与SeM 建议,我增加了以下内容CKF的的web.config文件的的System.Web 部分:

Per SeM's suggestion, I added the following to the system.web section of CKF's "Web.config" file:

<pages>
    <namespaces>
        <add namespace="CKSource.CKFinder.Connector.Core" />
        <add namespace="CKSource.CKFinder.Connector.Core.Authentication" />
    </namespaces>
</pages>

和更新了我的文件的内容是:

And updated the contents of my file to be:

<%@page codepage="65001" language="C#" lcid="6153"%>
<%@import namespace="ConnectorBuilder.SetAuthenticator"%>
<%
public class MyAuthenticator:IAuthenticator{
    public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){
        return Task.FromResult((IUser)new User(true,"editor"));
    }
}
%>

然而,这导致了原来的错误( CS1513 :}预期)目前正在扔在那个神秘文件的行214(在下面摘录第一行)在我的%WINDIR% - 与该文件的内容添加怪事已经在某种程度上改变了

This, however, leads to the original error ("CS1513: } expected") now being thrown on line 214 (first line in below extract) of that mystery file in my %WINDIR% - with the added weirdness of the contents of that file having somehow changed.

private void @__Render__control1(System.Web.UI.HtmlTextWriter @__w, System.Web.UI.Control parameterContainer) {

    #line 3 "x:\redacted\path\to\myfile.aspx"

public class MyAuthenticator:IAuthenticator{
    public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){
        return Task.FromResult((IUser)new User(true,"editor"));
    }
}


    #line default
    #line hidden
}

更新3

更改我的文件使用剧本标签:

<%@page codepage="65001" language="c#" lcid="6153"%>
<%@import namespace="ConnectorBuilder.SetAuthenticator"%>
<script language="c#" runat="server">
    public class MyAuthenticator:IAuthenticator{
        public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){
            return Task.FromResult((IUser)new User(true,"editor"));
        }
    }
</script>

引出一个全新的错误第2行: CS0246 :类型或命名空间名称ConnectorBuilder'找不到(是否缺少using指令或程序集引用?)

Leads to a brand new error on line 2: "CS0246: The type or namespace name 'ConnectorBuilder' could not be found (are you missing a using directive or an assembly reference?)"

我删除了导入指令和接收的上线,宣布公共任务的以下错误: CS0246 :类型或命名空间名称'的CancellationToken'找不到(是否缺少using指令或程序集引用?)。

I removed the import directive and received the following error on the line declaring the public task: "CS0246: The type or namespace name 'CancellationToken' could not be found (are you missing a using directive or an assembly reference?)".

推荐答案

试试这个:

<%@page codepage="65001" language="C#" lcid="6153"%>
<%@ Import namespace="YourProgram.YourNamespace" %>
<%
public class MyAuthenticator:IAuthenticator{
    public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){
        return Task.FromResult((IUser)new User(true,"editor"));
    }
}
%>

的web.config

<system.web>    
<pages>
   <namespaces>
      <add namespace="CKSource.CKFinder.Connector.Core" />
      <add namespace="CKSource.CKFinder.Connector.Core.Authentication" />
   </namespaces>
</pages>

请试试这个你 ASPX 页:

<%@page codepage="65001" language="C#" lcid="6153"%>
<%@ Import namespace="ConnectorBuilder.SetAuthenticator" %>
<script language="c#" runat="server">
    public class MyAuthenticator:IAuthenticator
    {
        public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken)
        {
            return Task.FromResult((IUser)new User(true,"editor"));
        }
    }
</script>

这篇关于编译期待右括号无开括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆