重新分配参考程序集 [英] Redistribution of Reference Assemblies

查看:69
本文介绍了重新分配参考程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个使用CSharpCodeProvider即时生成和编译代码的应用程序.编译后的代码使用Entityframework,因此我们将对Entityframework.dll的引用传递给编译器.我们重新分发的Entityframework.dll 我们的应用程序是为.net 4.0构建的.我们还将对System.ComponenModel.DataAnnotations.dll的引用传递给编译器.这是对GAC中发现的dll的引用.

We have an application that generates and compiles code on the fly using CSharpCodeProvider. The code that gets compiled uses Entityframework, so we pass a reference to Entityframework.dll to the compiler. The Entityframework.dll, which we redistribute with our application, is the one built for .net 4.0. We also pass a reference to System.ComponenModel.DataAnnotations.dll to the compiler. This is a reference to the dll found in the GAC.

在.net 4.0上运行应用程序时,所有这些都可以正常工作.但是,在.net 4.5上运行时,我们遇到了一个问题,因为.net 4.0中Entityframework中的某些属性已移至.net 4.5中的System.ComponenModel.DataAnnotations.所以我们 得到这样的错误:

All this works fine when running the application on .net 4.0. However, when running on .net 4.5 we get an issue, since some attributes that were in Entityframework in .net 4.0 have been moved to System.ComponenModel.DataAnnotations in .net 4.5. So we get errors like this:

Message=Error (CS0246): The type or namespace name 'Column' could not be found (are you missing a using directive or an assembly reference?) - file: c:\Generated\DataContext\0rs2sztj.2.cs:14
Error (CS0433): The type 'System.ComponentModel.DataAnnotations.Schema.ColumnAttribute' exists in both 'c:\Users\Steven Segers\AppData\Local\Temp\Temporary ASP.NET Files\vs\69fafaea\17b01629\assembly\dl3\95fc97d4\5bdae37d_7c05d101\EntityFramework.DLL' and 'c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll' - file: c:\Generated\DataContext\0rs2sztj.2.cs:14

据我所知,有两种解决方法:

As far as I can see there are two ways out of this:

  1. 将.net 4.0的System.ComponenModel.DataAnnotations的引用程序集传递给编译器.这里的问题是该参考组件需要存在于目标机器上.为了适应这一点,我们要么要求客户 在其服务器上安装Windows SDK或将引用程序集与我们的应用程序一起分发.我发现前者是一个相当不可取的要求,我不确定后者是否允许.
  2. 确保我们将面向运行时.net版本的Entityframework.dll传递给编译器.我不确定实现此目标的最佳方法是什么.
  1. Pass the reference assembly of System.ComponenModel.DataAnnotations for .net 4.0 to the compiler. Problem here is that this reference assembly needs to be present on the target machine. To accommodate this we need to either require the customer to install the Windows SDK on his server or distribute the reference assemblies with our application. I find the former a rather undesirable requirement, and I'm not sure if the latter is allowed.
  2. Make sure we pass the Entityframework.dll that targets the runtime .net version to the compiler. I'm not sure what would be the best way to accomplish this.

推荐答案

您好,史蒂芬·塞格斯(Steven Segers),

Hi Steven Segers,

>>>>>>><

>>"The code that gets compiled uses Entityframework"

该问题与实体框架有关.因此,我认为这("确保我们将面向运行时.net版本的Entityframework.dll传递给编译器.")是实现此目标的最佳方法.请确保您的版本 实体框架可以支持.NET Framework 4.5.

The issue is related to Entity Framework. So I think this("Make sure we pass the Entityframework.dll that targets the runtime .net version to the compiler. ." ) is the best way to accomplish this. Please make sure the version of your Entity Framework could supports .NET Framework 4.5.

最好的问候,
王丽

Best Regards,
Li Wang


这篇关于重新分配参考程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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