在这篇文章中,我们将为您详细介绍从PathTooLongException中检索path信息的内容,并且讨论关于寻找path变量的相关问题。此外,我们还会涉及一些关于asp.net-mvc–从ASP.
在这篇文章中,我们将为您详细介绍从PathTooLongException中检索path信息的内容,并且讨论关于寻找path变量的相关问题。此外,我们还会涉及一些关于asp.net-mvc – 从ASP.NET MVC 1迁移到ASP.NET MVC 2后的PathTooLongException、Caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method ''get...、com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException,OkHttp时间戳校验问题、elasticsearch.exceptions.AuthorizationException: AuthorizationException的知识,以帮助您更全面地了解这个主题。
本文目录一览:- 从PathTooLongException中检索path信息(寻找path变量)
- asp.net-mvc – 从ASP.NET MVC 1迁移到ASP.NET MVC 2后的PathTooLongException
- Caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method ''get...
- com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException,OkHttp时间戳校验问题
- elasticsearch.exceptions.AuthorizationException: AuthorizationException
从PathTooLongException中检索path信息(寻找path变量)
我在.net 4.0中使用DirectoryInfo和FileInfo来枚举目录树中的文件,我打到PathTooLongException。 简体版如下
public static class Test { public static void Search(DirectoryInfo base) { foreach(var file in base.GetFiles()) { try { Console.WriteLine(file.FullName); } catch(PathTooLongException ex) { // What path was this? } } foreach(var dir in base.GetDirectories()) { Search(dir); } } }
当错误被抛出时,我想知道什么文件path导致了这个问题。 显然,我不能要求FullName因为这是错误的。 我可以从file.Name得到名称,但是如果我不能得到path的其余部分作为file.Directory给出了一个PathTooLongException即使DirectoryInfo文件被发现工作正常! (我不能使用,但实际的代码要复杂得多)。
通过堆栈跟踪来看,它似乎是使用一个内部path(我看到一个受保护的file.FullPath从debugging),并试图从完整(超大)的path撕裂的目录。 大部分的问题似乎涉及到System.IO.Path.normalizePath ,我听说在.Net 4.0中经历了一些改变。 我还没有尝试过以前的版本的框架。
我的问题:
是否有任何技巧来计算文本文件中的行数?
启动一个执行委托的新进程
在Linux上运行ASP Classic和.NET
DataGridView不填充
input语言挂钩
我怎样才能从这个例外中得到完整的path; 似乎没有任何有用的信息通过。
为什么框架需要限制path中的字符来切断文件名?
提前感谢您的帮助,
安迪
带有通配符的.NET DirectoryInfo.GetFiles在不同的驱动器上有不同的含义
如何检测SD卡何时插入?
我怎样才能捕捉到另一个进程的未处理的exception?
机器在.NET中的域名?
特定networking接口IPv4可用性 – 无连接,本地,Internet
除了使用反射,或者使用库或P / Invoke来使用支持长路径的Windows API并手动检查长度之外,我无法想象其他任何方式。 完整路径存储在名为FullPath的protected string字段中
foreach(var dir in new DirectoryInfo (@"D:longpaths") .GetFileSystemInfos("*.*",SearchOption.AllDirectories)) { try { Console.WriteLine(dir.FullName); } catch (PathTooLongException) { FieldInfo fld = typeof(FileSystemInfo).GetField( "FullPath",BindingFlags.Instance | BindingFlags.NonPublic); Console.WriteLine(fld.GetValue(dir)); // outputs your long path } }
如果你试图用文件做一些事情,而不是仅仅检查文件的长度,那么我会建议你使用像BCL团队这样的一个库,但是它不会创建DirectoryInfos , FileInfo或者FileSystemInfo ,只有字符串。 所以它可能不是你的代码似乎替代你的代码。
至于你的第二个问题的答案,我建议阅读这篇博客文章处理.NET中的长路径。 这是一个引用,解释了为什么他们没有很快在.NET中添加长路径支持。
很少有人抱怨32K的限制,所以问题解决了? 不完全的。 有几个原因,我们不愿意在过去添加长路径,为什么我们仍然很小心,涉及安全性, API语法中的不一致的支持,以及应用程序的兼容性。
这是一个由3部分组成的系列文章,解释了为什么API是这样的以及为什么限制在那里的一些原因。
asp.net-mvc – 从ASP.NET MVC 1迁移到ASP.NET MVC 2后的PathTooLongException
[PathTooLongException: The specified path,file name,or both are too long. The fully qualified file name must be less than 260 characters,and the directory name must be less than 248 characters.] System.IO.Path.SafeSetStackPointerValue(Char* buffer,Int32 index,Char value) +7493057 System.IO.Path.normalizePathFast(String path,Boolean fullCheck) +387 System.IO.Path.normalizePath(String path,Boolean fullCheck) +36 System.IO.Path.GetFullPathInternal(String path) +21 System.Security.Util.StringExpressionSet.CanonicalizePath(String path,Boolean needFullPath) +73 System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str,Boolean needFullPath) +278 System.Security.Permissions.FileIOPermission.AddpathList(FileIOPermissionAccess access,AccessControlActions control,String[] pathListOrig,Boolean checkForDuplicates,Boolean needFullPath,Boolean copyPathList) +87 System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access,String path) +65 System.Web.InternalSecurityPermissions.Pathdiscovery(String path) +29 System.Web.HttpRequest.MapPath(VirtualPath virtualPath,VirtualPath baseVirtualDir,Boolean allowCrossAppMapping) +146 System.Web.HttpRequest.MapPath(VirtualPath virtualPath) +37 System.Web.HttpServerUtility.Execute(IHttpHandler handler,TextWriter writer,Boolean preserveForm,Boolean setPrevIoUsPage) +43 System.Web.HttpServerUtility.Execute(IHttpHandler handler,Boolean preserveForm) +28 System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler,Boolean preserveForm) +22 System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext) +284 System.Web.Mvc.WebFormView.RenderViewPage(ViewContext context,ViewPage page) +82 System.Web.Mvc.WebFormView.Render(ViewContext viewContext,TextWriter writer) +85 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +267 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext,ActionResult actionResult) +10 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext,String actionName) +320 System.Web.Mvc.Controller.ExecuteCore() +104 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +36 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 System.Web.Mvc.<>c__displayClass8.<BeginProcessRequest>b__4() +34 System.Web.Mvc.Async.<>c__displayClass1.<MakeVoidDelegate>b__0() +21 System.Web.Mvc.Async.<>c__displayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +53 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +30 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8678910 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously) +155
我知道ASP.NET中260-character-url-lenght的问题,但我的应用程序在更新到ASP.NET MVC 2.0之前工作正常!
此问题不仅发生在本地,也发生在远程主机上
我比较了RenderView方法实现.
MVC 1:
public virtual void RenderView(ViewContext viewContext) { ViewContext = viewContext; InitHelpers(); // Tracing requires Page IDs to be unique. ID = Guid.NewGuid().ToString(); ProcessRequest(HttpContext.Current); }
MVC 2:
public virtual void RenderView(ViewContext viewContext) { ViewContext = viewContext; InitHelpers(); bool needServerExecute = false; SwitchWriter switchWriter = viewContext.HttpContext.Response.Output as SwitchWriter; if (switchWriter == null) { switchWriter = new SwitchWriter(); needServerExecute = true; } using (switchWriter.Scope(viewContext.Writer)) { if (needServerExecute) { // It's safe to reset the _nextId within a Server.Execute() since it pushes a new TraceContext onto // the stack,so there won't be an ID conflict. int originalNextId = _nextId; try { _nextId = 0; viewContext.HttpContext.Server.Execute(HttpHandlerUtil.WrapForServerExecute(this),switchWriter,true /* preserveForm */); } finally { // Restore the original _nextId in case this isn't actually the outermost view,since resetting // the _nextId may Now cause trace ID conflicts in the outer view. _nextId = originalNextId; } } else { ProcessRequest(HttpContext.Current); } } }
解决方法
<httpRuntime maxUrlLength="1000" relaxedUrlToFileSystemMapping="true" />
Caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method ''get...
Running TestSuite
[TestNG] [WARN] Ignoring duplicate listener : org.uncommons.reportng.HTMLReporter
[TestNG] [WARN] Ignoring duplicate listener : org.uncommons.reportng.JUnitXMLReporter
[INFO ] 2019-04-21 18:26:24,609 method:com.chen.autocases.TestDemo.testcase1(TestDemo.java:10)
testcase1
[TestNG] Reporter org.uncommons.reportng.HTMLReporter@1e7bba3 failed
org.uncommons.reportng.ReportNGException: Failed generating HTML report.
at org.uncommons.reportng.HTMLReporter.generateReport(HTMLReporter.java:122)
at org.testng.TestNG.generateReports(TestNG.java:1097)
at org.testng.TestNG.run(TestNG.java:1022)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:170)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:84)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:156)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:82)
at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess(InPluginVMSurefireStarter.java:82)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:867)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:747)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:645)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:318)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:331)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:185)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:139)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:70)
at hudson.remoting.UserRequest.perform(UserRequest.java:181)
at hudson.remoting.UserRequest.perform(UserRequest.java:52)
at hudson.remoting.Request$2.run(Request.java:336)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method ''getUser'' in class org.uncommons.reportng.ReportMetadata threw exception class java.net.UnknownHostException : bogon: bogon: Temporary failure in name resolution
at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:193)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:175)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:220)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230)
at org.apache.velocity.Template.merge(Template.java:256)
at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:449)
at org.uncommons.reportng.AbstractReporter.generateFile(AbstractReporter.java:108)
at org.uncommons.reportng.HTMLReporter.createOverview(HTMLReporter.java:148)
at org.uncommons.reportng.HTMLReporter.generateReport(HTMLReporter.java:111)
... 48 more
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 15.332 sec <<< FAILURE! - in TestSuite
testcase1(com.chen.autocases.TestDemo) Time elapsed: 0.01 sec <<< FAILURE!
java.lang.AssertionError: expected [true] but found [false]
解决方法:
[root@bogon secrets]# hostname
bogon
解决方法:
1 执行hostname命令
可以看出 ping 不通我们的hostname 这就是原因所在
2 修改 /etc/sysconfig/network
改成我们的hostname命令下的名字
3 修改 /etc/hosts内容
加上我们的hostname命令下的名字
4 最后执行 /etc/rc.d/init.d/network rest
com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException,OkHttp时间戳校验问题
这个问题不常见,但是我遇到了,网上不好搜,基本是onFailure:javax.net.ssl.SSLHandshakeException,所以我标题没有前面加上这个
原因:你看下你设备上系统时间是不是不对←..←
解决:
1、时间改过来啊
2、联网校验手机本地时间
public class SSLCertificate { public static SSLSocketFactory SSLSocketFactorygetSSLSocketFactory(){ final TrustManager[] trustAllCerts =new TrustManager[]{ new x509trustmanager() { @Override public void checkClientTrusted(X509Certificate[] x509Certificates,String s) throws CertificateException { } @Override public void checkServerTrusted(X509Certificate[] x509Certificates,String s) throws CertificateException { } @Override public X509Certificate[] getAcceptedissuers() { return new X509Certificate[0]; } } }; SSLContext sslContext =null; try { sslContext = SSLContext.getInstance("SSL"); sslContext.init(null,trustAllCerts,new java.security.SecureRandom()); } catch (NoSuchAlgorithmException e) { e.printstacktrace(); } catch (KeyManagementException e) { e.printstacktrace(); } final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); return sslSocketFactory; } }
对 OkHttpClient 时间校验
OkHttpClient.Builder builder = new OkHttpClient.Builder() .sslSocketFactory(SSLCertificate.SSLSocketFactorygetSSLSocketFactory()) .hostnameVerifier(new HostnameVerifier() { @Override public boolean verify(String s,SSLSession sslSession) { return true; } });
OK,你试试吧
elasticsearch.exceptions.AuthorizationException: AuthorizationException
如何解决elasticsearch.exceptions.AuthorizationException: AuthorizationException?
elasticsearch 错误:
_request
self._raise_error(response.status_code,raw_data)
File "/Users/soubhagyapradhan/Desktop/upwork/africa/backend/env/lib/python3.8/site-packages/elasticsearch/connection/base.py",line 315,in _raise_error
raise HTTP_EXCEPTIONS.get(status_code,TransportError)(
elasticsearch.exceptions.AuthorizationException: AuthorizationException(403,''{"message":"The security token included in the request is invalid."}'')
ERROR 2021-04-28 03:13:17,280 basehttp 2729 123145562267648 "POST /en/signup HTTP/1.1" 500 53
Django 代码:
awsauth = AWS4Auth(
os.environ.get("AWS_ES_ACCESS_KEY"),os.environ.get("AWS_ES_SECRET_KEY"),os.environ.get("AWS_ES_REGION"),os.environ.get("AWS_ES_SERVICE"),)
# Elasticsearch configuration
ELASTICSEARCH_DSL = {
"default": {
"hosts": [
{"host": os.environ.get("AWS_ES_URL"),"port": 443},],"http_auth": awsauth,"use_ssl": True,"verify_certs": True,"connection_class": Requestshttpconnection,"request_timeout": 60,}
}
这是我的代码和错误共享。我的 elasticsearch 工作正常,但突然出现了这个问题。 请告诉我如何解决这个问题。
为此我需要任何令牌吗?以及如何获得
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
关于从PathTooLongException中检索path信息和寻找path变量的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于asp.net-mvc – 从ASP.NET MVC 1迁移到ASP.NET MVC 2后的PathTooLongException、Caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method ''get...、com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException,OkHttp时间戳校验问题、elasticsearch.exceptions.AuthorizationException: AuthorizationException等相关内容,可以在本站寻找。
本文标签: