在装配中定义的C#类未被引用 [英] C# type defined in an assembly that is not referenced

查看:168
本文介绍了在装配中定义的C#类未被引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个项目A和B.项目A利用项目B型的X,所以我在A.一切b的加成参考内置罚款。

I have two projects A and B. Project A makes use of type X in project B, so I have a reference to B added in A. Everything built fine.

我使用强命名的密钥文件签署B项目。一切都还是建立了良好的。

I signed project B using a strong named key file. Everything still built fine.

然后,我决定改变B.强命名的密钥文件我重建项目乙:你好。当我尝试建立项目AI收到的X型是在未引用的程序定义的错误错误1。你必须添加到程序集B的引用,版本= 1.0.0.0,文化=中性公钥= 95b41b0d6571627b。

Then I decided to change the strong named key file for B. I rebuilt project B ok. When I try to build project A I receive the error "Error 1 The type X is defined in an assembly that is not referenced. You must add a reference to assembly B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=95b41b0d6571627b'. "

所以我删除项目A中的参考和再次添加它放回,没有喜悦。我可以DBL点击项目一个项目1B参考,打开对象浏览器,看看X型在那里确定。我也完全有资格在一个X型的对象和智能感知把它们捡起来罚款,但它仍然没有建立。

So I deleted the reference in project A and added it back in again, no joy. I can dbl click on the project B reference in project A, open the object browser and see type X in there ok. I also fully qualified the type X objects in A and the intellisense picked them up fine but it still does not build.

我想改变密钥文件我可能需要向上修正,所以我改变程序集B版本2.0.0.0但仍抱怨说,它需要1.0版本。 0.0。望着在一个对B引用的属性绝对指向正确的版本,它确实显示为2.0.0.0

I thought that changing the key file I might need to up the revision, so I changed assembly B version to 2.0.0.0 but still A complains that it needs version 1.0.0.0. Looking at the properties of the B reference in A it definitely points to the correct version and indeed it shows as 2.0.0.0

我可以使用现有的密钥文件,但住我想明白的地方我错了,如果可能的。

I could live with using the existing key file but i'd like to understand where I am going wrong if possible.

推荐答案

根据你在评论中说,我会说这是最肯定的东西了项目A.

Based on what you said in the comments, I would say it's most definitely something up with Project A.

也许这些步骤将有助于解决这个问题:

Perhaps these steps will help fix it:


  1. 删除提及项目b,并保存

  2. 裂纹用记事本打开什么

  3. 的.csproj的文件,查找到任何引用在那里(也许hintpath节点)项目b和删除节点。

  4. 如果项目A恰好是一个ASP.NET项目,看在你的web.config或您的aspx页面页眉任何引用到b项目。

  1. Remove the reference to project B and save
  2. Crack open the .csproj file with notepad or something
  3. Look for any references to Project B in there (maybe a hintpath node) and remove the node.
  4. If Project A happens to be an ASP.NET project, look in your web.config or your aspx page headers for any references to Project B.

一旦删除该项目的所有引用,重新加载项目的瓶颈建议,看看能否解决适合你。

Once you remove all references to the project, reload the project as bottlenecked suggested and see if that fixes it for you.

这篇关于在装配中定义的C#类未被引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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