Infragistics NetAdvantage Vol.1在vs.net下的设置

刚刚接了一下公司内部的活儿,上一篇blog已经说过了,项目中使用了Infragistics NetAdvantage Vol.1的控件。在vs.net下进行开发时,发现每次都提示 Infragistics.WebUI.Shared.dll 找不到,然后就手动将Copy Local设置成True。

之前一直没有找为什么会这样,又不想张嘴就问同事,于是翻了一下帮助,Introduction/Setting Up Your Development Enviroment/ASP.NET: Setting CopyLocal To True中对该问题进行了说明,以下是为什么要这样做的原因:

The shared assembly is registered into the Global Assembly Cache by the Windows Forms products, but Web Applications, by default, do not look in the GAC to resolve assembly references at runtime. Therefore, the Infragistics.WebUI.Shared assembly must be copied to the local project directory along with the respective Web element's assembly in order to run the Web application under IIS.

提供了两种解决方法,一种是手动设置,一种是使用vs.net提供的宏(Macro),下面是宏的代码:

  1. Open Visual Studio .NET
  2. Open Macros Explorer window (Tools -> Macros Explorer)
  3. Right click MyMacros root node and select New Macro Project
  4. Open the Module within your new Macro project
  5. Open the EnvironmentEvents module
  6. Select BuildEvents from the Class Name drop down
  7. Select OnBuildBegin from the Event Name drop down
  8. Implement the OnBuildBegin event handler:

Private Sub BuildEvents_OnBuildBegin(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildBegin
    Dim s As Solution
    Dim p As Project
    Dim vs As VSProject
    Dim r As Reference
   
   
    s = DTE.Solution
   
    For Each p In s.Projects
        vs = p.Object
        For Each r In vs.References
            If Regex.IsMatch(r.Identity, "^Infragistics/.WebUI/.Shared.*") Then
                r.CopyLocal = True
                Exit For
            End If
        Next
    Next
End Sub

只使用以上代码也是不好用的,还要导入以下两个命名空间:

Imports VSLangProj
Imports System.Text.RegularExpressions

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值