我工作的软件公司为学校构建软件,因此我们的客户端计算机通常被锁定,导致我们几乎无法在其上安装任何东西.
The software company I'm working for builds software for schools, and so our client machines are usually locked down in such a way it makes it pretty impossible for us to install anything on it.
我们的旧系统主要基于一个(非常大的)MS Access 项目,因此它只需从本地文件夹运行即可解决访问问题.
Our old system is primarily based on a (very large) MS Access project and so it gets around the access problems by just running from a local folder.
我被赋予了将一些系统重新开发为 c# .NET 的任务 - 但是在过渡阶段,如果能够让 access 项目触发 .NET 事情,那就太好了.
I've been given the task of redeveloping some of the system into c# .NET - however it would be nice in the interim stages to have the ability to have the access project fire .NET things off.
我今天已经玩了几个小时的 com 互操作,但是使这些工作的唯一方法是使用 RegAsm.exe 注册它们 - 不幸的是,这不是客户端环境中的选项.
I have played around with com interops for a few hours today but afaik the only way to make these work is to register them with RegAsm.exe - and unfortunately this isn't an option in the client environments.
我尝试过 GetObject/CreateObject 但在引用 dll 或 tlb 文件时都不起作用,还有其他方法可以实现吗?
I've tried GetObject / CreateObject but neither work when referencing a dll or tlb file, is there any other way this could be achieved?
理想的解决方案是将 com interop dll 放在与 Access 项目相同的目录中.
The ideal solution would be to put the com interop dll in the same directory as the Access project.
是的,在任何人说之前,我就知道 MS Access 是邪恶的,只适合非常小的项目 - 但我 4 个月前才到这里......
And yes, before anyone says it, I know MS Access is evil and only suited for very small projects - but I only arrived here 4 months ago...
马龙
您可以在 Access 中托管 CLR:
You could host the CLR inside Access:
添加对 mscoree 的引用(可能是 C:WINDOWSMicrosoft.NETFrameworkv2.0.50727mscoree.tlb)
Add a reference to mscoree (Probably C:WINDOWSMicrosoft.NETFrameworkv2.0.50727mscoree.tlb)
Sub Main()
Dim CORHost As New mscoree.CorRuntimeHost
Dim Domain As Object
Dim AssemblyFilename As String
Dim Classname As String
Dim Result As Object
AssemblyFilename = "mscorlib"
Classname = "System.Collections.ArrayList"
CORHost.Start
CORHost.CurrentDomain Domain
Set Result = Domain.CreateInstance(AssemblyFilename, Classname).Unwrap()
Result.Add "test"
MsgBox Result.Count
End Sub
这绕过了使用注册表的需要.这样做的缺点是您必须对对象使用后期绑定.
This bypasses the need to use the registry. The down side of this is you have to use late binding with your objects.
您还可以添加对 mscorlib.tlb 的引用以获取 AppDomain 类和其他类的类型信息.
You can also add a reference to mscorlib.tlb to get type information for the AppDomain class and others.
这篇关于来自VB6的.NET对象而不使用regasm.exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!