混合模式程序集是针对运行时的版本"v2.0.50727"构建的,无法在4.0运行时中加载-研究的解决方案不起作用 [英] Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime - Researched solutions not working

查看:89
本文介绍了混合模式程序集是针对运行时的版本"v2.0.50727"构建的,无法在4.0运行时中加载-研究的解决方案不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的完整错误:

Error in Microsoft.SqlServer.Dts.Runtime.TaskHost  
The Execute method on the task returned error code 0x80131621 (Mixed 
mode assembly is built against version 'v2.0.50727' of the 
runtime and cannot be loaded in the 4.0 runtime without 
additional configuration information.  The Execute method must succeed,
and indicate the result using an "out" parameter.

我找到了可能的解决方案此处,但是仍然出现上述错误.

I have found possible solutions here and here however I am still getting the above error.

以下是我的表单代码:

private void button1_Click(object sender, EventArgs e)
    {
        string pkgLocation;
        Package pkg;
        Microsoft.SqlServer.Dts.Runtime.Application app;
        DTSExecResult pkgResults;

        MyEventListener eventListener = new MyEventListener();

        pkgLocation =
          @"C:\FilePath.dtsx";

        app = new Microsoft.SqlServer.Dts.Runtime.Application();
        pkg = app.LoadPackage(pkgLocation, eventListener);
        pkgResults = pkg.Execute(null, null, eventListener, null, null);

        MessageBox.Show(pkgResults.ToString());

    }

    class MyEventListener : DefaultEvents
    {
        public override bool OnError(DtsObject source, int errorCode, string subComponent,
          string description, string helpFile, int helpContext, string idofInterfaceWithError)
        {
            // Add application-specific diagnostics here.
            MessageBox.Show("Error in " + "/t" + source + "/t" + subComponent + "/t" + description);
            return false;
        }
    }

以下是我的app.config标记:

The following is my app.config markup:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    <supportedRuntime version="v2.0.50727" />
  </startup>
  </configuration>

为什么以前研究过的解决方案对我不起作用?他们推销了很多票,我推断这些票已经为许多其他用户使用.

Why are the previous researched solutions not working for me? They have lots of upvotes which I deduce have worked for a lot of other users.

推荐答案

找到答案命中属性->编译->高级编译选项...->生成序列化程序集是一个下拉菜单"

成功了!

这篇关于混合模式程序集是针对运行时的版本"v2.0.50727"构建的,无法在4.0运行时中加载-研究的解决方案不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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