关于vb.net中的.dll [英] Regarding .dll in vb.net

查看:86
本文介绍了关于vb.net中的.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在VB.NET中使用类库作为项目创建.AVI(视频)文件的.dll(动态链接库)?并在创建.dll之后如何从.dll中检索.AVI文件并使用Windows窗体应用程序中的Windows Media Player作为项目进行播放?

How to create .dll(Dynamic Link Library) of .AVI(video) file by using Class Library as a project in VB.NET ? and after creating .dll how to retrieve the .AVI file from the .dll and play using Windows Media Player in Windows Form Application as Project?

推荐答案

首先要了解的事情:.NET模块化的中心点是程序集,而DLL或EXE只是 modules (每个程序集可能有多个模块,Visual不直接支持Studio),组装之间几乎没有区别,只有EXE有入口点方法。



要生成图书馆,请转到应用程序属性,并将输出类型更改为类库。要使用库,添加对程序集的引用以使用它,添加引用窗口将显示所有选项,但最好的方法是将两个项目放在同一解决方案中并使用项目选项卡。如果通过引用项目引用,则将以适当的方式自动创建程序集之间的引用。好处是:如果您在引用的项目中更改某些内容,比如重新定位输出,更改数字签名,解决方案构建将轻松解决它,如果您通过输出模块文件名引用则不是这种情况。



现在,关于播放AVI:我不会让它复杂化。更好地存储AVI文件,就像在临时目录中一样( https://msdn.microsoft.com/en-us/library/system.io.path.gettempfilename%28v=vs.110%29.aspx [ ^ ]),和然后与玩家一起玩:

https://msdn.microsoft.com/en-us/library/system.windows.media.mediaplayer%28v=vs.110%29.aspx [ ^ ] ,

https://msdn.microsoft .com / zh-CN / library / bb383953%28v = vs.90%29.aspx [ ^ ],

https://msdn.microsoft.com/en-us/library/windows/desktop/dd562692 %28v = vs.85%29.aspx [ ^ ]。



另请参阅此CodeProject文章:媒体播放器类 [ ^ ]。



您的库程序集可以使用方法将内容复制到临时文件并返回文件名;引用程序集可以播放此文件,然后删除文件。



您也可以从内存中播放,但实现起来会更难,更重要的是,文件可能太大了。



-SA
First thing to understand: central point of .NET modularity is assembly, and DLL or EXE are just modules (it's possible to have more than one module per assembly, which is not directly supported by Visual Studio), and there is little difference between the assembly, only an EXE has entry point method.

To produce a library, go to the application properties, and change "Output type" to "Class Library". To use the library, add a reference to your assembly to use it, the "Add Reference" window will show you all the option, but the best method is to put two projects in the same solution and use "Projects" tab. If you reference by referencing a project, the reference between assemblies will be created automatically in proper way. The benefit is: if you change something in the referenced project, say, relocated the output, change digital signature, the solution build will resolve it painlessly, which is not the case if you reference by the output module file name.

Now, as to playing AVI: I would not complicate it. Better store the AVI file as is in the temporary directory (https://msdn.microsoft.com/en-us/library/system.io.path.gettempfilename%28v=vs.110%29.aspx[^]), and then play it with the player:
https://msdn.microsoft.com/en-us/library/system.windows.media.mediaplayer%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/bb383953%28v=vs.90%29.aspx[^],
https://msdn.microsoft.com/en-us/library/windows/desktop/dd562692%28v=vs.85%29.aspx[^].

See also this CodeProject article: Media Player Class[^].

Your library assembly could have the method to copy the content into a temporary file and return you the file name; the referencing assembly could play this file and later remove the file.

You can play from memory, too, but it would be harder to implement and, importantly, the file could be too big for that.

—SA


这篇关于关于vb.net中的.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