aga*_*era 0 c# com vbscript visual-studio-2005 visual-studio-2010
嗨,我正在用下面的代码创建ac#dll
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
namespace imageexport
{
[ComVisible(true)]
public class ExportImage
{
[ComVisible(true)]
public void exportPNG(String pDirectory,String svgFileName,String outputFileName) {
String arguments= pDirectory+"res\\include\\highcharts-convert.js -infile "+pDirectory+"res\\graphs\\"+svgFileName+" -outfile "+pDirectory+"res\\graphs\\"+outputFileName +" -scale 2.5 -width 1088";
/*using (StreamWriter writer = new StreamWriter("c:\\debug.txt", true))
{
writer.WriteLine("pDirectory=" +pDirectory);
writer.WriteLine("arguments="+arguments);
}*/
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.FileName = pDirectory+"res\\bin\\phantomjs.exe";
p.StartInfo.Arguments = arguments;
p.Start();
p.WaitForExit();
}
}
}
为了创建DLL,我在VS2005中进行如下配置
Application
Assembly Name -> imageexport
Default Namespace - > imageexport
outputtype => Classlibrary
startup object ->(Not Set)
Assembly Information :
a) Assembly Version ->1 0 0 0
b)File Version ->1 0 0 0
c) Make Assembly Com visible ->checked
Build
Configuration -> Active (Debug)
Platform ->Active (Any CPU)
General :
a)conditional Compilation Symbols -> blank
b) Define Debug Constant ->checked
c) Define Trace Constant -> checked
d) platform Target -> Any CPU
e) allow unsafe code -> not checked
f) optimize code -> not checked
g) warning lavel -> 4
h) Supperess warning -> blank
i) Treat Warnign errors -> None
在此之后我将注册imageexport.dll与.net 2.0的regasm
现在当我查看注册表然后在HKEY_CLASSES_ROOT下我找到了imageexport.ExportImage.
现在在vbscript下面的代码用于创建对象并调用该函数
Dim obj
Set obj = CreateObject("imageexport.ExportImage")
obj.exportPNG rvPAWZDirectoryPath&"\","SVGData_"&Session("export_time")&".svg","Export_" & export_time & ".png"
但是这会在VBSCript的createObject行中给出名为'UnknownException'的异常.请告诉我问题出在哪里
我认为你应该将你的Dll注册为:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>regasm yourDllPath /codebase
Run Code Online (Sandbox Code Playgroud)
现在你可以创建你的Dll的对象了.
| 归档时间: |
|
| 查看次数: |
1146 次 |
| 最近记录: |