C#Com组件注册后vbs和C#调用路径不一样
1、Com组件GetMapinFile()函数:
public string GetMapinFile()
{
return GetRootPath() + "\\Mapin\\mapin.tmp";
}
internal string GetRootPath()
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path1 = Uri.UnescapeDataString(uri.Path);
path1 = Path.GetDirectoryName(path1);
return path1;
}
2、VBS调用:
Dim oDemoCom
Set oDemoCom=CreateObject("LiveDataServiceLibrary.LiveDataService")
MsgBox(oDemoCom.GetMapinFile())
结果为:Dll注册时所在路径 (程序开发路径)C:\VisualStudio\LiveDataServiceLibrary\LiveDataServiceLibrary\bin\Debug\Mapin\mapin.tmp
Set oDemoCom=Nothing
3、C# 实例与调用接口:
LiveDataServiceLibrary.LiveDataService service = ( LiveDataServiceLibrary.LiveDataService)Microsoft.VisualBasic.Interaction.CreateObject("LiveDataServiceLibrary.LiveDataService");
string path=service.GetMapinFile();
结果为 :MapinFile:C:\Windows\assembly\GAC_32\LiveDataServiceLibrary\1.0.0.0__b0b041de91bf1bb2\Mapin\mapin.tmp
VBS调用与C# 实例调用 路径为什么不一样 ,为希望能得VBS调用的效果