"Automation服务器不能创建对象" 的多种解决办法

方法一:
开始-运行:regsvr32 scrrun.dll


方法二:
请将以下语句复制到记事本中,另存为后缀为.cmd的文件,并运行。当然在命令行下一句句运行也没问题。
echo 正在修复,这个过程可能需要几分钟,请稍候……
rundll32.exe advpack.dll /DelNodeRunDLL32 %systemroot%\System32\dacui.dll
rundll32.exe advpack.dll /DelNodeRunDLL32 %systemroot%\Catroot\icatalog.mdb
regsvr32 /s comcat.dll
regsvr32 /s asctrls.ocx
regsvr32 /s oleaut32.dll
regsvr32 /s shdocvw.dll /I
regsvr32 /s shdocvw.dll
regsvr32 /s browseui.dll
regsvr32 /s browseui.dll /I
regsvr32 /s msrating.dll
regsvr32 /s mlang.dll
regsvr32 /s hlink.dll
regsvr32 /s mshtml.dll
regsvr32 /s mshtmled.dll
regsvr32 /s urlmon.dll
regsvr32 /s plugin.ocx
regsvr32 /s sendmail.dll
regsvr32 /s mshtml.dll /i
regsvr32 /s scrobj.dll
regsvr32 /s corpol.dll
regsvr32 /s jscript.dll
regsvr32 /s msxml.dll
regsvr32 /s imgutil.dll
regsvr32 /s cryptext.dll
regsvr32 /s inseng.dll
regsvr32 /s iesetup.dll /i
regsvr32 /s cryptdlg.dll
regsvr32 /s actxprxy.dll
regsvr32 /s dispex.dll
regsvr32 /s occache.dll
regsvr32 /s iepeers.dll
regsvr32 /s urlmon.dll /i
regsvr32 /s cdfview.dll
regsvr32 /s webcheck.dll
regsvr32 /s mobsync.dll
regsvr32 /s pngfilt.dll
regsvr32 /s licmgr10.dll
regsvr32 /s hhctrl.ocx
regsvr32 /s inetcfg.dll
regsvr32 /s trialoc.dll
regsvr32 /s tdc.ocx
regsvr32 /s MSR2C.DLL
regsvr32 /s msident.dll
regsvr32 /s msieftp.dll
regsvr32 /s xmsconf.ocx
regsvr32 /s ils.dll
regsvr32 /s msoeacct.dll
regsvr32 /s wab32.dll
regsvr32 /s wabimp.dll
regsvr32 /s wabfind.dll
regsvr32 /s oemiglib.dll
regsvr32 /s directdb.dll
regsvr32 /s inetcomm.dll
regsvr32 /s msoe.dll
regsvr32 /s oeimport.dll
regsvr32 /s msdxm.ocx
regsvr32 /s dxmasf.dll
regsvr32 /s laprxy.dll
regsvr32 /s l3codecx.ax
regsvr32 /s acelpdec.ax
regsvr32 /s mpg4ds32.ax
regsvr32 /s danim.dll
regsvr32 /s Daxctle.ocx
regsvr32 /s lmrt.dll
regsvr32 /s datime.dll
regsvr32 /s dxtrans.dll
regsvr32 /s dxtmsft.dll
regsvr32 /s wshom.ocx
regsvr32 /s wshext.dll
regsvr32 /s vbscript.dll
regsvr32 /s scrrun.dll mstinit.exe /setup
regsvr32 /s msnsspc.dll /SspcCreateSspiReg
regsvr32 /s msapsspc.dll /SspcCreateSspiReg
echo.
echo.
echo 修复成功!任意键退出!
pause>nul

就是组件的注册问题,我的问题用这种方法解决了。


方法三:
一直用得好好的vs.net编辑器,突然有一天在我新建一个工程时,进行到一半时,弹出"Automation 服务器不能创建对象",然后就停住了。

我到csdn上以"Automation"关键字查阅了C#版的问题,发现有很多朋友都遇上过,而回答的朋友大部分以为提问者问的是IE解析xml文件时的那个错误 (见 http://www.csdn.net/expert/topic/757/757297.xml )

看到几个回答此类问题的,都是遇到过这个问题的朋友,他们的答案是:重装vs.net都没有作用,最后重新装操作系统才将这个问题解决。
要我装操作系统真是要我的命,所以我一直用 Copy & Paste 工程文件来达到新建工程的目的。

