程序里面调用autocad的 Autodesk.AutoCAD.Interop.Common.dll和Autodesk.AutoCAD.Interop.dll
功能就是把dwg文件转换成pdf文件
vs2010里面调试都正常的,一在IIS浏览里面查看就报错。
代码如下public string FoldPath = @"C:\Users\Administrator\Desktop\新建文件夹 (2)\";
public string targetPath = @"E:\znl\WebSite1\PDF\";
protected void Page_Load(object sender, EventArgs e)
{ }
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
if (this.TreeView1.SelectedNode.ChildNodes.Count < 1)
{
string filePath = FoldPath + TreeView1.SelectedNode.Value.Trim();
int fangxiang = 90; if (System.IO.File.Exists(filePath))
{
try
{
string filename = Path.GetFileNameWithoutExtension(filePath);
string foloder = Path.GetDirectoryName(filePath);
string filesource = foloder + "\\" + filename + "-Model.pdf";
string filetarget = targetPath + filename + ".pdf";
AcadDocumentClass AcdDoc = new AcadDocumentClass();
AcadDocument docu = AcdDoc.Application.Documents.Open(filePath, true, null); //以只读方式打开该文件
docu.ActiveLayout.ConfigName = "DWG To PDF.pc3"; //定义打印机
docu.ActiveLayout.UseStandardScale = true;
docu.ActiveLayout.StandardScale = AutoCAD.AcPlotScale.acScaleToFit;
docu.ActiveLayout.PlotType = AutoCAD.AcPlotType.acExtents;
docu.ActiveLayout.CenterPlot = true;
if (fangxiang == 0)
{
docu.ActiveLayout.PlotRotation = AutoCAD.AcPlotRotation.ac0degrees;
}
else
{
docu.ActiveLayout.PlotRotation = AutoCAD.AcPlotRotation.ac90degrees;
}
//docu.ActiveLayout.CanonicalMediaName = "A0"; //定义打印纸张
docu.ActiveLayout.PlotType = AutoCAD.AcPlotType.acExtents; //定义打印范围 docu.Plot.PlotToDevice(null);
docu.Close(null, null);
AcdDoc.Close(null, null);
if (System.IO.Directory.Exists(targetPath))
{ while (true)
{
if (System.IO.File.Exists(filesource) && !(IsFileInUse(filesource)))
{ System.Threading.Thread.Sleep(2000);
System.IO.File.Copy(filesource, filetarget, true);
while (true)
{
if (System.IO.File.Exists(filetarget))
{
System.IO.File.Delete(filesource);
ShowPdf1.FilePath = "PDF/"+filename + ".pdf";
break;
}
System.Threading.Thread.Sleep(1000);
} break;
}
System.Threading.Thread.Sleep(1000);
}
}
else
{
}
}
catch(Exception ex)
{
Console.WriteLine("Convert Failed!"); }
}
else
{
} }
else
{ }
}具体的报错是:
检索 COM 类工厂中 CLSID 为 {6D7AE628-FF41-4CD3-91DD-34825BB1A251} 的组件失败,原因是出现以下错误: 80070005 拒绝访问。 (异常来自 HRESULT:0x80070005 (E_ACCESSDENIED))。IIS里面报错事件:计算机-默认 权限设置并未从地址 LocalHost(使用 LRPC) 使用 CLSID
{D70E31AD-2614-49F2-B0FC-ACA781D81F3E}
和 APPID
不可用
向用户 IIS APPPOOL\DefaultAppPool SID (S-1-5-82-3006700770-424185619-1745488364-794895919-4004696415)授予对 COM 服务器应用程序的 本地 激活 权限。此安全权限可以使用组件服务管理工具进行修改。
在DCOM配置的时候 一直没找到IIS APPPOOL\DefaultAppPool 用户 。
求高手指点dwf 装换pdf
功能就是把dwg文件转换成pdf文件
vs2010里面调试都正常的,一在IIS浏览里面查看就报错。
代码如下public string FoldPath = @"C:\Users\Administrator\Desktop\新建文件夹 (2)\";
public string targetPath = @"E:\znl\WebSite1\PDF\";
protected void Page_Load(object sender, EventArgs e)
{ }
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
if (this.TreeView1.SelectedNode.ChildNodes.Count < 1)
{
string filePath = FoldPath + TreeView1.SelectedNode.Value.Trim();
int fangxiang = 90; if (System.IO.File.Exists(filePath))
{
try
{
string filename = Path.GetFileNameWithoutExtension(filePath);
string foloder = Path.GetDirectoryName(filePath);
string filesource = foloder + "\\" + filename + "-Model.pdf";
string filetarget = targetPath + filename + ".pdf";
AcadDocumentClass AcdDoc = new AcadDocumentClass();
AcadDocument docu = AcdDoc.Application.Documents.Open(filePath, true, null); //以只读方式打开该文件
docu.ActiveLayout.ConfigName = "DWG To PDF.pc3"; //定义打印机
docu.ActiveLayout.UseStandardScale = true;
docu.ActiveLayout.StandardScale = AutoCAD.AcPlotScale.acScaleToFit;
docu.ActiveLayout.PlotType = AutoCAD.AcPlotType.acExtents;
docu.ActiveLayout.CenterPlot = true;
if (fangxiang == 0)
{
docu.ActiveLayout.PlotRotation = AutoCAD.AcPlotRotation.ac0degrees;
}
else
{
docu.ActiveLayout.PlotRotation = AutoCAD.AcPlotRotation.ac90degrees;
}
//docu.ActiveLayout.CanonicalMediaName = "A0"; //定义打印纸张
docu.ActiveLayout.PlotType = AutoCAD.AcPlotType.acExtents; //定义打印范围 docu.Plot.PlotToDevice(null);
docu.Close(null, null);
AcdDoc.Close(null, null);
if (System.IO.Directory.Exists(targetPath))
{ while (true)
{
if (System.IO.File.Exists(filesource) && !(IsFileInUse(filesource)))
{ System.Threading.Thread.Sleep(2000);
System.IO.File.Copy(filesource, filetarget, true);
while (true)
{
if (System.IO.File.Exists(filetarget))
{
System.IO.File.Delete(filesource);
ShowPdf1.FilePath = "PDF/"+filename + ".pdf";
break;
}
System.Threading.Thread.Sleep(1000);
} break;
}
System.Threading.Thread.Sleep(1000);
}
}
else
{
}
}
catch(Exception ex)
{
Console.WriteLine("Convert Failed!"); }
}
else
{
} }
else
{ }
}具体的报错是:
检索 COM 类工厂中 CLSID 为 {6D7AE628-FF41-4CD3-91DD-34825BB1A251} 的组件失败,原因是出现以下错误: 80070005 拒绝访问。 (异常来自 HRESULT:0x80070005 (E_ACCESSDENIED))。IIS里面报错事件:计算机-默认 权限设置并未从地址 LocalHost(使用 LRPC) 使用 CLSID
{D70E31AD-2614-49F2-B0FC-ACA781D81F3E}
和 APPID
不可用
向用户 IIS APPPOOL\DefaultAppPool SID (S-1-5-82-3006700770-424185619-1745488364-794895919-4004696415)授予对 COM 服务器应用程序的 本地 激活 权限。此安全权限可以使用组件服务管理工具进行修改。
在DCOM配置的时候 一直没找到IIS APPPOOL\DefaultAppPool 用户 。
求高手指点dwf 装换pdf
需要使用dcomcnfg来配置。
***************************************************************
具体解决方法如下:1:在服务器上安装office的Excel软件.2:在"开始"->"运行"中输入dcomcnfg.exe启动"组件服务"3:依次双击"组件服务"->"计算机"->"我的电脑"->"DCOM配置"4:在"DCOM配置"中找到"Microsoft Excel 应用程序",在它上面点击右键,然后点击"属性",弹出"Microsoft Excel 应用程序属性"对话框5:点击"标识"标签,选择"交互式用户"(此设置可能对计算机安全存在威胁,如不设置可以解决问题就不设置)。6:点击"安全"标签,在"启动和激活权限"上点击"自定义",然后点击对应的"编辑"按钮,在弹出的"安全性"对话框中填加一个"NETWORK SERVICE"用户(注意要选择本计算机名),并给它赋予"本地启动"和"本地激活"权限.7:依然是"安全"标签,在"访问权限"上点击"自定义",然后点击"编辑",在弹出的"安全性"对话框中也填加一个"NETWORKSERVICE"用户,然后赋予"本地访问"权限.这样,我们便配置好了相应的Excel的DCOM权限.注意:这是在WIN2003上配置的,在2000,xp上,NETWORK SERVICE用户改为ASP.net用户。
***************************************************************来自:
http://www.cnblogs.com/yssoft/archive/2009/04/20/1439762.html
你可以在Application pool中设置用什么用户运行IIS process.
。
没有在web里面添加调取cad转换的程序,因为不实际,而且cad只能开2个进程。谢谢大家帮忙。结贴了