FreeTrainの進化系を目指す
VS2013対応
| @@ -22,6 +22,12 @@ | ||
| 22 | 22 | |
| 23 | 23 | private PluginSerializationBinder(){ |
| 24 | 24 | AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(OnAssemblyResolve); |
| 25 | + Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies(); | |
| 26 | + foreach (Assembly a in asms) | |
| 27 | + { | |
| 28 | + if (a.GlobalAssemblyCache) continue; | |
| 29 | + asmcache.Add(a.CodeBase, a); | |
| 30 | + } | |
| 25 | 31 | } |
| 26 | 32 | |
| 27 | 33 | #region resolve assembly on deserialize |
| @@ -53,17 +59,24 @@ | ||
| 53 | 59 | public static Assembly SafeLoadAssembly(IFileSource f) { |
| 54 | 60 | Assembly a = null; |
| 55 | 61 | LocalFile lfile = f as LocalFile; |
| 56 | - if (lfile != null) { | |
| 57 | - // load assumig from local strage. | |
| 58 | - a = Assembly.LoadFrom(lfile.AbsolutePath); | |
| 59 | - } else if (!asmcache.TryGetValue(f.Uri, out a)) { | |
| 60 | - // load from byte stream. | |
| 61 | - using (Stream stream = f.OpenRead()) { | |
| 62 | - byte[] dllimage = new byte[stream.Length]; | |
| 63 | - stream.Read(dllimage, 0, dllimage.Length); | |
| 64 | - stream.Close(); | |
| 65 | - a = Assembly.Load(dllimage); | |
| 62 | + if (!asmcache.TryGetValue(f.Uri, out a)) | |
| 63 | + { | |
| 64 | + if (lfile != null) | |
| 65 | + { | |
| 66 | + // load assumig from local strage. | |
| 67 | + a = Assembly.LoadFrom(lfile.AbsolutePath); | |
| 66 | 68 | } |
| 69 | + else | |
| 70 | + { | |
| 71 | + // load from byte stream. | |
| 72 | + using (Stream stream = f.OpenRead()) | |
| 73 | + { | |
| 74 | + byte[] dllimage = new byte[stream.Length]; | |
| 75 | + stream.Read(dllimage, 0, dllimage.Length); | |
| 76 | + stream.Close(); | |
| 77 | + a = Assembly.Load(dllimage); | |
| 78 | + } | |
| 79 | + } | |
| 67 | 80 | asmcache.Add(f.Uri, a); |
| 68 | 81 | } |
| 69 | 82 | return a; |
| @@ -33,7 +33,7 @@ | ||
| 33 | 33 | static public void RegisterAssembly( Assembly asm ) |
| 34 | 34 | { |
| 35 | 35 | list.Add(asm); |
| 36 | - BuildSysInfoText(); | |
| 36 | + //BuildSysInfoText(); | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | #region build system information text |
| @@ -48,7 +48,9 @@ | ||
| 48 | 48 | infoText.Append("Assembly", asm.FullName); |
| 49 | 49 | infoText.Append("CLR Version", RuntimeEnvironment.GetSystemVersion()); |
| 50 | 50 | Assembly mscore = Assembly.GetAssembly(typeof(string)); |
| 51 | - infoText.AppendInline(mscore.GetName().Name + " win32 version", Win32Version.GetAssemblyFileVersion(mscore)); | |
| 51 | + FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(mscore.Location); | |
| 52 | + infoText.AppendInline(mscore.GetName().Name + " win32 version", fvi.FileVersion); | |
| 53 | + //infoText.AppendInline(mscore.GetName().Name + " win32 version", Win32Version.GetAssemblyFileVersion(mscore)); | |
| 52 | 54 | // using( Form f = new Form()) |
| 53 | 55 | // { |
| 54 | 56 | // Assembly forms = Assembly.GetAssembly(f.GetType()); |
| @@ -31,6 +31,7 @@ | ||
| 31 | 31 | { |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | + [Obsolete("Application will shut down when build on VS2013")] | |
| 34 | 35 | unsafe static public string GetAssemblyFileVersion(Assembly target) |
| 35 | 36 | { |
| 36 | 37 | string fname = (new Uri(target.CodeBase)).LocalPath; |