日期:2014-05-17  浏览次数:21041 次

异常来自 HRESULT:0x80131040 System.IO.FileLoadException:
本帖最后由 mpy2003 于 2013-11-24 23:45:42 编辑
************** 异常文本 **************
System.IO.FileLoadException: 未能加载文件或程序集“Windows”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)
文件名:“Windows”
   在 System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   在 System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   在 System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   在 System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   在 System.Reflection.Assembly.Load(String assemblyString)
   在 WindowsApp.MDIBOX.CreateForm(String strName, String namespaceName, Form MdiParentForm)
   在 WindowsApp.MDIBOX.TOOLS_AfterSelect(Object sender, TreeViewEventArgs e)
   在 System.Windows.Forms.TreeView.OnAfterSelect(TreeViewEventArgs e)
   在 System.Windows.Forms.TreeView.TvnSelected(NMTREEVIEW* nmtv)
   在 System.Windows.Forms.TreeView.WmNotify(Message& m)
   在 System.Windows.Forms.TreeView.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
正常情况下不会有这个问题,出现这个问题是因为更改了程序文件名。求解决方案

------解决方案--------------------
看了,代码修改起来不算太难:

public static void CreateForm(string filePath,  string strName, string namespaceName, Form MdiParentForm)
        {
            int Index = strName.LastIndexOf(".");
            string formName = strName.Substring(Index + 1);
            if (!ShowChildForm(formName, MdiParentForm))
            {
            &nbs