直到有一天,我无意中点了 vs_setup.msi 来添加 vs.net 的帮助文档(后来才知道应该点setup.exe来添加的)。vs_setup.msi进行到一半,也是出错了,一看调试结果,是FileSystemObject创建失败(感谢上帝,这里的错误信息终于是友好些了)。
vs.net的错误 "Automation 服务器不能创建对象" 是不是也是这个导致的呢?

我突然想起,前几个月在网上听说可以禁止使用FileSystemObject对象,我当时都忘了怎么操作的了,反正当时一摆弄,具体怎么操作的我也忘了,从那起我也从来没有在我的程序里用过FileSystemObject了。到google上搜索,发现禁止FileSystemObject有3种方法(http://www.sometips.com/faqs/315.htm),第一种方法:修改注册表([HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{0D43FE01-F093-11CF-8940-00A0C9054228}\ProgID]
@="Scripting.FileSystemObject"),将FileSystemObject改成一个任意的名字,只有知道该名字的用户才可以创建该对象。我查看注册表,该处的名字还是 Scripting.FileSystemObject.

那么我的FSO为何不能用呢?我突然想起原来当时我用的是第二种方法,"运行Regsvr32 scrrun.dll /u,所有用户无法创建FileSystemObject"。 当时真是太狠了些。赶快运行 Regsvr32 scrrun.dll。我试着用vs.net 创建一个工程,一阵进度提示,再也没有那个该死的 "Automation 服务器不能创建对象"

所以,遇上这类问题的朋友,仔细想想有没有动这"FileSystemObject"这个奶酪,应该都可以通过这个方法解决的。否则真的要重新安装操作系统,又要重新安装vs.net喔。


方法四:
在控制面板中打开“用户账户”,选择其中的“更改用户登录或注销的方式”时出现“automation服务器不能创建对象”的错误提示。(如果在执行其他操作时,出现这个错误提示,亦可按下面的方法解决,原因是一样的。)

解决:主要是Scripting.FileSystemObject(FSO 文本文件读写)被关闭了,开启FSO功能即可,在“运行”中执行regsvr32 scrrun.dll。

特别方法:在“运行”中执行regsvr32 shimgvw.dll


方法五:
不用重新安装操作系统和vs.net,但有些脚本需要微软的 MSXML 控件才能进入。当使用 IE 5 以上版本的缺省安全模式时,会提示是否接受 MSXML 控件,如果接受,MSXML 将自动安装到您的机器上(得等上几分钟)。如果自动安装不成功,可以自行下载和安装 MSXML 3.0。如果安装 MSXML 3 后仍然出现“Automation 服务器不能创建对象”错误,是因为您的机器禁止了所有的ActiveX,一般将 IE 的安全模式设为“中”即可

方法六:
我的机器用了上面的方法没有解决问题,用下面的方法解决了问题,大家不妨可以试试:打开Internet Explorer “工具”菜单栏中的“选项”一栏,单击“安全”栏中的“自定义级别”选项卡,将第三项“对没有标记为安全的activex控件进行初始化和脚本运行”设置成“启用”即可。

 

经过测试后,部分可以了!

<script >
function OpenWord(){  
Layer1.style.border=0 
word = new ActiveXObject('Word.Application');  
word.Application.Visible = true;  
var mydoc=word.Documents.Add('',0,1);  
myRange =mydoc.Range(0,1)  
var sel=Layer1.document.body.createTextRange()  
sel.select()  
Layer1.document.execCommand('Copy')  
sel.moveEnd('character')  
myRange.Paste();  
location.reload()  
word.ActiveWindow.ActivePane.View.Type=1 
}  
  </script>
<input type="button" value="word" onclick="OpenWord()"/>
<div id="Layer1" name="Layer1"></div>

以面是从codeproject网站拷下来的,还是无法执行

 

