简体   繁体   English

当引用或使用指令中包含“类型或名称空间'名称'时丢失”

[英]“The type or namespace 'name' is missing” when it is included in references and using directives

I have a very weird problem. 我有一个很奇怪的问题。 I am developing a Sharepoint 2013 Project which consists of a WebPart and a couple of Lists. 我正在开发一个Sharepoint 2013项目,其中包括一个WebPart和几个列表。 I am using a DateTimeControl in the WebPart. 我在WebPart中使用DateTimeControl。 I moved the WebPart into another project yesterday. 昨天,我将WebPart移到了另一个项目中。 After I moved it, I got an error that stated "The type or namespace DateTimeControl cannot be found in the namespace 'Microsoft.Sharepoint.WebControls'...". 移动它后,出现错误消息“在名称空间'Microsoft.Sharepoint.WebControls'...中找不到类型或名称空间DateTimeControl”。 So I checked my using directives and my references. 因此,我检查了我的using指令和引用。 The supposedly missing namespace is definitely there. 所谓的缺少名称空间肯定存在。 I even inspected it to check if DateTimeControl was inside it, which it was. 我什至检查了它以检查DateTimeControl是否在其中。 The architecture of both projects is also the same. 两个项目的架构也相同。

Am I missing something here? 我在这里想念什么吗?

ADD: I tried adding a new WebPart with an DateTimeControl on it. 添加:我尝试添加带有DateTimeControl的新WebPart。 I still get the same error. 我仍然遇到相同的错误。 When I add another control from the same namespace, I get no errors. 当我从同一名称空间添加另一个控件时,没有任何错误。 Only with DateTimeControl. 仅适用于DateTimeControl。

Make sure both projects are compiled against the same .Net Framework. 确保两个项目均针对相同的.Net Framework进行编译。 If you WebPart project that is referencing your DateTimeControl is compiled at a lower .Net Framework than your DateTimeControl then you will get this error. 如果引用DateTimeControl WebPart项目是在比DateTimeControl更低的.Net Framework上编译的,则将收到此错误。

In esseense make sure they are compiled at the same .Net Framework, or referenced libraries are compiled at a lower .Net Framework 最好确保它们是在相同的.Net Framework上编译的,或者确保引用的库是在较低的.Net Framework上编译的。

Ok I found the problem. 好的,我发现了问题。 This is a more Sharepoint-specific error. 这是一个特定于SharePoint的错误。

It seems that you cannot use the control in the namespace "Microsoft.Sharepoint.WebControls" if you are working on a sandbox solution. 如果您正在使用沙箱解决方案,则似乎无法使用名称空间“ Microsoft.Sharepoint.WebControls”中的控件。 I don't really understand Microsoft's reasons behind this, but it has to do with farm solutions being run under the farm administrator account, sandbox solutions don't do this. 我真的不了解Microsoft背后原因的原因,但是这与在场管理员帐户下运行场解决方案有关,沙盒解决方案却没有这样做。

So when I set the project's "Sandboxed Solution" property to false, the error was gone. 因此,当我将项目的“沙盒解决方案”属性设置为false时,错误消失了。 My colleague could confirm this behavior on his machine too. 我的同事也可以在他的机器上确认这种行为。

暂无
暂无

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

相关问题 缺少程序集引用和/或指令“找不到类型或命名空间名称” - Missing assembly references and/or directives “The type or namespace name could not be found” 缺少类型或命名空间名称 - Missing type or namespace name 命名空间“Windows”中不存在类型或命名空间名称“存储”(您是否缺少任何程序集引用?) - The Type or namespace name 'Storage' does not exist in the namespace 'Windows'(are you missing any assembly references ?) 找不到类型或名称空间名称(缺少使用指令或程序集引用吗?) - Type or namespace name could not be found (missing using directive or assembly reference?) msbuild 失败,缺少类型或命名空间名称 - msbuild fails with type or namespace name missing 命名空间中不存在类型或命名空间名称(您是否缺少程序集引用?) - The type or namespace name does not exist in the namespace (are you missing an assembly reference?) 类型或名称空间名称在名称空间中不存在“是否缺少程序集引用?” - The type or namespace name does not exist in the namespace ''are you missing an assembly reference ?" 找不到类型或名称空间名称“ My_Interface_Name”(您是否缺少using指令或程序集引用?) - The type or namespace name 'My_Interface_Name' could not be found (are you missing a using directive or an assembly reference?) 找不到类型或名称空间名称“ MySql”(您是否缺少using指令或程序集引用?)c#VS 2013 - The type or namespace name 'MySql' could not be found (are you missing a using directive or an assembly reference?) c# VS 2013 如何修复“找不到类型或名称空间名称“ PlayerManager”(您是否缺少using指令或程序集引用? - how to fix 'The type or namespace name 'PlayerManager' could not be found (are you missing a using directive or an assembly reference?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM