none
报错:合并程序集时出错,可能是因为两个程序集之间存在循环依赖项

    Pertanyaan

  • 很简单得几段代码,但是这种报错,很无解....
    我自己经过几次测试,估计是不是泛型LIst<T>没用好,因为我把类文件2中的泛型去除就没报错了。仅供参考。

    注:本人对泛型不是很熟悉,但是理论上应该没写错,如果不采用web deployment project 进行编译,则页面正常运行。一旦采用web deployment把
    几个dll,合并就出问题。

    报错原文:
    错误 1 
    合并程序集时出错,可能是因为两个程序集之间存在循环依赖项。报告的错误为: ILMerge.Merge: The assembly 'App_WebReferences' was not merged in correctly. It is still listed as an external reference in the target assembly. 
    aspnet_merge 1 1 DisSun2012_01_12_deploy

    大家看看我的几段源码吧,很简单

    文件结构:

     

    类文件1:myCrmService.cs

    using 省略若干...
    using CrmServiceWsdl_cmk;   //这个是crmWebService
    using System.Web.Configuration;
    
    namespace cmkCode
    {
        /// <summary>
        ///myCrmService 的摘要说明
        /// </summary>
        public static class myCrmService
        {
    
    
            private static string _crmHost = WebConfigurationManager.AppSettings["CrmHost"];
            private static string _crmPort = WebConfigurationManager.AppSettings["WebServicePort"];
            private static string _crmOrganizationName = WebConfigurationManager.AppSettings["OrganizationName"];
    
            public static CrmService makeMyService()
            {
                CrmAuthenticationToken token = new CrmAuthenticationToken();
                token.AuthenticationType = 0;
                token.OrganizationName = _crmOrganizationName;
    
                CrmService service = new CrmService();
                service.Url = string.Format("{0}:{1}/mscrmservices/2007/crmservice.asmx", _crmHost, _crmPort);
                service.CrmAuthenticationTokenValue = token;
                service.Credentials = System.Net.CredentialCache.DefaultCredentials;
    
                return service;
            }
    
    
        }
    }
    

    类文件2:myMultipleResponse.cs

    using 省略若干
    using System.Collections.Generic;
    using CrmServiceWsdl_cmk;
    
    
    namespace cmkCode
    {
        /// <summary>
        ///返回搜索到的所有实体实例
        /// </summary>
        public static class myMultipleResponse<T> where T : BusinessEntity
        {
            public static List<T> searchMyResponse( QueryExpression query)
            {
                RetrieveMultipleRequest request = new RetrieveMultipleRequest();
                request.Query = query;
                
                RetrieveMultipleResponse response = (RetrieveMultipleResponse)myCrmService.makeMyService().Execute(request);
    
                List<T> myEntitiesList = new List<T>();
    
                for (int x = 0; x < response.BusinessEntityCollection.BusinessEntities.Length; x++)
                {
                    if (response.BusinessEntityCollection.BusinessEntities[x] != null)
                    {
                        T subBus = (T)response.BusinessEntityCollection.BusinessEntities[x];
                        myEntitiesList.Add(subBus);
                    }
    
                }
                return myEntitiesList;
    
            }
        }
    }

    网页文件3:Default.aspx.cs

    using CrmServiceWsdl_cmk;
    using cmkCode;
    
    public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            CrmService aaa = myCrmService.makeMyService();
        }
    }
    



    14 Januari 2012 8:05

Semua Balasan