C#Com组件注册后vbs和C#调用路径不一样

xander.cc 2018-06-08 10:47:20
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调用的效果
...全文
721 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
SoulRed 2018-06-08
  • 打赏
  • 举报
回复
DLL放在自己程序目录下就好。 或者转换成绝对路径

110,561

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