<%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="AJAXUpload._Default" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>Default</title>
  <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
  <meta content="C#" name="CODE_LANGUAGE">
  <meta content="JavaScript" name="vs_defaultClientScript">
  <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
  <style type="text/css"> .tdBorder { border-color:Black; border-width:1px; border-style:Solid; }
 .tableBorder { border-color:Black; border-width:1px; border-style:Solid; border-collapse:collapse; }
  </style>
  <script language="javascript">
  var filePath;
  var xmlhttp;
  var fileSize;
  var fileName;
  var adoStream = new ActiveXObject("ADODB.Stream");
  var cancelUpload;
  
  //Receive intial file information and init upload
  function getFileParams()
  {
   //Convert file path to appropriate format
   this.filePath = document.getElementById("file").value.replace(/\\/g, "\\\\");
   
   fso = new ActiveXObject( 'Scripting.FileSystemObject' );
   if ( !fso.FileExists(this.filePath) )
   {
    alert("Can't open file.");
    return;
   }
    
   f = fso.GetFile( this.filePath );
   this.fileSize = f.size;
   this.fileName = f.Name;
   InitStatusForm();
   InitUpload();
  }
  //Initialize progress bar panel
  function InitStatusForm()
  {
    this.cancelUpload = false;
    SetButtonCloseState(true);
    document.getElementById("uploadStatus").innerHTML = "Initializing";
    document.getElementById("fileSize").innerHTML = (this.fileSize/1024).toLocaleString();
    document.getElementById("uploadPercentage").innerHTML = "0".toLocaleString();
    document.getElementById("progressBar").style.width = 0+"%";
  }
  //Read part of file and send it to webservice
  function SendFilePart(offset, length)
  {
   // create SOAP XML document
   var xmlSOAP = new ActiveXObject("MSXML2.DOMDocument");
   xmlSOAP.loadXML('<?xml version="1.0" encoding="utf-8"?>'+
   '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+
    '<soap:Body>'+
     '<UploadData xmlns="http://tempuri.org/">'+
      '<fileName>'+this.fileName+'</fileName>'+
      '<fileSize>'+this.fileSize+'</fileSize>'+
      '<file></file>'+
     '</UploadData>'+
    '</soap:Body>'+
   '</soap:Envelope>');
   
   // create a new node and set binary content
   var fileNode = xmlSOAP.selectSingleNode("//file");
   fileNode.dataType = "bin.base64";
   // open stream object and read source file
   if (adoStream.State != 1 )
   {
    adoStream.Type = 1;  // 1=adTypeBinary
    adoStream.Open();
    adoStream.LoadFromFile(this.filePath);
   }
   
   adoStream.Position = offset;
   // store file content into XML node
   fileNode.nodeTypedValue = adoStream.Read(length);//adoStream.Read(-1); // -1=adReadAll
   if (adoStream.EOS)
   {
    //Close Stream
    adoStream.Close();
   }
   
   // send XML document to Web server
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   xmlhttp.onreadystatechange = HandleStateChange;
   xmlhttp.open("POST","http://localhost/AJAXUpload/Upload.asmx",true);
   xmlhttp.setRequestHeader("SOAPAction", "http://tempuri.org/UploadData");
   xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
   xmlhttp.send(xmlSOAP);
  }
  //send init upload request to webservice
  function InitUpload()
  {
   document.getElementById("uploadConsole").style.display = "none";
   document.getElementById("statusConsole").style.display = "block";
   
   xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
   xmlhttp.onreadystatechange = HandleStateChange;
  
   var parameters = "fileSize=" + encodeURI(this.fileSize) +
   "&fileName=" + encodeURI(this.fileName)+
   "&overwriteFile=" + encodeURI(document.getElementById("overwriteFile").checked);

   xmlhttp.open("POST","http://localhost/AJAXUpload/Upload.asmx/InitUpload", true);
   xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
   xmlhttp.setRequestHeader("Content-length", parameters.length);
   xmlhttp.setRequestHeader("Connection", "close");
   xmlhttp.send(parameters);
  }
  //XMLHTTPRequest change state callback function
  function HandleStateChange() {
   switch (xmlhttp.readyState) {
   case 4:
    response  = xmlhttp.responseXML.documentElement;
    id = response.getElementsByTagName('ID')[0].firstChild.data;
    offset = response.getElementsByTagName('OffSet')[0].firstChild.data;
    bufferLength = response.getElementsByTagName('BufferLength')[0].firstChild.data;
    
    percentage = (offset/this.fileSize)*100;
    if (offset<this.fileSize && !this.cancelUpload)
    {
     UpdateStatusConsole(percentage, "Uploading");
     SendFilePart(offset, bufferLength);
    }
    else
    {
     SetButtonCloseState(false);
     if (this.cancelUpload)
      UpdateStatusConsole(percentage, "Canceled");
     else
      UpdateStatusConsole(percentage, "Complete");
    }
    break;
   } 
  }
  //Update progress bar panel
  function UpdateStatusConsole(percentage, uploadStatus)
  {
   document.getElementById("uploadPercentage").innerHTML = percentage.toLocaleString();
   document.getElementById("progressBar").style.width = percentage+"%";
   document.getElementById("uploadStatus").innerHTML = uploadStatus;
  }
  //Encode parameter
  function URLEncode(str)
  {
   return escape(str).replace(/[+]/g, '%2B');
  }
  //Close button functionality
  function CancelUpload()
  {
   this.cancelUpload = true;
   SetButtonCloseState(false);
  }
  //Set close button Enabled/Disabled state
  function SetButtonCloseState(disabled)
  {
   document.getElementById("buttonClose").disabled = disabled;
  }
  //Hide Progress bar panel and set panel with brose file dialog visible
  function CloseStatusConsole()
  {
   document.getElementById("uploadConsole").style.display = "block";
   document.getElementById("statusConsole").style.display = "none";
  }
  </script>
 </HEAD>
 <body>
  <form id="Form1" method="post" runat="server">
   <TABLE class="tableBorder" id="statusConsole" cellSpacing="0" cellPadding="0" width="360"
    bgColor="ghostwhite" border="0" style="DISPLAY: none">
    <TR bgColor="gainsboro">
     <TD align="center" width="350" bgColor="gainsboro" colSpan="3">Status: <span id="uploadStatus">
       Initializing</span></TD>
     <TD align="right" width="10"><INPUT type="button" id="buttonClose" value="X" disabled onclick="CloseStatusConsole();"></TD>
    </TR>
    <TR>
     <TD width="50"></TD>
     <TD align="center" width="250">File Size: <span id="fileSize">1,234,321</span> KB</TD>
     <TD width="50"></TD>
     <TD width="10"></TD>
    </TR>
    <TR>
     <TD align="right" width="50">0%</TD>
     <TD class="tdBorder" width="250">
      <TABLE id="progressBar" height="20" cellSpacing="0" cellPadding="0" width="50%" bgColor="dimgray"
       border="0">
       <TR>
        <TD></TD>
       </TR>
      </TABLE>
     </TD>
     <TD width="50">100%</TD>
     <TD width="10"></TD>
    </TR>
    <TR>
     <TD width="50"></TD>
     <TD align="center" width="250">Uploaded: <span id="uploadPercentage">25.20</span> %</TD>
     <TD width="50"></TD>
     <TD width="10"></TD>
    </TR>
    <TR>
     <TD width="50"></TD>
     <TD align="center" width="250"><INPUT id="buttonCancel" type="button" value="Cancel" onclick="CancelUpload();"></TD>
     <TD width="50"></TD>
     <TD width="10"></TD>
    </TR>
    <TR>
     <TD width="50"></TD>
     <TD align="center" width="250">&nbsp;</TD>
     <TD width="50"></TD>
     <TD width="10"></TD>
    </TR>
   </TABLE>
   <TABLE class="tableBorder" id="uploadConsole" borderColor="black" cellSpacing="0" cellPadding="1"
    width="360" bgColor="ghostwhite" border="0">
    <TR>
     <TD class="tdBorder" align="center" bgColor="gainsboro" colSpan="2">Upload Console</TD>
    </TR>
    <TR>
     <TD class="tdBorder" align="center" width="300">File Path</TD>
     <TD class="tdBorder" width="60">Overwrite</TD>
    </TR>
    <TR>
     <TD class="tdBorder" align="center" width="300"><INPUT id="file" type="file" name="file"></TD>
     <TD class="tdBorder" align="center" width="60"><INPUT id="overwriteFile" type="checkbox" value="on"></TD>
    </TR>
    <TR>
     <TD class="tdBorder" align="right" colSpan="2"><INPUT id="ButtonUpload" onclick="getFileParams(); return false;" type="button" value="Upload"
       name="ButtonUpload"></TD>
    </TR>
   </TABLE>
  </form>
 </body>
</HTML>

Ajax无更新上传文件的附件

/Files/qiaojun/AJAXUpload_src.zip
posted @ 2009-03-26 10:25  月光小提琴  阅读(4454)  评论(0)    收藏  举报