国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > web前端 > htmlcss > <add assembly="Microsoft.Office.Tools.Word, Version=10.0.0.0, Culture=ne

<add assembly="Microsoft.Office.Tools.Word, Version=10.0.0.0, Culture=ne

来源:程序员人生   发布时间:2015-01-20 08:41:47 阅读次数:6999次

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:T1Webweb.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 [HKLMSoftwareMicrosoftFusion!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 [HKLMSoftwareMicrosoftFusion!EnableLog].


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


2015⑴⑴6 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:T1Webweb.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 [HKLMSoftwareMicrosoftFusion!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 [HKLMSoftwareMicrosoftFusion!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:T1WebApp_CodeCCWordApp.cs    Line: 6 






Show Detailed Compiler Output:




C:WINDOWSSysWOW64inetsrv> "C:WINDOWSMicrosoft.NETFrameworkv4.0.30319csc.exe" /t:library /utf8output /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3a6a79954bbe8a36_dcf4cf01DevExpress.Web.ASPxHtmlEditor.v13.2.DLL" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Configurationv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Configuration.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Runtime.Serializationv4.0_4.0.0.0__b77a5c561934e089System.Runtime.Serialization.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Corev4.0_4.0.0.0__b77a5c561934e089System.Core.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl38dc27d626bee8f36_dcf4cf01DevExpress.Utils.v13.2.UI.resources.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3a8ab943bebb58e36_dcf4cf01DevExpress.Printing.v13.2.Core.DLL" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Data.DataSetExtensionsv4.0_4.0.0.0__b77a5c561934e089System.Data.DataSetExtensions.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl33032107aeb448c36_dcf4cf01DevExpress.XtraReports.v13.2.Extensions.resources.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl386b20fcdcba38436_dcf4cf01DevExpress.Web.ASPxThemes.v13.2.DLL" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Drawingv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Drawing.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Web.WebPages.Deploymentv4.0_1.0.0.0__31bf3856ad364e35System.Web.WebPages.Deployment.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3219f6ba1fb188536_dcf4cf01DevExpress.XtraGrid.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3c96c32236b9b8836_dcf4cf01DevExpress.Web.v13.2.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl367591196bcf8b36_dcf4cf01DevExpress.XtraPrinting.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl34ed06aaf9b818b36_dcf4cf01DevExpress.XtraCharts.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl33fc622ee8b788636_dcf4cf01DevExpress.Utils.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.ServiceModel.Webv4.0_4.0.0.0__31bf3856ad364e35System.ServiceModel.Web.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_32System.Datav4.0_4.0.0.0__b77a5c561934e089System.Data.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILMicrosoft.CSharpv4.0_4.0.0.0__b03f5f7f11d50a3aMicrosoft.CSharp.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Web.Servicesv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Web.Services.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3ac46d821db1d8c36_dcf4cf01DevExpress.XtraTreeList.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl32f48bec2bca7b36_dcf4cf01DevExpress.Web.ASPxHtmlEditor.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl34718ffb45b038636_dcf4cf01DevExpress.DataAccess.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319mscorlib.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Web.ApplicationServicesv4.0_4.0.0.0__31bf3856ad364e35System.Web.ApplicationServices.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.ComponentModel.DataAnnotationsv4.0_4.0.0.0__31bf3856ad364e35System.ComponentModel.DataAnnotations.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Web.DynamicDatav4.0_4.0.0.0__31bf3856ad364e35System.Web.DynamicData.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_32System.EnterpriseServicesv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.EnterpriseServices.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Xml.Linqv4.0_4.0.0.0__b77a5c561934e089System.Xml.Linq.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3a766ce63dbac8936_dcf4cf01DevExpress.Data.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3945ced597ba48d36_dcf4cf01DevExpress.Data.v13.2.DLL" /R:"C:WINDOWSassemblyGAC_MSILMicrosoft.ReportViewer.Common9.0.0.0__b03f5f7f11d50a3aMicrosoft.ReportViewer.Common.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3c72258e36b0c8b36_dcf4cf01DevExpress.Printing.v13.2.Core.resources.DLL" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.ServiceModelv4.0_4.0.0.0__b77a5c561934e089System.ServiceModel.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl34b6a04fe8be98836_dcf4cf01DevExpress.DataAccess.v13.2.UI.resources.DLL" /R:"C:WINDOWSassemblyGAC_MSILMicrosoft.ReportViewer.ProcessingObjectModel9.0.0.0__b03f5f7f11d50a3aMicrosoft.ReportViewer.ProcessingObjectModel.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Windows.Formsv4.0_4.0.0.0__b77a5c561934e089System.Windows.Forms.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl38c30e28772726957_ca2bd001App_Licenses.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl376f1f0e7ebd38936_dcf4cf01DevExpress.XtraReports.v13.2.Web.resources.DLL" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystemv4.0_4.0.0.0__b77a5c561934e089System.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl35d19a33c7b159036_dcf4cf01DevExpress.Web.ASPxSpellChecker.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3c1aeec2fb5e8936_dcf4cf01DevExpress.XtraNavBar.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl390d8b77e4bdc8536_dcf4cf01Microsoft.Vbe.Interop.DLL" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Web.Extensionsv4.0_4.0.0.0__31bf3856ad364e35System.Web.Extensions.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.ServiceModel.Activitiesv4.0_4.0.0.0__31bf3856ad364e35System.ServiceModel.Activities.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_32System.Webv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Web.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3f2ca8fcb408536_dcf4cf01DevExpress.Web.ASPxScheduler.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl38f49a32c8bcb8d36_dcf4cf01DevExpress.Web.ASPxTreeList.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3b5faf33fb6b8c36_dcf4cf01DevExpress.XtraReports.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.IdentityModelv4.0_4.0.0.0__b77a5c561934e089System.IdentityModel.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.ServiceModel.Activationv4.0_4.0.0.0__31bf3856ad364e35System.ServiceModel.Activation.dll" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Activitiesv4.0_4.0.0.0__31bf3856ad364e35System.Activities.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3f8bec3688b3c9036_dcf4cf01DevExpress.Web.v13.2.resources.DLL" /R:"C:WINDOWSassemblyGAC_MSILMicrosoft.ReportViewer.WebForms9.0.0.0__b03f5f7f11d50a3aMicrosoft.ReportViewer.WebForms.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3312172aab7c7b36_dcf4cf01DevExpress.XtraCharts.v13.2.Wizard.resources.DLL" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Xmlv4.0_4.0.0.0__b77a5c561934e089System.Xml.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl3307b3a489b108936_dcf4cf01DevExpress.XtraEditors.v13.2.resources.DLL" /R:"C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.WorkflowServicesv4.0_4.0.0.0__31bf3856ad364e35System.WorkflowServices.dll" /R:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36assemblydl34ad03872b8e8536_dcf4cf01DevExpress.XtraBars.v13.2.resources.DLL" /out:"C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36App_Code.fs1kyxl-.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699;1701 /warnaserror-  "C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36App_Code.fs1kyxl-.0.cs" "C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36App_Code.fs1kyxl-.1.cs" "C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36App_Code.fs1kyxl-.2.cs" "C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36App_Code.fs1kyxl-.3.cs" "C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36App_Code.fs1kyxl-.4.cs" "C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36App_Code.fs1kyxl-.5.cs" "C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36App_Code.fs1kyxl-.6.cs" "C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files ootfdb97f61f8333f36App_Code.fs1kyxl-.7.cs"




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


e:T1WebApp_CodeCCWordApp.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:T1WebApp_CodeCCWordApp.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  打开1个文件(该文件必须存在),并激活它
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打开1个新文档
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:      //去到1个预先定义的书签,如果书签不存在利用程序将引发毛病
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 全部功能安装到服务器上先 重启测试(这个比较烦恼 服务器不止我1个项目还要选个夜深人静的时候才能测试.)


2015⑴⑴6 14:37:31

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

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

百度了下看来已有人和我1样了 论坛地址以下:http://bbs.csdn.net/topics/340233804

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

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


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

罢了接着看利用程序援用的WORD程序集是哪几个.[项目]-[添加援用]-[扩大] 以下图.找到 C:Program FilesReference AssembliesMicrosoftVSTO40v4.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:T1WebCustInfoManagePrintPage.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:T1WebCustInfoManagePrintPage.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 用户 都启用本地激活的功能.

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

生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生