简体   繁体   English

该类型在未引用的程序集中定义

[英]The type is defined in an assembly that is not referenced

I've just begun incorporating a few projects from a partner office's solution into our solution. 我刚刚开始将合作伙伴办公室解决方案中的一些项目纳入我们的解决方案中。 The program is a C# winform application. 该程序是一个C#winform应用程序。

The program compiled and everything was going fine, but then yesterday I went to build again and out of nowhere it threw an error "The type 'Namespace.MainFrameDisplay' is defined in an assembly that is not referenced. You must add a reference to assembly 'OtherAssembly, Version=1.7.0.0, Culture=neutral, PublicKeyToken=52af1880d3cd7291" (As far as I can tell, OtherAssembly isn't used as a reference in the original project. There are compatibility issues between Assembly and OtherAssembly, adding OtherAssembly nets about 100 errors.) 该程序已编译,一切正常,但是昨天我又去构建,它无处不抛出错误“在未引用的程序集中定义了'Namespace.MainFrameDisplay'类型。您必须添加对程序集的引用'OtherAssembly,版本= 1.7.0.0,文化=中性,PublicKeyToken = 52af1880d3cd7291” (据我所知,OtherAssembly在原始项目中未用作参考。Assembly与OtherAssembly之间存在兼容性问题,添加了OtherAssembly网络大约100个错误。)

As well as a related error "Cannot implicitly convert type 'Namespace.MainFrameDisplay' to 'Namespace.MainFrameDisplay' [c:\\Dev\\program\\bin\\debug\\Assembly.dll] 以及相关的错误“无法将类型'Namespace.MainFrameDisplay'隐式转换为'Namespace.MainFrameDisplay'[c:\\ Dev \\ program \\ bin \\ debug \\ Assembly.dll]

A snippet of psuedo-code for the error is: 该错误的伪代码片段为:

private MainFrameDisplay _MainFrame;  //definition
_MainFrame = this.Mainframe;  // error is thrown here
_MainFrame.Parent.Controls.Add(_NotifyBar);

If I delete the definition, the error remains. 如果删除定义,则错误仍然存​​在。
If I take out the line where the error is thrown, it compiles fine. 如果我删除引发错误的行,则可以正常编译。 Even with calling the _MainFrame.Parent. 即使调用_MainFrame.Parent。

I've gone so far as to delete/remove this troublesome project and unzip/add a new copy of the original, but the problem remains. 我已经尽力删除/删除这个麻烦的项目并解压缩/添加原始文件的新副本,但是问题仍然存在。 Any thoughts, suggestions? 有什么想法,建议吗?

Well........... Of course I figured this out right after posting. 好吧...........我当然是在发帖后才想到的。

( -_- ) (-_-)

So let's call this a tip for posterity. 因此,我们称其为后代技​​巧。

In the code above, "this" references a base class, which is one of the other projects that I'm bringing into our solution. 在上面的代码中,“ this”引用一个基类,这是我要引入我们的解决方案的其他项目之一。 I compared the references of the original base class project to my version, and sure enough I had accidentally included a Reference to "OtherAssembly" rather than "Assembly." 我将原始基类项目的引用与我的版本进行了比较,并确定我偶然地包含了对“ OtherAssembly”而不是“ Assembly”的引用。 (Their real names are very similar.) (他们的真实姓名非常相似。)

The incorrect reference didn't cause any problems in the base class, but caused a conflict in the derived class. 错误的引用不会在基类中引起任何问题,但是会在派生类中引起冲突。 Switched, fixed, compiled successfully. 切换,修复,编译成功。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型“ MailAddress”在未引用的程序集中定义 - The type 'MailAddress' is defined in an assembly that is not referenced “DateTime”类型是在未引用的程序集中定义的? - The type 'DateTime' is defined in an assembly that is not referenced? 在未引用的程序集中定义了“电子邮件”类型 - The type 'EMail' is defined in an assembly that is not referenced 类型“IdentityUser”在未引用的程序集中定义 - The type 'IdentityUser' is defined in an assembly that is not referenced 类型“HttpResponseMessage”是在未引用的程序集中定义的 - The type 'HttpResponseMessage' is defined in an assembly that is not referenced 类型“IEnumerable&lt;&gt;”是在未引用的程序集中定义的 - The type 'IEnumerable<>' is defined in an assembly that is not referenced &#39;Nullable&lt;&gt;&#39; 类型在未引用的程序集中定义 - The type 'Nullable<>' is defined in an assembly that is not referenced 在未引用的程序集中定义了“ Expando”类型 - The type 'Expando' is defined in an assembly that is not referenced 类型“IUnityContainer”在未引用的程序集中定义 - The type 'IUnityContainer' is defined in an assembly that is not referenced 偶发错误:类型&#39;HttpRequestMessage&#39;在未引用的程序集中定义 - Occasional error: The type 'HttpRequestMessage' is defined in an assembly that is not referenced
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM