日期:2014-05-17  浏览次数:20581 次

在VS中运行页面和发布之后在IIS中运行到底有什么区别
程序就一个页面使用了CodeSoft7.0的一个DLL(LabelManager2.dll),然后调用了这个DLL中的一个方法是用来改变局域网中选择那台打印机打印的函数。
设置:在运行中输入Dcomcnfg把“服务组件”---“DCOM配置”都里面用到的第三方DCOM属性安全里面所有用户的所有访问权限都加上了。

VS调试和IIS发布都是在我本地电脑,VS运行页面提交后,打印机提示打印成功;在本机同一台电脑发布后的IIS中运行页面提示:“打印机设置出错或拒绝访问”,请问VS中运行页面和IIS中运行页面到底有什么区别,是匿名用户访问的区别吗?(我在IIS中把匿名用户设置成ASPNET还是提示失败)

代码如下:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using LabelManager2;
using System.Collections.Generic;
using System.Reflection;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void btnPrint_Click(object sender, EventArgs e)
        {
            ApplicationClass lbl = new ApplicationClass();           

            try
            {
                lbl.Documents.Open(this.MapPath("Document2.lab"), false);// 调用设计好的label文件                

                Document doc = lbl.ActiveDocument;
//局域网打印机地址:\\MR50006433PC2\ZDesigner 110XiIII Plus 300DPI  和  \\MR50007967PC2\Zebra S4M (300 dpi) - ZPL
                string printName=txtPrintName.Text.Trim();
//端口:LPT1:
                string printPoint = txtPrintPoint.Text.Trim(); 

                bool Ptflag = doc.Printer.SwitchTo(@printName, printPoint, true);
                if (Ptflag)
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('打印成功2!');</script>");
                    doc.PrintDocument(1);
                }