MS Word自动化问题与asp.net相关 [英] MS Word automation problem abut asp.net

查看:65
本文介绍了MS Word自动化问题与asp.net相关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望服务器(IIS)能够停止一个单词,用户可以下载这个文件,即。



i使用MS WORD AUTOMATIONS的解决方案,代码如下下面:



I want server(IIS) to ceate a word doument and users can download this file BY ie.

i use the solutions of MS WORD AUTOMATIONS,the codes like below:

using Word = Microsoft.Office.Interop.Word;
private Word.ApplicationClass oWordApplic;
private Word.Document oDoc;		

oWordApplic = new Word.ApplicationClass();
object missing = System.Reflection.Missing.Value;
oDoc = oWordApplic.Documents.Add(ref missing, ref missing,ref missing, ref missing);
oDoc.Activate();		
oWordApplic.Selection.TypeText("test");
oDoc.SaveAs("tes.doc", ref missing,ref missing, ref missing,ref missing,ref missing,ref missing,
				ref missing,ref missing,ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

oWordApplic.Application.Quit(ref missing, ref missing, ref missing);









这些代码在我的本地机器上运行良好,但是当我在服务器上发布这个asp.net项目时,代码不起作用并且没有任何提示消息或错误消息。



没有文件创建,也没有任何提醒信息。



任何人都可以帮助我?













我找到了这个问题的原因!





在web.config中,如果我设置<编译调试=false>(发布),问题发生



如果我设置< compilation debug =true> (调试),程序运行良好。



但我不知道为什么?我将调试版本发布到服务器?



任何人都可以帮助我???





this codes works well on my local machine,but when i publish this asp.net project on the server, the code do not work AND there is no any prompt message or error message.

no file is created and no any alert message.

anyone can help me??






I find the cause of this problem!


in the web.config, if i set the <compilation debug="false">(release), the issue occurs

if I set the <compilation debug="true"> (debug), the programs works well.

but I do not know why? and I publish a debug version to the server ?

anyone can help me ???

推荐答案

感谢您的帮助!



我找到了这个问题的原因!





在web.config中,如果我设置< compilation debug =false> (发布),问题发生



如果我设置< compilation debug =true> (调试),程序运行良好。



但我不知道为什么?我将调试版本发布到服务器?



任何人都可以帮助我???
thanks for your help!

I find the cause of this problem!


in the web.config, if i set the <compilation debug="false"> (release), the issue occurs

if I set the <compilation debug="true"> (debug), the programs works well.

but I do not know why? and I publish a debug version to the server ?

anyone can help me ???


你所写的内容将在服务器上运行。检查文件是否在服务器上创建并放在您为其编写代码的文件夹中。

由于您正在使用Web应用程序,因此用户/客户端不会看到任何内容 - 错误或提示,因为编写的代码不是客户端。



上面的代码是创建一个word文档并保存在服务器上。现在,您的步骤应该是找到核心问题:

1.是否创建文件

2.下载到客户端的文件



首先检查1,如果创建时有任何问题,应该由日志捕获。可能没有足够的安全权限来保存指定文件夹中的文件。

如果1工作正常,请查看代码2.查看是否从正确的位置选择文件以传递给客户端或不。一步一步地缩小问题以解决问题。拾取下载时可能是文件路径未正确形成。
What you have written will run on server. Check if the file is created on server and placed in the folder where you wrote code for.
Since you are having a web application, user/client will not see anything on their side - error or prompt as the code written is not a client side.

Code above is to create a word document and save on server. Now, your steps should be to find the core issue:
1. Document created or not
2. Document downloaded to client or not

Check for 1 first, if there is any issue on creation, it should be captured by logs. May be insufficient security privilege to save a file in the folder designated.
If 1 is working fine, look at the code for 2. See if the file is picked from correct location to be passed to client or not. Go step wise and narrow down the issue to resolve. May be the filepath while picking for download is not correctly formed.


这篇关于MS Word自动化问题与asp.net相关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