提示该错误:未能加载文件或程序集“Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”或它的某一个依赖项。系统找不到指定的文件。分别2台电脑,
在A机上Using Microsoft.Office.Interop.Excel就提示上面这个,用Using Excel;就可以运行
在B机上Microsoft.Office.Interop.Excel就没有任何问题,请高手赐教,谢谢^

解决方案 »

  1.   

    After read some articles i found that the follow file is required when we want to use the Office applications with our application.Office 2003 Update: Redistributable Primary Interop Assemblies (http://www.microsoft.com/downloads/...&displaylang=en)I just installed the:
    Office 2003 Primary Interop Assemblies Redistributableand all the exceptions dissapear!
      

  2.   

    谢谢一休,你说的方法我都试过了,该装的我都装了,重启了也启了,但还是一直都在提示那个错误!
    我把bin文件夹里的东西,还是有webconfig里的东西我都删除过,重新引用了,但还是提示那个错误,真是搞不懂了
      

  3.   

    添加一个到office的引用就行了:
    项目--->添加引用--->com 标签下的microsoft office ?.? ...  
      

  4.   

    对Office的操作可以采用后期绑定的方法来消除因为版本不一致或无法引用的问题,可以参考下面的代码:
    private void btnLater_Click(object sender, EventArgs e)
    {
    object objApp;
    object objBook;
    object objBooks;
    object objSheets;
    object objSheet;
    object objRange;
    object[] Parameters; try
    {
    // Get the class type and instantiate Excel.
    Type objClassType;
    objClassType = Type.GetTypeFromProgID("Excel.Application");
    objApp = Activator.CreateInstance(objClassType); //Get the workbooks collection.
    objBooks = objApp.GetType().InvokeMember("Workbooks",
    BindingFlags.GetProperty, null, objApp, null); //Add a new workbook.
    objBook = objBooks.GetType().InvokeMember("Add",
    BindingFlags.InvokeMethod, null, objBooks, null); //Get the worksheets collection.
    objSheets = objBook.GetType().InvokeMember("Worksheets",
    BindingFlags.GetProperty, null, objBook, null); //Get the first worksheet.
    Parameters = new Object[1];
    Parameters[0] = 1;
    objSheet = objSheets.GetType().InvokeMember("Item",
    BindingFlags.GetProperty, null, objSheets, Parameters); //Get a range object that contains cell A1.
    Parameters = new Object[2];
    Parameters[0] = "A1";
    Parameters[1] = "D3";
    objRange = objSheet.GetType().InvokeMember("Range",
    BindingFlags.GetProperty, null, objSheet, Parameters); //Write "Hello, World!" in cell A1.
    Parameters = new Object[1];
    Parameters[0] = "Hello, World!";
    objRange.GetType().InvokeMember("Value", BindingFlags.SetProperty,
    null, objRange, Parameters); //Return control of Excel to the user.
    Parameters = new Object[1];
    Parameters[0] = true;
    objApp.GetType().InvokeMember("Visible", BindingFlags.SetProperty,
    null, objApp, Parameters);
    objApp.GetType().InvokeMember("UserControl", BindingFlags.SetProperty,
    null, objApp, Parameters);
    }
    catch (Exception theException)
    {
    String errorMessage;
    errorMessage = "Error: ";
    errorMessage = String.Concat(errorMessage, theException.Message);
    errorMessage = String.Concat(errorMessage, " Line: ");
    errorMessage = String.Concat(errorMessage, theException.Source); MessageBox.Show(errorMessage, "Error");
    }
    }
      

  5.   

    我也遇到过,要装那种内部支持.net的 office,在装的 时候选自定义,然后选 .net内部支持就 行了,就看你 的 office有 没有 了,