标签:interop com-interop c vba excel-vba
我所拥有的是一个Excel 2010 VBA客户端正在使用的C#.NET 4.5 ComVisible(true)库.
我有两个问题:
1-
在VBA中,当我从“工具->引用”添加对tlb的引用时,出现“可用引用”对话框,该对话框将库引用名称显示为与.tlb文件相同的名称,但没有扩展名.如果我的.tlb文件有空格,那么它将在对话框中替换为下划线.
以下线程讨论了类似的问题,但是从VBA项目的角度来看:
How can I put spaces in my VBA project name?
From my C# project, how can I control the name that will appear in “Available References”
(including using spaces)?
2-
关于我的库的名称空间,如何选择一个独立于我的引用名称和.tlb名称的名称空间?例如:
Dim oMyTest As New MyCustomNameSpace.MyTest
我已经在C#中尝试了以下方法,但是它没有用,它总是选择.tlb文件名作为名称空间:
[ProgId("MyCustomNameSpace.MyTest")]
public class MyTest: IMyTest
What do I need to change in C# to control my namespace within VBA?
解决方法:
在MSDN Library section中详细描述了从程序集到类型库的转换.“导出的程序集转换”文章提供了您要询问的相关详细信息.引用它们:
Assembly names often contain periods, which are not permitted in type library names. The export process converts periods in the name field of an assembly to underscores.
The export process copies the AssemblyDescriptionAttribute if applied to an assembly at design time, to the helpstring or DocString associated with a type library. Neither the HelpFile field nor the HelpContext field in the type library is set. None of the LIBFLAGS in the type library is set.
请注意,默认情况下,ASsemblyInfo.cs中的[assembly:AssemblyDescription]属性使用空字符串.您可以直接对其进行编辑,也可以使用“项目属性”,“应用程序”选项卡,“装配信息”按钮.
标签:interop,com-interop,c,vba,excel-vba 来源: https://codeday.me/bug/20191031/1978017.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。