English 中文(简体)
如何 C#在没有登记的情况下使用遗产DL(regsvr32)
原标题:How can C# use a legacy DLL simply without registration(regsvr32)

Situation
I run a build system that executes many builds for many project. To avoid one build impacting another we lock down the build user to only its workspace. Builds run as a non privileged users who only have write ability to the workspace.

Challenge
During our new build we need to use a legacy 3rdparty DLL that exposes its interface through COM. The dev team wants to register the build(regsrv32.exe) but our build security regime blocks this activity. If we relax the regime then the 3rdparty DLL will impact other builds and if I have two build which need two different versions I may have the wrong build compile against the wrong version (a very real possibility).

Question
Are there any other options besides registration to handle legacy DLLs which expose their interface via COM?

感谢援助

Peter

最佳回答

这里的无注册股份行走:

And excruciating detail here: http://msdn.microsoft.com/en-us/library/aa376414 (the root of that document is actually here: http://msdn.microsoft.com/en-us/library/dd408052 )

此外,对于总体建筑而言,你应当能够利用Tlbimp或tlbexp,创建你可以用于建筑的TLB档案,假定登记点只是能够成功汇编,而不是进行具体测试。

问题回答

我对类似问题的原始答复见:TFS。 建筑服务器和COM参考资料——这项工作吗?

汇编好的方法。 NET代码表示,没有在建筑服务器上登记COM部件的参考资料是将<代码>COMFileReference查询项目列入贵项目/布ild文档,而不是COMReference/code>。 ACOMFileReference 页: 1

<ItemGroup>
  <COMFileReference Include="MyComLibrary.dll">
    <EmbedInteropTypes>True</EmbedInteropTypes>
  </COMFileReference>
</ItemGroup>

由于视觉演播室没有为<代码>COMFileReference提供设计员支持,你必须手提项目/造文档。

在建房期间,MSBuild从COM DLL中提取了哪类图书馆信息,并创建了一个能够独立或包含在电话中的联席会。 NET组件。

每个<代码>COMFileReference项目也可有WrapperTool属性,但缺省似乎只为我工作。 <代码>Embed InteropTypes Depende>没有记载可适用于COMFileReference,但似乎正在按预期开展工作。

See https://learn.microsoft.com/en-ca/visualstudio/msbuild/common-msbuild-project-items#comfilereference for a little more detail. This MSBuild item has been available since .NET 3.5.

It s a shame that no-one seems to know anything about this technique, which to me seems simpler than the alternatives. It s actually not surprising since I could only find just the one above reference to it on-line. I myself discovered this technique by digging into MSBuild s Microsoft.Common.targets file.

安装工具,如Installshield,可以从DLLs中提取COM接口,并将其添加到登记处。 它还可以使用DL的自我登记程序(我认为是监察员的做法),但这不是一个。 微软安装最佳做法

页: 1 NET COM通常是在Interop进行注册。 DL, in .NET, they are known Assembly and that can be made several ways. by Add reference through VS IDE at the project level, or written Code that Loads and unloads the Assembly. by .Config file that haas the reference to the Assembly and the use of that reference within the Project... GAC.

  • If you have access to the 3rd party .DLL s you can GAC them, and reference them in your project
  • you can add a using to your .cs file header as well as add the reference to the project by right clicking on reference --> add Reference ...
  • you can also do the above step as well as set the copy local = true in the properties for that .dll.. I hope that this gives you some ideas.. keep in mind that .NET assemblies are Managed code so there are several ways to Consume those 3rd party .DLL s using other methods within C# like LoadFromAssembly ect..

感谢一切帮助。

我们从早期约束变为过时约束,因为我们从来没有在编纂时真正需要《刑法》。 这就把登记要求从建筑服务器推向一体化测试服务器(我们在那里安装了处理登记工作的安装器)。 我们努力使建筑系统处于 p状态,并建立了易于重建的一体化体系。

Thanks again Peter





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签