System.IO.FileNotFoundException Captured

Topics: Prism v2 - WPF 4
Oct 28, 2010 at 1:28 AM

Hi all,

I built an WPF4 app with Prism 2. My development environment is Win7 64bit with VS2010. I tried everything works on my development machine.

Now I copied all EXE, DLL and required files to a Windows XP SP3 32bit machine. Before that I installed .Net Framework 4. When I run the application on WinXP I got exception messages from event viewer:

Excepton: System.IO.FileNotFoundException
Stack:
   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.<>c__DisplayClass2b.<GetNotAllreadyLoadedModuleInfos>b__27(FileInfo file)
   at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.GetModuleInfos(String path)
   at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog+InnerModuleInfoLoader.GetModuleInfos(System.String)
   at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog.InnerLoad()
   at Microsoft.Practices.Composite.Modularity.ModuleCatalog.Initialize()
   at Microsoft.Practices.Composite.Modularity.ModuleManager.Run()
   at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.InitializeModules()
   at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run(Boolean)
   at HardySoft.App..ctor()
   at HardySoft.App.Main()

What does it mean? Do I miss anything from my WinXP?

Thanks

Hardy

Oct 28, 2010 at 7:08 PM

Hi Hardy,

There is no similar issues reported so far. If you continue experiencing this in your scenario, and also consider this an issue in Prism, you could copy this as a work-item. This way the product team will be notified as well as other users can vote this.

In the meantime, could you please share the complete exception message?. It might help to determine a possible reason. Have you checked the length of the modules' directory is not longer than 256 characters?

Fernando Antivero

http://blogs.southworks.net/fantivero

 

 

Oct 29, 2010 at 11:53 PM
Edited Oct 29, 2010 at 11:54 PM

I think I found the reason, I have a Windows XP with .Net Framework 4.0 installed only (no 3.5 and/or SP1), when the application runs Prism framework "Could not load file or assembly 'WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies." even though I have WindowsBase 4.0 referenced.

I checked download binary of Prism 2, and I think I did not find a setup for 4.0 only.

So do I have to install 3.5 or you can compile with 4.0?

Hardy

Oct 30, 2010 at 12:26 AM

More update, Installed VS2010 on WinXP with .Net 4.0 only, and pulled following more detailed exception message. I even tried to open Prism 2.2 source code in VS2010, switched to Framework 4.0 and removed all reference to 3.5 GAC assemblies, referenced to all 4.0 GAC assemblies. I recompiled codes, used new Prism DLLs in project, there is still no hope. Is there somewhere in Prism source code hard-coded to look for 3.5 version of WindowBase via reflection?

=======================================

System.IO.FileNotFoundException was unhandled
  Message=Could not load file or assembly 'WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
  Source=mscorlib
  FileName=WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  FusionLog=""
  StackTrace:
       at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
       at System.Reflection.RuntimeAssembly.GetExportedTypes()
       at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.<>c__DisplayClass2b.<GetNotAllreadyLoadedModuleInfos>b__27(FileInfo file)
       at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.GetModuleInfos(String path)
       at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.GetModuleInfos(String path)
       at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog.InnerLoad()
       at Microsoft.Practices.Composite.Modularity.ModuleCatalog.Load()
       at Microsoft.Practices.Composite.Modularity.ModuleCatalog.Initialize()
       at Microsoft.Practices.Composite.Modularity.ModuleManager.Run()
       at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.InitializeModules()
       at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run(Boolean runWithDefaultConfiguration)
       at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run()
       at HardySoft.Clinic.App..ctor() in C:\Projects\HardySoft\HardySoft.Shell\App.xaml.cs:line 15
       at HardySoft.Clinic.App.Main() in C:\Projects\HardySoft\HardySoft.Shell\obj\x86\Debug\App.g.cs:line 49
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.IO.FileNotFoundException
       Message=Could not load file or assembly 'WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
       Source=mscorlib
       FileName=WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
       FusionLog==== Pre-bind state information ===
LOG: User = HARDY-0D941D7AC\Administrator
LOG: DisplayName = WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/Projects/HardySoft/HardySoft.Shell/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This is an inspection only bind.
LOG: Using application configuration file: C:\Projects\HardySoft\HardySoft.Shell\bin\Debug\Test.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: Attempting download of new URL file:///C:/Projects/HardySoft/HardySoft.Shell/bin/Debug/WindowsBase.DLL.
LOG: Attempting download of new URL file:///C:/Projects/HardySoft/HardySoft.Shell/bin/Debug/WindowsBase/WindowsBase.DLL.
LOG: Attempting download of new URL file:///C:/Projects/HardySoft/HardySoft.Shell/bin/Debug/WindowsBase.EXE.
LOG: Attempting download of new URL file:///C:/Projects/HardySoft/HardySoft.Shell/bin/Debug/WindowsBase/WindowsBase.EXE.

       StackTrace:
            at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
            at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
            at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
            at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
            at System.Reflection.Assembly.ReflectionOnlyLoad(String assemblyString)
            at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.OnReflectionOnlyResolve(ResolveEventArgs args, DirectoryInfo directory)
            at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.<>c__DisplayClass23.<GetModuleInfos>b__20(Object sender, ResolveEventArgs args)
            at System.AppDomain.OnReflectionOnlyAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
       InnerException:

Oct 30, 2010 at 1:09 AM
Edited Oct 30, 2010 at 1:13 AM

I think I finally found the reason, because in my project I have DocumentFormat.OpenXml.dll referenced, and it references to WindowsBase 3.0.

In \CAL\Desktop\Composite\Modularity\DirectoryModuleCatalog.Desktop.cs GetNotAllreadyLoadedModuleInfos method found the reference and try to load this assembly thus failed.