C#中的模块预计将包含汇编清单 [英] C# the module was expected to contain assembly manifest

查看:120
本文介绍了C#中的模块预计将包含汇编清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我是新来的C#的世界。我不得不使用它,因为在xceedzip.dll压缩数据从组播Feed中通过一个依赖。
黑客一起一些代码,用于接收进料后,我面临的一个障碍在调用此DLL。
从我的理解,我需要使用的System.Reflection并调用该DLL。

Hi I am new to the C# world. I am having to use it because of a dependency on xceedzip.dll compressed data coming through from a multicast feed. After hacking together some code for receiving the feed, I am facing a hurdle in invoking this dll. From what i understand i need to use the "System.Reflection" and invoke the dll.

目前我的源代码和DLL驻留在同一目录。该代码编译成功

Currently my source code and the dll reside in the same directory. The code compiles successfully.

Assembly ass = Assembly.Load("XceedZip");



我在运行时获得System.BadImageFormatException:
无法加载文件或程序集XceedZip 或它的依赖条件中的一个。该模块应包含清单的程序集。

I get the System.BadImageFormatException during runtime: Could not load file or assembly "XceedZip" or one of its dependecies. The module was expected to contain an assembly manifest.

请帮忙,谢谢

好吗感谢所有您的答复,我有以下加载到我的环境中TLBIMP命令的dll一个工作版本。我面临的解压方法签名的麻烦。我需要提供一个引用对象和出对象作为源(压缩)和目的地(未压缩)的对象。我试图加载字节数组到这些位置,但它抛出了我一个无效的参数错误。帮助的感谢参考对象和out对象......

alright thanks to all your responses, i have a working version of the dll following the tlbimp command loaded into my environment. i am facing trouble with the Uncompress method signature. I need to provide a "ref object" and a "out object" as source (compressed) and destination (uncompressed) objects. I tried loading byte arrays into these positions, but it throws me an invalid arguments error. Help on "ref object" and "out object" appreciated ...

问题解决了,感谢所有的

problem solved, thanks all

推荐答案

我怀疑这个DLL不是一个托管程序集,但包含本地​​代码。在的Assembly.Load 只应与管理组件中使用。如果你需要从非托管代码调用的函数,你可以使用的P / Invoke 。该过程涉及定义要调用非托管函数的托管包装

I suspect that this DLL is not a managed assembly but contains native code. The Assembly.Load should only be used with managed assemblies. If you need to invoke functions from unmanaged code you could use P/Invoke. The process involves in defining a managed wrapper for the unmanaged function that you want to invoke.

例如,如果你想调用的的MessageBox 本地函数(其实你永远不会需要做到这一点因为已经有一个管理相当,但它应该为这个演示的目的是罚款),你可以写一个包装:

For example if you wanted to invoke the MessageBox native function (actually you would never need to do this because there's already a managed equivalent, but it should be fine for the purpose of this demonstration) you could write a wrapper:

[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern MessageBoxResult MessageBox(IntPtr hWnd, String text, String caption, int options);



,然后调用它:

and then invoke it:

MessageBox(IntPtr.Zero, "Text", "Caption", 0);

您会做同样的事情,与包含在DLL中的非托管函数。您必须查看文档,看看具体的非托管签名,这将帮助你定义托管包装。

You will have to do the same thing with the unmanaged function that is contained inside the DLL. You will have to check the documentation to see the exact unmanaged signature which will help you define the managed wrapper.

这篇关于C#中的模块预计将包含汇编清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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