我们正在开发一个需要屏幕“录制”的C#WPF(.Net 4.0)应用程序。我们已经评估了ByteScout的Screen Capture SDK(免费试用),它完全符合我们的需要。
然而,问题是我们的应用程序旨在由ClickOnce部署到我们客户的计算机(不在我们的网络上),并且可能以有限的非管理用户身份登录。 SDK具有可再发行组件,但这需要单独安装 - 对ClickOnce没有好处。
ByteScout似乎在其文档中的“免注册部署”部分中解决了这一需求:
/*
* REGISTRRATION FREE SCENARIO DEPLOYMENT: allows to just copy DLLs from the SDK without installing them
* See SAMPLE.EXE.manfest as the sample.
* 1) Rename "SAMPLE.EXE.manifest" into the actual application name (e.g. "MyApp.exe.manifest")
* 2) Edit this .manifest file and replace "SAMPLE.EXE" with your application name (e.g. "MyApp.exe")
* 3) Copy put this .manifest file into the same folder where your MyApp.exe is located
* 4) Copy all dlls from /x86/ folder into the same folder as your application
* So you will have files in the folder:
* - MyApp.exe
* - MyApp.exe.manifest
* - BytescoutVideoMixerFilter.dll
* - BytescoutScreenCapturingFilter.dll
* - BytescoutScreenCapturing.dll
* 5) Now you should be able run MyApp.exe without Screen Capturing SDK installed
所以:我创建了一个app.manifest
文件 - 我的项目之前没有或者需要一个 - 并在上面提到的SAMPLE.EXE.manifest中添加了以下内容:
<file name="BytescoutScreenCapturing.dll">
<comClass
description="Capturer Class"
clsid="{48967118-C4C9-435C-94D8-001247B9A52A}"
threadingModel="Apartment"
progid="BytescoutScreenCapturing.Capturer"
tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}" />
<comClass
description="C:\Documents and Settings\Administrator\My Documents\Capture From Entire Screen\bin\Debug\BytescoutScreenCapturing.dll"
clsid="{DCAFCA37-546E-4D0A-9C02-D3221E65FCA9}"
threadingModel="Both" />
<typelib tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}"
version="1.0"
helpdir="C:\Documents and Settings\Administrator\My Documents\Capture From Entire Screen\bin\Debug\" />
</file>
<comInterfaceExternalProxyStub
name="ICapturer"
iid="{DCAFCA37-546E-4D0A-9C02-D3221E65FCA9}"
proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
baseInterface="{00000000-0000-0000-C000-000000000046}"
tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}" />
<comInterfaceExternalProxyStub
name="IVideoWMVSettings"
iid="{1A814EC2-55A9-4FA2-99E2-2C20A897C2E7}"
proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
baseInterface="{00000000-0000-0000-C000-000000000046}"
tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}" />
<file name="BytescoutScreenCapturingFilter.dll">
<comClass
description="Bytescout Screen Capturing Filter"
clsid="{0F5D4CE4-2166-4FF7-9AA1-91330D35978A}"
threadingModel="Both" />
<comClass
description="Screen Capturing Property Page"
clsid="{22DD33B0-30C4-420D-A955-844E2B85A1F3}"
threadingModel="Both" />
<comClass
description="Screen Capturing Property Page"
clsid="{9D153AAA-0477-4C2E-B827-211F10561B44}"
threadingModel="Both" />
<comClass
description="Screen Capturing Property Page"
clsid="{26882CF7-F62F-47DB-9A3C-D1191591BD04}"
threadingModel="Both" />
</file>
<file name="BytescoutVideoMixerFilter.dll">
<comClass
description="Bytescout Video Mixer Filter"
clsid="{4407F28D-97C2-41C5-A23F-2FAE465CE7BB}"
threadingModel="Both" />
</file>
所以我的应用程序现在有:
BytescoutScreenCapturingLib
的引用,其中“嵌入互操作类型”设置为“True”BytescoutScreenCapturing.dll
,BytescoutScreenCapturingFilter.dll
和BytescoutVideoMixerFilter.dll
作为“内容”添加到项目中,“复制到输出目录”设置为“始终复制”app.manifest
文件。项目构建正常,但是当我现在运行它时,应用程序崩溃了。查看事件查看器,我看到错误:
Activation context generation failed for "myapp.exe.Manifest".
Error in manifest or policy file "myapp.exe.Manifest" on line 89. The value "" of attribute "resourceid" in element "typelib" is invalid.
Bytescout也有一个示例控制台应用程序,我遇到了同样的问题:项目构建正常,但它失败并出现上述错误。我尝试过他们的支持,但除了“尝试阅读文档”之外,我没有得到太多回应。
我尝试过“自我注册”COM组件;我没有太多(或实际上,任何)使用COM的经验,但我尝试过的所有示例代码似乎都没有(A)工作,(B)没有管理员权限或(C)两者都工作。我不确定它是否可以在我的场景中起作用。
有人可以建议如何继续吗?我们所需要的只是“注册”并可在我的代码中使用的DLL,而无需安装它们。
编辑:如果我编辑生成的myapp.exe.Manifest
文件,并将“resourceID”设置为“1”,则会出现进一步的错误:
Activation context generation failed for "myapp.exe.Manifest".
Error in manifest or policy file "myapp.exe.Manifest" on line 103. The value "" of attribute "tlbid" in element "comClass" is invalid.
如果我从项目中删除app.manifest
文件,并将参考DLL上的Isolated
设置设置为True
,则启动时的错误将更改为:
Activation context generation failed for "myapp.exe.Manifest".
Dll redirector contributor unable to add file map entry for file BytescoutScreenCapturing.dll; Two or more components referenced directly or indirectly by the application manifest have files by the same name.