当前位置:编程学习 > C#/ASP.NET >>

.net4.0环境如何调用.net2.0编译的DLL?

在.NET 4.0环境下用MagickNet.DLL做缩略图 报错

"混合模式程序集是针对"V2.0.50727"版的运行时生成,在没有被指其他信息的情况下,无法在4.0运行时中加载该程序集"

看了网上改app.config 的方法
但是我的app.config原内容和教程上要改的完全一样 不需要修改

<?xml version ="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>
        <supportedRuntime version="v4.0" sku="client" />
    </startup>
</configuration>


求高人赐教啊
或者给个4.0环境下编译的MagickNet.DLL
不胜感激! --------------------编程问答-------------------- 我今天也遇到一个问题:
我用Winform里调用一个C++写的dll,三个函数签名为:
        [DllImport("User32.dll")]
        public static extern int MessageBox(int h, string m, string c, int type);
        [DllImport("DLL.dll")]
        public static extern void MyBox();
        [DllImport("DLL1.dll")]
        public static extern void MyBox(int iNum);
如果在.net3.5下,一切都正常.
如果以.net4.0来运行,前两个方法没问题,最后一个死法报错:
'MyBox' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

这几个方法是专门用来测试的,我是要在WPF(.net4.0)下调用C++写的函数.
现在我有个想法就是在WPF(.net4.0)调用.net3.5下的方法abc(),再用abc()调用C++的函数,
在此解决这个问题,你这个问题如果解决了,我的问题也可能多一个方案了。 --------------------编程问答-------------------- 如果以.net4.0来运行,前两个方法没问题,最后一个死活报错 --------------------编程问答-------------------- 我也遇到了这个问题。WPF调用C++的,麻烦解决了告诉我一下啊 --------------------编程问答--------------------   <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" />
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="XXX" publicKeyToken="32ab4ba45e0a69a1" culture="neutral"/>
        <codeBase version="v2.0.50727" href="XXX.dll"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
我的解决了,这样可以 --------------------编程问答-------------------- 实在不行就把你的程序用2.0来编译吧 --------------------编程问答--------------------
引用 1 楼 ywtywt337 的回复:
我今天也遇到一个问题:
我用Winform里调用一个C++写的dll,三个函数签名为:
        [DllImport("User32.dll")]
        public static extern int MessageBox(int h, string m, string c, int type);
        [DllImport("DLL.dll")]
   ……


托管代码是否是x64,非托管代码是否为x86 --------------------编程问答-------------------- 我想用MagickNet.DLL 将PDF图片转化成其他格式的图片进行处理,有办法吗?
请赐教
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,