此处将为大家介绍关于创建资源路径时从ZipFileSystemProvider获取FileSystemNotFoundException的详细内容,并且为您解答有关创建资源文件夹的相关问题,此外,我们
此处将为大家介绍关于创建资源路径时从ZipFileSystemProvider获取FileSystemNotFoundException的详细内容,并且为您解答有关创建资源文件夹的相关问题,此外,我们还将为您介绍关于android java.lang.IllegalStateException: System services not available to Activities before onCreate、c# – FileNotFoundException在System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()、c# – System.IO.FileLoadException:无法加载文件或程序集“System.Data.SQLite”、c# – 如何解决此System.IO.FileNotFoundException的有用信息。
本文目录一览:- 创建资源路径时从ZipFileSystemProvider获取FileSystemNotFoundException(创建资源文件夹)
- android java.lang.IllegalStateException: System services not available to Activities before onCreate
- c# – FileNotFoundException在System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()
- c# – System.IO.FileLoadException:无法加载文件或程序集“System.Data.SQLite”
- c# – 如何解决此System.IO.FileNotFoundException
创建资源路径时从ZipFileSystemProvider获取FileSystemNotFoundException(创建资源文件夹)
我有一个Maven项目,并且在一种方法内想在我的资源文件夹中为目录创建路径。这样做是这样的:
try { final URI uri = getClass().getResource("/my-folder").toURI(); Path myFolderPath = Paths.get(uri);} catch (final URISyntaxException e) { ...}
生成的URI
看起来像jar:file:/C:/path/to/my/project.jar!/my-folder
。
stacktrace如下:
Exception in thread "pool-4-thread-1" java.nio.file.FileSystemNotFoundException at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171) at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157) at java.nio.file.Paths.get(Paths.java:143)
在URI
似乎是有效的。之前的部分!
指向生成的jar文件,之后的部分指向my-folder
存档的根目录。在创建资源路径之前,我已经使用了此说明。为什么现在我要例外?
答案1
小编典典您需要先创建文件系统,然后才能访问zip之类的路径
final URI uri = getClass().getResource("/my-folder").toURI();Map<String, String> env = new HashMap<>(); env.put("create", "true");FileSystem zipfs = FileSystems.newFileSystem(uri, env);Path myFolderPath = Paths.get(uri);
这不会自动完成。
参见http://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/zipfilesystemprovider.html
android java.lang.IllegalStateException: System services not available to Activities before onCreate
java.lang.IllegalStateException: System services not available to Activities before onCreate()出现这种情况一般是因为 通过使用new关键字实例化Activity类,这样是错误的。因为Activity是系统通过ActivityManagerService创建管理的。 new之后,创建了对象,但没有创建这个Activity,要知道Activity的对象和在Android中真正表示的东西,不是一样的。 对象创建完成后,需要系统对其进行一系列的init和管理。在这个创建的过程中,会回调Acitivity中的onCreate方法,这个方法调用之后,才能说明Activity是创建完成了。
所以就不能使用new关键字实例化Activity对象,要通过startActivity的方式,实例化这个Activity对象。
原文链接: http://blog.csdn.net/centralperk/article/details/7496877
c# – FileNotFoundException在System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()
var entry = new DirectoryEntry("WinNT://DOMAIN/MachineName,Computer"); Console.WriteLine(entry.Guid);
实际上,路径由命令行提供.这个简单的控制台应用程序是为了测试而编译的,在我的测试中我发现:
>连接到我自己的Windows 7 PC工作.
>连接到网络上的任何其他Windows XP机器,工作.
>连接到网络上的任何其他Windows 7计算机失败,包括:
Unhandled Exception: System.IO.FileNotFoundException: The network path was not found.
at System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()
at System.DirectoryServices.DirectoryEntry.RefreshCache()
at System.DirectoryServices.DirectoryEntry.FillCache(String propertyName)
at System.DirectoryServices.DirectoryEntry.get_NativeGuid()
at System.DirectoryServices.DirectoryEntry.get_Guid()
at GetDirectoryEntryProperties.Program.Main(String[] args) in D:\GetDirectoryEntryProperties\Program.cs:line 15
有任何想法吗?
我是所有机器上的管理员,但是由于设备锁定服务引起了另一个问题,导致在询问时出现UnauthorizedAccessException异常,但在这种情况下,我甚至无法阅读机器的Guid.
事件日志没有任何用处.
卢克
解决方法
升级到Windows 10后,我的电脑启动时出现弹出错误,看起来就像您发布的那样.这是System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()中的FileNotFoundException.
解决方案是将两个字符串从一个注册表位置复制到另一个.
copy these strings: RegisteredOwner and RegisteredOrganization From: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion To: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion
c# – System.IO.FileLoadException:无法加载文件或程序集“System.Data.SQLite”
这是我的问题:
我的应用程序使用System.Data.sqlite.DLL.我引用它并在我的电脑中正常运行,但是无法在另一台计算机上运行.这是错误信息:
System.IO.FileLoadException: Could not load file or assembly
‘System.Data.sqlite,Version=1.0.88.0,Culture=neutral,
PublicKeyToken=db937bc2d44ff139’ or one of its dependencies.
The application has Failed to start because its side-by-side
configuration is incorrect. Please see the application event
log or use the command-line sxstrace.exe tool for more detail.
(Exception from HRESULT: 0x800736B1) File name: ‘System.Data.sqlite,
Version=1.0.88.0,PublicKeyToken=db937bc2d44ff139’
—> System.Runtime.InteropServices.COMException (0x800736B1):
The application has Failed to start because its side-by-side
configuration is incorrect. Please see the application event log or
use the command-line sxstrace.exe tool for more detail.
(Exception from HRESULT: 0x800736B1)
at SimPB.config.PrepareDatabase()
at SimPB.config.InitializeProgram()
at SimPB.Program.Main()
我的电脑正在运行Windows 7 32位,Visual Studio 2010.
另一台计算机也运行Windows 7 32位,没有安装Visual Studio.
我试过了
尝试1:确保使用版本x86构建应用程序,并使用目标框架构建应用程序:.NET Framework 2.0.完成.
尝试2:确保应用程序使用System.Data.sqlite(x86 .Net Framework 2.0(sqlite-netFx20-binary-Win32-2005-1.0.88.0))的正确构建引用.完成
尝试3:在App.config尝试这些代码:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v2.0.50727"/> </startup> </configuration>
和这个
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v2.0.50727"/> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> <runtime> <NetFx40_LegacySecurityPolicy enabled="true"/> </runtime> </configuration>
和这个
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v2.0.50727"/> </startup> </configuration>
完成.
尝试4:尝试关闭另一台计算机上的用户帐户控制.完成.
尝试5:尝试在另一台计算机上安装Visual C Runtime(我安装Visual Microsoft Visual C Runtime 2010可再发行组件包(x86),也尝试了2005年的verse.).完成.
尝试6:尝试重新安装.NET Framework 2.0 SP2.接收错误:
You must use “Turn Windows Features On or Off” in the Control Panel to
install or configure Microsoft .NET Framework 2.0 SP2.
更新:(阅读答案和意见后)
尝试7:确保System.Data.sqlite.DLL位于输出bin文件夹.完成
尝试8:双重确认另一台计算机正在运行32位Windows 7.完成
尝试9:更改.csproj文件中的HintPath声明:
改变这个:
<Reference Include="System.Data.sqlite,PublicKeyToken=db937bc2d44ff139,processorArchitecture=x86"> <HintPath>E:\Developer Soft\sqlite\sqlite-netFx20-binary-bundle-Win32-2005-1.0.88.0\System.Data.sqlite.dll</HintPath> </Reference>
为此:
<Reference Include="System.Data.sqlite,processorArchitecture=x86"> <HintPath>..\System.Data.sqlite.dll</HintPath> </Reference>
完成尝试9.
经过上述尝试,结果仍然是一样的.应用程序可以从我的计算机正常运行,并且无法在另一台计算机上运行.
这是一个开源的免费软件,简单的电话簿.我已经提交并将最新的源代码上传到其源控制服务器:http://simpb.codeplex.com/SourceControl/list/changesets(更改集号:fd847ac6c406)
解决方法
短篇故事:
使用旧版本的System.Data.sqlite.新版本怀疑有bug(我可能是错的).
很长的故事:
我开始回想起我以前的旧版本的程序是否能够在其他计算机上执行,这个新版本不能.我做了哪些明显的变化?
是的,我已经更改了System.Data.sqlite的版本.
该程序使用的旧版本的System.Data.sqlite是V1.0.66.我使用的新版本是最新版本:V1.0.88,于2013年8月8日发布.(是的,从今天起约4天前).阅读更多:http://system.data.sqlite.org/index.html/timeline
然后我决定放弃新版本(V1.0.88),并使用旧版本(V1.0.66),一切恢复正常.程序再次可以在另一台计算机上执行.
我试图看看V1.0.88的源代码,但是我找不到导致问题的代码行.我可以发现的最好的是在System.Data.sqlite.Interop的项目.当我在Visual Studio 2010中加载解决方案时,System.Data.sqlite.Interop被预置为构建.NET Framework 4.0.我不知道如何改变它.之后,我重新加载Visual Studio 2008中的解决方案,这是System.Data.sqlite.Interop的常见属性,显示它将为.NET Framework 2.0(这是我正在寻找的)构建,但是我无法构建解决方案.发生一些构建错误.我没有花时间来调试它.
我需要开发.NET Framework 2.0的程序,因为还有使用Windows XP的用户.
我假设V1.0.88包含错误,但我可能是错误的.无论如何,至于目前的解决方案,我只是坚持V1.0.66.
c# – 如何解决此System.IO.FileNotFoundException
>该错误仅发生在 Windows登录后的第一个应用程序运行中.
>当我们单击BtnUseDesktop并因此触发BtnUseDesktop_Click事件(下面)时,会发生错误.
>事件查看器堆栈以The.Application.Name.Main()方法开头…
>但是我们的代码没有那个方法(它是一个WPF应用程序).
事件查看器
Application: The.Application.Name.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException Stack: at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen( System.Object,System.Delegate,System.Object,Int32,System.Delegate) at System.Windows.Threading.dispatcher.LegacyInvokeImpl( System.Windows.Threading.dispatcherPriority,System.TimeSpan,Int32) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr,IntPtr,IntPtr) at MS.Win32.UnsafeNativeMethods.dispatchMessage(System.Windows.Interop.MSG ByRef) at System.Windows.Threading.dispatcher.PushFrameImpl( System.Windows.Threading.dispatcherFrame) at System.Windows.Threading.dispatcher.PushFrame( System.Windows.Threading.dispatcherFrame) at System.Windows.Threading.dispatcher.Run() at System.Windows.Application.Rundispatcher(System.Object) at System.Windows.Application.RunInternal(System.Windows.Window) at System.Windows.Application.Run(System.Windows.Window) at The.Application.Name.Main()
BtnUseDesktop_Click
private void BtnUseDesktop_Click(object sender,RoutedEventArgs e) { AvSwitcher switcher = new AvSwitcher(); this.RunAsyncTask(() => switcher.SwitchToDesktop(this.windowSyncSvc.ActiveLyncWindowHandle)); }
Click事件调用的AvSwitcher
public class AvSwitcher { private DeviceLocationSvc deviceLocationSvc; private UIAutomationSvc uiAutomationSvc; private WindowMovingSvc windowMovingSvc; private ManualResetEvent manualResetEvent; private Modality audioVideo; public static bool IsSwitching { get; set; } public AvSwitcher() { this.deviceLocationSvc = new DeviceLocationSvc(); this.uiAutomationSvc = new UIAutomationSvc(); this.windowMovingSvc = new WindowMovingSvc(); } public void SwitchToDesktop(IntPtr activeLyncConvWindowHandle) { this.BeginHold(DeviceLocation.Desktop,activeLyncConvWindowHandle); } public void SwitchToWall(IntPtr activeLyncConvWindowHandle) { this.BeginHold(DeviceLocation.Wall,activeLyncConvWindowHandle); } private Conversation GetLyncConversation() { Conversation conv = null; if (Lyncclient.GetClient() != null) { conv = Lyncclient.GetClient().ConversationManager.Conversations.FirstOrDefault(); } return conv; } private void BeginHold(DeviceLocation targetLocation,IntPtr activeLyncConvWindowHandle) { AvSwitcher.IsSwitching = true; // make sure the class doesn't dispose of itself this.manualResetEvent = new ManualResetEvent(false); Conversation conv = this.GetLyncConversation(); if (conv != null) { this.audioVideo = conv.Modalities[ModalityTypes.AudioVideo]; ModalityState modalityState = this.audioVideo.State; if (modalityState == ModalityState.Connected) { this.HoldCallAndThenDoTheSwitching(targetLocation,activeLyncConvWindowHandle); } else { this.DoTheSwitching(targetLocation,activeLyncConvWindowHandle); } } } private void HoldCallAndThenDoTheSwitching( DeviceLocation targetLocation,IntPtr activeLyncConvWindowHandle) { try { this.audioVideo.BeginHold( this.BeginHold_callback,new AsyncStateValues() { TargetLocation = targetLocation,ActiveLyncConvWindowHandle = activeLyncConvWindowHandle }); this.manualResetEvent.WaitOne(); } catch (UnauthorizedAccessException) { // the call is already on hold this.DoTheSwitching(targetLocation,activeLyncConvWindowHandle); } } private void BeginHold_callback(IAsyncResult ar) { if (ar.IsCompleted) { DeviceLocation targetLocation = ((AsyncStateValues)ar.AsyncState).TargetLocation; IntPtr activeLyncConvWindowHandle = ((AsyncStateValues)ar.AsyncState).ActiveLyncConvWindowHandle; this.DoTheSwitching(targetLocation,activeLyncConvWindowHandle); } Thread.Sleep(2000); // is this necessary this.audioVideo.BeginRetrieve(this.BeginRetrieve_callback,null); } private void DoTheSwitching(DeviceLocation targetLocation,IntPtr activeLyncConvWindowHandle) { DeviceLocationSvc.TargetDevices targetDevices = this.deviceLocationSvc.GetTargetDevices(targetLocation); this.SwitchScreenUsingWinApi(targetDevices.Screen,activeLyncConvWindowHandle); this.SwitchVideoUsingLyncApi(targetDevices.VideoDevice); this.SwitchAudioUsingUIAutomation( targetDevices.MicName,targetDevices.SpeakersName,activeLyncConvWindowHandle); AvSwitcher.IsSwitching = false; } private void SwitchScreenUsingWinApi(Screen targetScreen,IntPtr activeLyncConvWindowHandle) { if (activeLyncConvWindowHandle != IntPtr.Zero) { WindowPosition wp = this.windowMovingSvc.GetTargetwindowPositionFromScreen(targetScreen); this.windowMovingSvc.MoveTheWindowToTargetPosition(activeLyncConvWindowHandle,wp); } } private void SwitchVideoUsingLyncApi(VideoDevice targetVideoDevice) { if (targetVideoDevice != null) { Lyncclient.GetClient().DeviceManager.ActiveVideoDevice = targetVideoDevice; } } private void SwitchAudioUsingUIAutomation( string targetMicName,string targetSpeakersName,IntPtr activeLyncConvWindowHandle) { if (targetMicName != null && targetSpeakersName != null) { AutomationElement lyncConvWindow = AutomationElement.FromHandle(activeLyncConvWindowHandle); AutomationElement lyncoptionsWindow = this.uiAutomationSvc.OpenTheLyncoptionsWindowFromTheConvWindow(lyncConvWindow); this.uiAutomationSvc.SelectTheTargetMic(lyncoptionsWindow,targetMicName); this.uiAutomationSvc.SelectTheTargetSpeakers(lyncoptionsWindow,targetSpeakersName); this.uiAutomationSvc.InvokeOkayButton(lyncoptionsWindow); } } private void BeginRetrieve_callback(IAsyncResult ar) { this.audioVideo.EndRetrieve(ar); this.manualResetEvent.Set(); // allow the program to exit } private class AsyncStateValues { internal DeviceLocation TargetLocation { get; set; } internal IntPtr ActiveLyncConvWindowHandle { get; set; } } }
解决方法
要查看程序在生产中查找的文件(查看异常的FileName属性),请尝试以下技术:
>写入调试日志,
>使用Visual Studio Attach to Process,或
>使用Visual Studio Remote Debugging
然后查看计算机上的文件系统并查看该文件是否存在.最有可能的情况是它不存在.
关于创建资源路径时从ZipFileSystemProvider获取FileSystemNotFoundException和创建资源文件夹的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于android java.lang.IllegalStateException: System services not available to Activities before onCreate、c# – FileNotFoundException在System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()、c# – System.IO.FileLoadException:无法加载文件或程序集“System.Data.SQLite”、c# – 如何解决此System.IO.FileNotFoundException等相关知识的信息别忘了在本站进行查找喔。
本文标签: