<add assembly="Microsoft.Office.Tools.Word, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F

Server Error in '/' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: Could not load file or assembly 'Microsoft.Office.Tools.Word, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. 系统找不到指定的文件。

Source Error: 

Line 55: 				<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Line 56: 				<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
Line 57: 				<add assembly="Microsoft.Office.Tools.Word, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
Line 58: 				<add assembly="Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
Line 59: 				<add assembly="Microsoft.Vbe.Interop, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>

Source File: E:\T1Web\web.config     Line: 57 

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.Office.Tools.Word, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be loaded.

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.504


2015-1-16 10:48:51

PS:暂时找不解放方案.


但是如果我删除报错的那行结果会怎么样?(webconfig里面把这行,删掉看看,可能就可以正确运行了,如果删掉还是报错的话,就是你缺少dll或者其他)

反馈给我的还是错误


Server Error in '/' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: Could not load file or assembly 'Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. 系统找不到指定的文件。

Source Error: 

Line 54: 				<add assembly="DevExpress.Web.ASPxThemes.v13.2, Version=13.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"/>
Line 55: 				<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Line 56: 				<add assembly="Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
Line 57: 				<add assembly="Microsoft.Vbe.Interop, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
Line 58: 				<add assembly="office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/></assemblies>

Source File: E:\T1Web\web.config     Line: 56 

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' could not be loaded.

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.504


好吧,贯彻我的思路接着删除报错的那行配置文件.然后我的后台代码就报错了.

现在够详细了,知道那行代码调用出错了.


Server Error in '/' Application.
--------------------------------------------------------------------------------


Compilation Error 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 


Compiler Error Message: CS0234: The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)


Source Error:


 


Line 4:  public class CCWordApp
Line 5:  {
Line 6:      private Microsoft.Office.Interop.Word.ApplicationClass oWordApplic;// a reference to Word application 引用Word应用程序
Line 7:      private Microsoft.Office.Interop.Word.Document oDoc;// a reference to the document 引用文档
Line 8:  
 


Source File: e:\T1Web\App_Code\CCWordApp.cs    Line: 6 






Show Detailed Compiler Output:




C:\WINDOWS\SysWOW64\inetsrv> "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\ba6a7995\4bbe8a36_dcf4cf01\DevExpress.Web.ASPxHtmlEditor.v13.2.DLL" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\8dc27d62\6bee8f36_dcf4cf01\DevExpress.Utils.v13.2.UI.resources.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\a8ab943b\ebb58e36_dcf4cf01\DevExpress.Printing.v13.2.Core.DLL" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\3032107a\eb448c36_dcf4cf01\DevExpress.XtraReports.v13.2.Extensions.resources.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\86b20fcd\cba38436_dcf4cf01\DevExpress.Web.ASPxThemes.v13.2.DLL" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Deployment\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Deployment.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\219f6ba1\fb188536_dcf4cf01\DevExpress.XtraGrid.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\c96c3223\6b9b8836_dcf4cf01\DevExpress.Web.v13.2.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\67591196\bbcf8b36_dcf4cf01\DevExpress.XtraPrinting.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\4ed06aaf\9b818b36_dcf4cf01\DevExpress.XtraCharts.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\3fc622ee\8b788636_dcf4cf01\DevExpress.Utils.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\ac46d821\db1d8c36_dcf4cf01\DevExpress.XtraTreeList.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\b2f48bec\2bca7b36_dcf4cf01\DevExpress.Web.ASPxHtmlEditor.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\4718ffb4\5b038636_dcf4cf01\DevExpress.DataAccess.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\a766ce63\dbac8936_dcf4cf01\DevExpress.Data.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\945ced59\7ba48d36_dcf4cf01\DevExpress.Data.v13.2.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.Common\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.Common.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\c72258e3\6b0c8b36_dcf4cf01\DevExpress.Printing.v13.2.Core.resources.DLL" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\4b6a04fe\8be98836_dcf4cf01\DevExpress.DataAccess.v13.2.UI.resources.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.ProcessingObjectModel\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.ProcessingObjectModel.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\8c30e287\72726957_ca2bd001\App_Licenses.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\76f1f0e7\ebd38936_dcf4cf01\DevExpress.XtraReports.v13.2.Web.resources.DLL" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\5d19a33c\7b159036_dcf4cf01\DevExpress.Web.ASPxSpellChecker.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\c1aeec2f\bb5e8936_dcf4cf01\DevExpress.XtraNavBar.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\90d8b77e\4bdc8536_dcf4cf01\Microsoft.Vbe.Interop.DLL" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\bf2ca8fc\0b408536_dcf4cf01\DevExpress.Web.ASPxScheduler.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\8f49a32c\8bcb8d36_dcf4cf01\DevExpress.Web.ASPxTreeList.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\0b5faf33\fb6b8c36_dcf4cf01\DevExpress.XtraReports.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\f8bec368\8b3c9036_dcf4cf01\DevExpress.Web.v13.2.resources.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\312172aa\0b7c7b36_dcf4cf01\DevExpress.XtraCharts.v13.2.Wizard.resources.DLL" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\307b3a48\9b108936_dcf4cf01\DevExpress.XtraEditors.v13.2.resources.DLL" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\assembly\dl3\b4ad0387\2b8e8536_dcf4cf01\DevExpress.XtraBars.v13.2.resources.DLL" /out:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\App_Code.fs1kyxl-.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699;1701 /warnaserror-  "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\App_Code.fs1kyxl-.0.cs" "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\App_Code.fs1kyxl-.1.cs" "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\App_Code.fs1kyxl-.2.cs" "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\App_Code.fs1kyxl-.3.cs" "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\App_Code.fs1kyxl-.4.cs" "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\App_Code.fs1kyxl-.5.cs" "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\App_Code.fs1kyxl-.6.cs" "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fdb97f61\f8333f36\App_Code.fs1kyxl-.7.cs"




Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.


e:\T1Web\App_Code\CCWordApp.cs(6,23): error CS0234: The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
e:\T1Web\App_Code\CCWordApp.cs(7,23): error CS0234: The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)


 






