如何建立htmlHelpers的项目,使其产生两个DLL - 为MVC3和mvc4? [英] How to set up project of htmlHelpers so that it produces two dlls - for mvc3 and mvc4?

查看:87
本文介绍了如何建立htmlHelpers的项目,使其产生两个DLL - 为MVC3和mvc4?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有HTML辅助库作为一个单独的项目。现在它引用的 system.web.mvc 4版本。

如果我尝试在使用MVC3它抛出当助手被试图用一个错误的一个项目使用这个库:

 编译器错误信息:CS1705:大会'MyHtmlHelpers,版本= 3.7.4.0,文化=中立,公钥=空'使用'System.Web.Mvc,版本= 4.0.0.0,文化=中性公钥= 31bf3856ad364e35'具有更高的版本比引用的程序集'System.Web.Mvc,版本= 3.0.0.0,文化=中性公钥= 31bf3856ad364e35'

我明白,我需要建立,以便参考版本3 system.web.mvc 我的助手的项目为它与MVC3项目兼容。我不希望有相同的code两个项目,只是差 system.web.mvc 引用。

问题的称号。
任何帮助是AP preciated。


解决方案

  

我不希望有两个项目具有相同code只用
  system.web.mvc的差异引用。


您不一定需要以物理方式复制源代码code。你可能只是另一种的.csproj你的类库,将添加源$ C ​​$ C作为链接的文件,只替换的.csproj的System.Web.Mvc参考的版本。

来看看如何将标准的项目,如 JSON .NET 有其源$ C ​​$ C举办。它们支持从2.0 .NET的多个版本高达4.0,但源$ C ​​$ c是相同的。这是正在做这项工作的项目文件。

I have a library of html helpers as a separate project. Right now it references system.web.mvc of version 4.

If I try to use this library in a project that uses mvc3 it throws an error when a helper is attempted to be used:

Compiler Error Message: CS1705: Assembly 'MyHtmlHelpers, Version=3.7.4.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

I understand that I need to build my helpers project with system.web.mvc of version 3 referenced in order for it to be compatible with mvc3 project. I do not want to have two projects with the same code with just the difference of system.web.mvc referenced.

Question is in the title. Any help is appreciated.

解决方案

I do not want to have two projects with the same code with just the difference of system.web.mvc referenced.

You don't necessarily need to physically duplicate the source code. You could just have another .csproj for your class library which will add the source code as Linked Files and only replace the version of the System.Web.Mvc reference in the .csproj.

Take a look at how standard projects such as JSON.NET have their source code organized. They support multiple versions of .NET from 2.0 up to 4.0 and yet the source code is the same. It's the project files that are doing the job.

这篇关于如何建立htmlHelpers的项目,使其产生两个DLL - 为MVC3和mvc4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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