嗨,我正在使用以下代码创建 ac# dll
使用系统;
使用 System.Collections.Generic;
使用 System.Text;
使用 System.Diagnostics;
使用 System.IO;
使用 System.Runtime.InteropServices;
命名空间图像导出
{
[ComVisible(真)]
公共类导出图像
{
[ComVisible(真)]
公共无效exportPNG(字符串pDirectory,字符串svgFileName,字符串输出文件名){
字符串参数= pDirectory+"res\\include\\highcharts-convert.js -infile "+pDirectory+"res\\graphs\\"+svgFileName+" -outfile "+pDirectory+"res\\graphs\\"+outputFileName +" -比例 2.5 - 宽度 1088";
/*使用 (StreamWriter writer = new StreamWriter("c:\\debug.txt", true))
{
writer.WriteLine("pDirectory=" +pDirectory);
writer.WriteLine("arguments="+arguments);
}*/
进程 p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.FileName = pDirectory+"res\\bin\\phantomjs.exe";
p.StartInfo.Arguments = 参数;
p.Start();
p.WaitForExit();
}
}
}
为了创建 dll,我在 VS2005 中进行如下配置
应用
程序集名称-> imageexport
默认命名空间 - > imageexport
outputtype => 类库
启动对象->(未设置)
装配信息:
a) 汇编版本 ->1 0 0 0
b)文件版本->1 0 0 0
c) 使 Assembly Com 可见 -> 选中
建造
配置 -> 活动(调试)
平台 -> 活动(任何 CPU)
一般的 :
a) 条件编译符号 -> 空白
b)定义调试常量->选中
c) 定义跟踪常数 -> 选中
d) 平台目标 -> 任何 CPU
e) 允许不安全代码 -> 未检查
f) 优化代码 -> 未选中
g) 警告级别 -> 4
h) Supperess 警告 -> 空白
i) 处理警告错误 -> 无
现在,在此之后,我使用 .net 2.0 的 regasm 注册 imageexport.dll
现在,当我查看注册表时,我在 HKEY_CLASSES_ROOT 下找到了 imageexport.ExportImage。
现在在 vbscript 下面的代码用于创建对象并调用函数
暗淡对象
设置 obj = CreateObject("imageexport.ExportImage")
obj.exportPNG rvPAWZDirectoryPath&"\","SVGData_"&Session("export_time")&".svg","Export_" & export_time & ".png"
但这会在 VBSCript 中的 createObject 行给出名为“UnknownException”的异常。请告诉我问题出在哪里