Show Complete Compilation Source:




Line 1:    using System;
Line 2:    using System.ComponentModel;
Line 3:    
Line 4:    public class CCWordApp
Line 5:    {
Line 6:        private Microsoft.Office.Interop.Word.ApplicationClass oWordApplic;// a reference to Word application 引用Word应用程序
Line 7:        private Microsoft.Office.Interop.Word.Document oDoc;// a reference to the document 引用文档
Line 8:    
Line 9:    
Line 10:       public CCWordApp()
Line 11:       {
Line 12:           // activate the interface with the COM object of Microsoft Word
Line 13:           //激活与Microsoft Word的COM对象的接口
Line 14:           oWordApplic = new Microsoft.Office.Interop.Word.ApplicationClass();
Line 15:       }
Line 16:   
Line 17:       /// <summary>
Line 18:       /// 插入图片
Line 19:       /// </summary>
Line 20:       /// <param name="picPath"></param>
Line 21:       public void InsertPicture(string picPath)
Line 22:       {
Line 23:           object missing = System.Reflection.Missing.Value;
Line 24:           oWordApplic.Selection.InlineShapes.AddPicture(picPath, ref missing, ref missing, ref missing);
Line 25:       }
Line 26:   
Line 27:       // Open a file (the file must exists) and activate it  打开一个文件(该文件必须存在),并激活它
Line 28:       public void Open(string strFileName)
Line 29:       {
Line 30:           object fileName = strFileName;
Line 31:           object readOnly = false;
Line 32:           object isVisible = true;
Line 33:           object missing = System.Reflection.Missing.Value;
Line 34:   
Line 35:           oDoc = oWordApplic.Documents.Open(ref fileName, ref missing, ref readOnly,
Line 36:               ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
Line 37:               ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing);
Line 38:   
Line 39:           oDoc.Activate();
Line 40:       }
Line 41:   
Line 42:   
Line 43:       // Open a new document打开一个新文档
Line 44:       public void Open()
Line 45:       {
Line 46:           object missing = System.Reflection.Missing.Value;
Line 47:           oDoc = oWordApplic.Documents.Add(ref missing, ref missing, ref missing, ref missing);
Line 48:   
Line 49:           oDoc.Activate();
Line 50:       }
Line 51:   
Line 52:   
Line 53:   
Line 54:   
Line 55:       public void Quit()
Line 56:       {
Line 57:           object missing = System.Reflection.Missing.Value;
Line 58:           oWordApplic.Application.Quit(ref missing, ref missing, ref missing);
Line 59:       }
Line 60:   
Line 61:       public void Save()
Line 62:       {
Line 63:           oDoc.Save();
Line 64:       }
Line 65:   
Line 66:       public void SaveAs(string strFileName)
Line 67:       {
Line 68:           object missing = System.Reflection.Missing.Value;
Line 69:           object fileName = strFileName;
Line 70:   
Line 71:           oDoc.SaveAs(ref fileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
Line 72:               ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
Line 73:       }
Line 74:   
Line 75:       // Save the document in HTML format 以HTML格式保存文档
Line 76:       public void SaveAsHtml(string strFileName)
Line 77:       {
Line 78:           object missing = System.Reflection.Missing.Value;
Line 79:           object fileName = strFileName;
Line 80:           object Format = (int)Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML;
Line 81:           oDoc.SaveAs(ref fileName, ref Format, ref missing, ref missing, ref missing, ref missing, ref missing,
Line 82:               ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
Line 83:       }
Line 84:   
Line 85:   
Line 86:   
Line 87:       public void InsertText(string strText)
Line 88:       {
Line 89:           oWordApplic.Selection.TypeText(strText);
Line 90:       }
Line 91:   
Line 92:       public void InsertLineBreak()
Line 93:       {
Line 94:           oWordApplic.Selection.TypeParagraph();
Line 95:       }
Line 96:       public void InsertLineBreak(int nline)
Line 97:       {
Line 98:           for (int i = 0; i < nline; i++)
Line 99:               oWordApplic.Selection.TypeParagraph();
Line 100:      }
Line 101:  
Line 102:  
Line 103:      // Change the paragraph alignement 更改段落对齐键相
Line 104:      public void SetAlignment(string strType)
Line 105:      {
Line 106:          switch (strType)
Line 107:          {
Line 108:              case "Center":
Line 109:                  oWordApplic.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
Line 110:                  break;
Line 111:              case "Left":
Line 112:                  oWordApplic.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
Line 113:                  break;
Line 114:              case "Right":
Line 115:                  oWordApplic.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
Line 116:                  break;
Line 117:              case "Justify":
Line 118:                  oWordApplic.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphJustify;
Line 119:                  break;
Line 120:          }
Line 121:  
Line 122:      }
Line 123:  
Line 124:  
Line 125:      // if you use thif function to change the font you should call it again with 如果您使用此功能来改变字体,你应该再次调用它 
Line 126:      // no parameter in order to set the font without a particular format 为了不带参数设置字体没有特定的格式
Line 127:      public void SetFont(string strType)
Line 128:      {
Line 129:          switch (strType)
Line 130:          {
Line 131:              case "Bold":
Line 132:                  oWordApplic.Selection.Font.Bold = 1;
Line 133:                  break;
Line 134:              case "Italic":
Line 135:                  oWordApplic.Selection.Font.Italic = 1;
Line 136:                  break;
Line 137:              case "Underlined":
Line 138:                  oWordApplic.Selection.Font.Subscript = 0;
Line 139:                  break;
Line 140:          }
Line 141:  
Line 142:      }
Line 143:  
Line 144:      // disable all the style  禁用所有的风格
Line 145:      public void SetFont()
Line 146:      {
Line 147:          oWordApplic.Selection.Font.Bold = 0;
Line 148:          oWordApplic.Selection.Font.Italic = 0;
Line 149:          oWordApplic.Selection.Font.Subscript = 0;
Line 150:  
Line 151:      }
Line 152:  
Line 153:      public void SetFontName(string strType)
Line 154:      {
Line 155:          oWordApplic.Selection.Font.Name = strType;
Line 156:  
Line 157:      }
Line 158:  
Line 159:      public void SetFontSize(int nSize)
Line 160:      {
Line 161:          oWordApplic.Selection.Font.Size = nSize;
Line 162:  
Line 163:      }
Line 164:  
Line 165:      public void InsertPagebreak()
Line 166:      {
Line 167:          // VB : Selection.InsertBreak Type:=wdPageBreak
Line 168:          object pBreak = (int)Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
Line 169:          oWordApplic.Selection.InsertBreak(ref pBreak);
Line 170:      }
Line 171:  
Line 172:      // Go to a predefined bookmark, if the bookmark doesn't exists the application will raise an error 
Line 173:      //去到一个预先定义的书签,如果书签不存在应用程序将引发错误
Line 174:      public void GotoBookMark(string strBookMarkName)
Line 175:      {
Line 176:          // VB :  Selection.GoTo What:=wdGoToBookmark, Name:="nome"
Line 177:          object missing = System.Reflection.Missing.Value;
Line 178:  
Line 179:          object Bookmark = (int)Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark;
Line 180:          object NameBookMark = strBookMarkName;
Line 181:          oWordApplic.Selection.GoTo(ref Bookmark, ref missing, ref missing, ref NameBookMark);
Line 182:      }
Line 183:  
Line 184:      public void GoToTheEnd()
Line 185:      {
Line 186:          // VB :  Selection.EndKey Unit:=wdStory
Line 187:          object missing = System.Reflection.Missing.Value;
Line 188:          object unit;
Line 189:          unit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
Line 190:          oWordApplic.Selection.EndKey(ref unit, ref missing);
Line 191:  
Line 192:      }
Line 193:      public void GoToTheBeginning()
Line 194:      {
Line 195:          // VB : Selection.HomeKey Unit:=wdStory
Line 196:          object missing = System.Reflection.Missing.Value;
Line 197:          object unit;
Line 198:          unit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
Line 199:          oWordApplic.Selection.HomeKey(ref unit, ref missing);
Line 200:  
Line 201:      }
Line 202:  
Line 203:      public void GoToTheTable(int ntable)
Line 204:      {
Line 205:          // Selection.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=1, Name:=""
Line 206:          //    Selection.Find.ClearFormatting
Line 207:          //    With Selection.Find
Line 208:          //        .Text = ""
Line 209:          //        .Replacement.Text = ""
Line 210:          //        .Forward = True
Line 211:          //        .Wrap = wdFindContinue
Line 212:          //        .Format = False
Line 213:          //        .MatchCase = False
Line 214:          //        .MatchWholeWord = False
Line 215:          //        .MatchWildcards = False
Line 216:          //        .MatchSoundsLike = False
Line 217:          //        .MatchAllWordForms = False
Line 218:          //    End With
Line 219:  
Line 220:          object missing = System.Reflection.Missing.Value;
Line 221:          object what;
Line 222:          what = Microsoft.Office.Interop.Word.WdUnits.wdTable;
Line 223:          object which;
Line 224:          which = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToFirst;
Line 225:          object count;
Line 226:          count = 1;
Line 227:          oWordApplic.Selection.GoTo(ref what, ref which, ref count, ref missing);
Line 228:          oWordApplic.Selection.Find.ClearFormatting();
Line 229:  
Line 230:          oWordApplic.Selection.Text = "";
Line 231:  
Line 232:  
Line 233:      }
Line 234:  
Line 235:      public void GoToRightCell()
Line 236:      {
Line 237:          // Selection.MoveRight Unit:=wdCell
Line 238:  
Line 239:          object missing = System.Reflection.Missing.Value;
Line 240:          object direction;
Line 241:          direction = Microsoft.Office.Interop.Word.WdUnits.wdCell;
Line 242:          oWordApplic.Selection.MoveRight(ref direction, ref missing, ref missing);
Line 243:      }
Line 244:  
Line 245:      public void GoToLeftCell()
Line 246:      {
Line 247:          // Selection.MoveRight Unit:=wdCell
Line 248:  
Line 249:          object missing = System.Reflection.Missing.Value;
Line 250:          object direction;
Line 251:          direction = Microsoft.Office.Interop.Word.WdUnits.wdCell;
Line 252:          oWordApplic.Selection.MoveLeft(ref direction, ref missing, ref missing);
Line 253:      }
Line 254:  
Line 255:      public void GoToDownCell()
Line 256:      {
Line 257:          // Selection.MoveRight Unit:=wdCell
Line 258:  
Line 259:          object missing = System.Reflection.Missing.Value;
Line 260:          object direction;
Line 261:          direction = Microsoft.Office.Interop.Word.WdUnits.wdLine;
Line 262:          oWordApplic.Selection.MoveDown(ref direction, ref missing, ref missing);
Line 263:      }
Line 264:  
Line 265:      public void GoToUpCell()
Line 266:      {
Line 267:          // Selection.MoveRight Unit:=wdCell
Line 268:  
Line 269:          object missing = System.Reflection.Missing.Value;
Line 270:          object direction;
Line 271:          direction = Microsoft.Office.Interop.Word.WdUnits.wdLine;
Line 272:          oWordApplic.Selection.MoveUp(ref direction, ref missing, ref missing);
Line 273:      }
Line 274:  
Line 275:  
Line 276:      // this function doesn't work 这个功能不起作用
Line 277:      public void InsertPageNumber(string strType, bool bHeader)
Line 278:      {
Line 279:          object missing = System.Reflection.Missing.Value;
Line 280:          object alignment;
Line 281:          object bFirstPage = false;
Line 282:          object bF = true;
Line 283:          //if (bHeader == true)
Line 284:          //WordApplic.Selection.HeaderFooter.PageNumbers.ShowFirstPageNumber = bF;
Line 285:          switch (strType)
Line 286:          {
Line 287:              case "Center":
Line 288:                  alignment = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter;
Line 289:                  //WordApplic.Selection.HeaderFooter.PageNumbers.Add(ref alignment,ref bFirstPage);
Line 290:                  //Word.Selection objSelection = WordApplic.pSelection;
Line 291:  
Line 292:                  //oWordApplic.Selection.HeaderFooter.PageNumbers.Item(1).Alignment = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter;
Line 293:                  break;
Line 294:              case "Right":
Line 295:                  alignment = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberRight;
Line 296:                  //oWordApplic.Selection.HeaderFooter.PageNumbers.Item(1).Alignment = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberRight;
Line 297:                  break;
Line 298:              case "Left":
Line 299:                  alignment = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberLeft;
Line 300:                  oWordApplic.Selection.HeaderFooter.PageNumbers.Add(ref alignment, ref bFirstPage);
Line 301:                  break;
Line 302:          }
Line 303:  
Line 304:      }
Line 305:  
Line 306:  
Line 307:  }
Line 308:  //object units = WdUnits.wdCharacter;
Line 309:  //object last=doc.Characters.Count;
Line 310:  //doc.Range(ref first, ref last).Delete(ref units, ref last)
 








--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.504 


既然是调用WORD组件时出错了.那么只要对比出需要什么样的组件如何安装就好了.

服务器上是(WIN2003 X64 IIS6.0  OFFICE2003)

我本机是WIN7 X64 IIS6.1 OFFICE2007

我先将office2007 全部功能安装到服务器上先 重启测试(这个比较烦恼 服务器不止我一个项目还要选个夜深人静的时候才能测试.)


2015-1-16 14:37:31

安装好OFFICE2007 后把刚才在web.config中删除掉的行还原还是报之前的错误.就是没办法调用WORD组件.

好吧在"开始"- >"运行"中输入dcomcnfg.exe启动"组件服务"  依次双击"组件服务"- >"计算机"- >"我的电脑"- >"DCOM配置" 在"DCOM配置"中找到"Microsoft   word应用程序(全名是"Microsoft Office Word 97 - 2003 文档" 应用程序ID是"{00020906-0000-0000-C000-000000000046}")我通过对比服务器和本机 发现竟然没有.

百度了下看来已经有人和我一样了 论坛地址如下:http://bbs.youkuaiyun.com/topics/340233804

好吧.一语道破天机.服务器上 名称 和 应用程序ID 竟然是一样的.怪不得找不到"Microsoft Office Word 97 - 2003 文档"原来得找"{00020906-0000-0000-C000-000000000046}"

好吧.然后再参考此文"http://blog.youkuaiyun.com/sat472291519/article/details/42489637" 中的解决方案.


重启了一遍IIS接着测试.貌似还是不行大哭抓狂抓狂

罢了接着看应用程序引用的WORD程序集是哪几个.[项目]-[添加引用]-[扩展] 如下图.找到 C:\Program Files\Reference Assemblies\Microsoft\VSTO40\v4.0.Framework路径下的Microsoft.Office.Tools.Word.dll (多拷了Microsoft.Office.Tools.Word.v4.0.Utilities.dll ; Microsoft.Office.Tools.Word.v4.0.Utilities.xml 这俩个不知道有用没)拷贝到服务器上BIN 文件夹中.刷新网站可以正常访问了大笑




立马访问打印界面,测试下打印功能是否能正常调用.

Server Error in '/' Application.

Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 8000401a 因为配置类型不正确,系统无法开始服务器进程。请检查用户名和密码。 (Exception from HRESULT: 0x8000401A).

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 8000401a 因为配置类型不正确,系统无法开始服务器进程。请检查用户名和密码。 (Exception from HRESULT: 0x8000401A).

Source Error: 

Line 1678:        catch (Exception exc)
Line 1679:        {
Line 1680:            throw (exc);
Line 1681:        }
Line 1682:

Source File: e:\T1Web\CustInfoManage\PrintPage.aspx.cs     Line: 1680 

Stack Trace: 

[COMException (0x8000401a): Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 8000401a 因为配置类型不正确,系统无法开始服务器进程。请检查用户名和密码。 (Exception from HRESULT: 0x8000401A).]
   CustInfoManage_PrintPage.OpenModelWordSave(Object sender, EventArgs e) in e:\T1Web\CustInfoManage\PrintPage.aspx.cs:1680
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.504


为配置类型不正确,系统无法开始服务器进程。请检查用户名和密码;

1.检查新建的TEST2用户 是否是管理员用户,检查web.config用户名和密码是否正确

2.登录test2 查看能否登录.

俩项都正常. 接着检查

 开始-dcomcnfg,启动组件服务。
Microsoft Office Word 97 - 2003 文档,-属性 -安全-自定义,添加启动和激活权限、访问权限,已经添加NETWORK SERVICE用户,赋予本地启动和激活;这里都是正常的.

为了测试了.

将标识 改成 下列用户(注意,这里要选择下列用户,而不是交互式用户),用户输入正确的当前登录的管理员帐户和正确密码。

并且上面 属性 -安全-自定义 我都添加了 everyone 用户 都启用本地激活的功能.

然后刷新调用.这次总算成功了.告一段落了.

<think>嗯,我现在要理解用户提供的这段XML配置是什么,以及它在什么情况下使用。首先,这段代码看起来像是ASP.NET的配置文件中的一部分,可能是在Web.config文件里。用户提到的是<compilation>标签,里面设置了debug="true"和targetFramework="4.0",然后还有<assemblies>部分添加了一个System.Web.DataVisualization的引用。 首先,我需要回忆ASP.NET的配置结构。Web.config文件用于配置ASP.NET应用程序的各种设置,比如连接字符串、身份验证、编译选项等。<compilation>标签通常位于<system.web>节点下,控制应用程序的编译行为。debug属性设置为true,这可能意味着启用调试模式,生成调试符号,但可能会影响性能。targetFramework属性指定项目目标使用的.NET Framework版本,这里是4.0,所以应用程序会使用该版本的特性,并且需要对应的运行时环境。 接下来是<assemblies>部分,用户添加了一个assembly,System.Web.DataVisualization。这个程序集可能和图表控件有关,因为System.Web.DataVisualization包含了Chart控件,用于在Web应用中生成图表。版本是4.0.0.0,公钥令牌是31BF3856AD364E35,这应该是微软的标准公钥令牌,确保程序集的真实性。 需要确认debug属性设置为true的影响。在开发环境中,这会启用调试信息,方便开发人员排查错误,但在生产环境中应该关闭,因为会影响性能,并且可能暴露敏感信息。targetFramework="4.0"是否正确?如果应用程序实际使用的是更高版本的.NET Framework,可能需要调整。另外,添加程序集引用是否正确,是否有必要。例如,如果项目中使用的是较新的框架版本,可能需要确认该程序集是否仍然适用,或者是否需要不同的版本。 可能用户遇到的问题是在部署时缺少该程序集,或者编译时出现找不到相关命名空间的错误,所以需要在配置文件中添加引用。或者他们可能在使用Chart控件时遇到问题,需要确保程序集正确引用。此外,检查是否在项目中实际安装了对应的NuGet包或引用了正确的DLL文件,因为仅仅配置文件中添加可能不足,还需要实际的程序集存在。 总结来说,这段配置的作用是设置ASP.NET应用的编译选项,开启调试模式,指定目标框架为4.0,并添加对System.Web.DataVisualization程序集的引用,以支持图表功能。需要提醒用户注意debug模式在生产环境中的风险,以及确保目标框架和程序集版本与实际环境一致。</think>这段XML配置属于ASP.NET应用程序的`Web.config`文件中的编译设置,主要控制项目编译行为和依赖引用。以下是逐层解析: --- ### **一、配置结构定位** ```xml <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </assemblies> </compilation> ``` - **父节点**:通常位于`<system.web>`节点下。 - **作用**:定义ASP.NET应用程序的编译规则和依赖程序集。 --- ### **二、关键属性解析** #### 1. `debug="true"` - **功能**:启用调试模式。 - **影响**: - ✅ **开发阶段**:生成调试符号(.pdb文件),支持断点调试、查看变量值。 - ❌ **生产环境风险**:降低性能(不优化代码),可能暴露敏感错误信息。 - **建议**:部署时设置为`debug="false"`。 #### 2. `targetFramework="4.0"` - **功能**:指定项目目标框架为`.NET Framework 4.0`。 - **要求**: - 服务器需安装.NET Framework 4.0或兼容版本。 - 代码需符合.NET 4.0语法和API限制。 --- ### **三、程序集引用解析** #### `<add assembly="System.Web.DataVisualization..."/>` - **作用**:显式引用`System.Web.DataVisualization.dll`程序集。 - **用途**: - 提供`Chart`控件功能(如生成折线图、柱状图)。 - 需搭配`<asp:Chart>`标签在页面中使用。 - **依赖检查**: - 确保服务器GAC(全局程序集缓存)或`Bin`目录中存在该DLL。 - 若未安装,需通过NuGet安装`Microsoft.AspNet.DataVisualization`包。 --- ### **四、典型应用场景** #### 场景示例:使用ASP.NET Chart控件 1. **页面声明**: ```html <asp:Chart ID="Chart1" runat="server"> <Series> <asp:Series Name="Series1"></asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="ChartArea1"></asp:ChartArea> </ChartAreas> </asp:Chart> ``` 2. **后端代码**: ```csharp Chart1.Series["Series1"].Points.DataBindY(new[] { 10, 20, 30 }); ``` --- ### **五、常见问题排查** 1. **编译错误**:`The type 'System.Web.UI.DataVisualization.Charting.Chart' could not be found` - **原因**:缺少程序集引用。 - **解决**:检查配置中程序集名称是否拼写正确,确认DLL存在。 2. **运行时错误**:`Could not load file or assembly 'System.Web.DataVisualization'` - **原因**:服务器未安装该程序集。 - **解决**:通过NuGet安装或手动部署DLL到`Bin`目录。 --- ### **六、生产环境建议** 1. **关闭调试模式**: ```xml <compilation debug="false" targetFramework="4.0"> ``` 2. **验证程序集版本**: - 若升级到.NET 4.5+,检查`System.Web.DataVisualization`是否兼容。 --- **总结**:此配置用于ASP.NET 4.0项目的编译设置,开启调试并引用图表控件所需的程序集。需根据环境调整`debug`属性,并确保依赖正确部署。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值