|
-
May 27th, 2014, 05:24 PM
#1
Thread Starter
Hyperactive Member
Cannot find file, even though I already found it.
I am getting an error stating the program cannot find the file, even though the file was found using a loop to grab all files in the directory.
Code:
vb.net Code:
For Each file In IO.Directory.GetFiles(Application.StartupPath & "\Editors")
pbar.Value += 1
pbar.Text = "Checking: " & New IO.FileInfo(file).Name
' Only search files that end in .dll
If file.EndsWith(".dll") Then
Try
' Load the assembly.
asm = Reflection.Assembly.Load(IO.Path.GetFileNameWithoutExtension(file))
Catch ex As Exception
Continue For
End Try
...
Exception:
vb.net Code:
- ex {"Could not load file or assembly 'testModule' or one of its dependencies. The system cannot find the file specified.":"testModule"} System.Exception
- System.IO.FileNotFoundException {"Could not load file or assembly 'testModule' or one of its dependencies. The system cannot find the file specified.":"testModule"} System.IO.FileNotFoundException
_className "System.IO.FileNotFoundException" String
_COMPlusExceptionCode -532462766 Integer
_data Nothing System.Collections.IDictionary
_dynamicMethods Nothing Object
_exceptionMethod Nothing System.Reflection.MethodBase
_exceptionMethodString Nothing String
_fileName "testModule" String
_fusionLog "=== Pre-bind state information === LOG: DisplayName = testModule (Partial) WRN: Partial binding information was supplied for an assembly: WRN: Assembly Name: testModule | Domain ID: 1 WRN: A partial bind occurs when only part of the assembly display name is provided. WRN: This might result in the binder loading an incorrect assembly. WRN: It is recommended to provide a fully specified textual identity for the assembly, WRN: that consists of the simple name, version, culture, and public key token. WRN: See whitepaper [url]http://go.microsoft.com/fwlink/?LinkId=109270[/url] for more information and common solutions to this issue. LOG: Appbase = file:///C:/Users/Troy Lundin/Documents/Visual Studio 2012/Projects/_Emulation/NDS/__Output/ LOG: Initial PrivatePath = NULL Calling assembly : NDSMain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\Troy Lundin\Documents\Visual Studio 2012\Projects\_Emulation\NDS\__Output\NDSMain.vshost.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///C:/Users/Troy Lundin/Documents/Visual Studio 2012/Projects/_Emulation/NDS/__Output/testModule.DLL. LOG: Attempting download of new URL file:///C:/Users/Troy Lundin/Documents/Visual Studio 2012/Projects/_Emulation/NDS/__Output/testModule/testModule.DLL. LOG: Attempting download of new URL file:///C:/Users/Troy Lundin/Documents/Visual Studio 2012/Projects/_Emulation/NDS/__Output/testModule.EXE. LOG: Attempting download of new URL file:///C:/Users/Troy Lundin/Documents/Visual Studio 2012/Projects/_Emulation/NDS/__Output/testModule/testModule.EXE. " String
_helpURL Nothing String
_HResult -2147024894 Integer
_innerException Nothing System.Exception
_ipForWatsonBuckets 1820636370 System.UIntPtr
_maybeFullPath Nothing String
_message "Could not load file or assembly 'testModule' or one of its dependencies. The system cannot find the file specified." String
_remoteStackIndex 0 Integer
_remoteStackTraceString Nothing String
+ _safeSerializationManager {System.Runtime.Serialization.SafeSerializationManager} System.Runtime.Serialization.SafeSerializationManager
_source Nothing String
+ _stackTrace {SByte()} Object
_stackTraceString Nothing String
_watsonBuckets Nothing Object
_xcode -532462766 Integer
_xptrs 0 System.IntPtr
+ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary
FileName "testModule" String
FusionLog "=== Pre-bind state information === LOG: DisplayName = testModule (Partial) WRN: Partial binding information was supplied for an assembly: WRN: Assembly Name: testModule | Domain ID: 1 WRN: A partial bind occurs when only part of the assembly display name is provided. WRN: This might result in the binder loading an incorrect assembly. WRN: It is recommended to provide a fully specified textual identity for the assembly, WRN: that consists of the simple name, version, culture, and public key token. WRN: See whitepaper [url]http://go.microsoft.com/fwlink/?LinkId=109270[/url] for more information and common solutions to this issue. LOG: Appbase = file:///C:/Users/Troy Lundin/Documents/Visual Studio 2012/Projects/_Emulation/NDS/__Output/ LOG: Initial PrivatePath = NULL Calling assembly : NDSMain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\Troy Lundin\Documents\Visual Studio 2012\Projects\_Emulation\NDS\__Output\NDSMain.vshost.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///C:/Users/Troy Lundin/Documents/Visual Studio 2012/Projects/_Emulation/NDS/__Output/testModule.DLL. LOG: Attempting download of new URL file:///C:/Users/Troy Lundin/Documents/Visual Studio 2012/Projects/_Emulation/NDS/__Output/testModule/testModule.DLL. LOG: Attempting download of new URL file:///C:/Users/Troy Lundin/Documents/Visual Studio 2012/Projects/_Emulation/NDS/__Output/testModule.EXE. LOG: Attempting download of new URL file:///C:/Users/Troy Lundin/Documents/Visual Studio 2012/Projects/_Emulation/NDS/__Output/testModule/testModule.EXE. " String
HelpLink Nothing String
HResult -2147024894 Integer
InnerException Nothing System.Exception
IPForWatsonBuckets 1820636370 System.UIntPtr
IsTransient False Boolean
Message "Could not load file or assembly 'testModule' or one of its dependencies. The system cannot find the file specified." String
RemoteStackTrace Nothing String
s_EDILock {Object} Object
Source "mscorlib" String
StackTrace " at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at NDS.Main.LoadModule() in C:\Users\Troy Lundin\Documents\Visual Studio 2012\Projects\_Emulation\NDS\_NDS\Main.vb:line 182" String
+ TargetSite {System.Reflection.RuntimeAssembly _nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)} System.Reflection.MethodBase
WatsonBuckets Nothing Object
The exception informs me it cannot load the assembly 'testModule' because it cannot find the file ":"testModule".
What's with the three quotes and the colon? Why would I get this error even though the assembly was grabbed in the loop?
Prefix has no suffix, but suffix has a prefix.
-
May 27th, 2014, 05:32 PM
#2
Re: Cannot find file, even though I already found it.
-
May 27th, 2014, 06:00 PM
#3
Re: Cannot find file, even though I already found it.
I suggest that you read the documentation for that Assembly.Load method that you're calling. The String you pass should contain the long-form assembly name, NOT a file path.
http://msdn.microsoft.com/en-us/libr...vs.110%29.aspx
-
May 27th, 2014, 06:11 PM
#4
Re: Cannot find file, even though I already found it.
John did not mention
If file.EndsWith(".dll") Then
-
May 27th, 2014, 06:18 PM
#5
Thread Starter
Hyperactive Member
Re: Cannot find file, even though I already found it.
I understand what you are saying. I am just a bit confused. I have used the same code for over two years now and haven't once gotten an error. In fact, I am able to load two assemblies from the same directory (Editors) prior to the assembly that causes the exception.
After some fiddling, I was able to load it using the same process, Reflection.Assembly.Load(IO.Path.GetFileNameWithoutExtension(file)), but I changed the directory from 'Application.StartupPath & "\Editors"' to just 'Application.StartupPath'. This made it work, but I am still wondering why it would load two other assemblies from the 'Editors' directory, but not 'testModule'.
Prefix has no suffix, but suffix has a prefix.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|