0

I have 3 Projects. A, B and X

Project X is a class library and holds my EntityFramework EDMX Database Model. Project X is referenced in Project A. I want to use Project A and Project X in Project B.

I found out that is a bit more complicated: I have 4 Projects. A, B, C and X

Project X is a class library and holds my EntityFramework EDMX Database Model. Project A is a Silverlight Project. Project B is a SilverlightApplication.Web Project. Project C is a class library project.

Project X is referenced in Project B. Project A has Project B as reference. Project B is auto generated in Project A. Project C should reference Project A, B and X.

Error Message: "The Type "ProjectX.Location" exists in both "D:\Projectgroup\ProjectA\bin\ProjectA.dll" and "D:\Projectgroup\ProjectX\bin\ProjectX.dll"

When I look in the auto generated code of project B in Project A, I see some classes of the DatabaseModel (edmx) of Project X, but not all, which are in the namespace of Project X.

4

3 回答 3

0

我认为您的问题是您在相同的名称空间中定义了两个具有相同名称但不同的程序集的不同类型。

例如,我在以下情况下提到了错误:

ClassLibrary1.Class1.cs (Assembly1)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
  public class Class1
  {
  }
}

ClassLibrary2.Class1.cs (Assembly2)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
  public class Class1
  {
  }
}

Program.cs (Assembly3)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ClassLibrary1;


namespace ConsoleApplication1
{
  class Program
  {
    static void Main(string[] args)
    {
        Class1 a;
    }
  }
}

在此处输入图像描述

因此,请确保您对不同的程序集没有相同的名称类型。

于 2013-10-10T14:08:34.607 回答
0

尝试使用extern Alias它允许您将程序集包装在由别名命名的根级命名空间中,这使它们能够在同一个文件中使用。尽管我建议您查看代码的结构,以便避免这种情况

于 2013-10-10T09:48:17.383 回答
0

在表单中引用相同的程序集

     /==>A==\
    /        \
    B=======> X

根本不是问题,也不应该导致任何错误或警告......只要通过两条路线的X身份相同。所以基本上确保你只有一个版本的 X。如果您没有启用强命名,这会更容易,但即使使用强命名,它也应该只是确保您的引用正确的情况。

于 2013-10-10T09:54:33.497 回答