"未能加载类型[命名空间]。全球"导致我的悲伤 [英] "Could not load type [Namespace].Global" causing me grief

查看:167
本文介绍了"未能加载类型[命名空间]。全球"导致我的悲伤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的.Net 2.0 Asp.net的WebForms应用程序,我有我的Global.asax包含以下code:

In my .Net 2.0 Asp.net WebForms app, I have my Global.asax containing the following code:

<%@ Application CodeBehind="Global.asax.cs" Inherits="MyNamespace.Global" Language="C#" %>

然而,当我建立我得到一个错误,说明 -

However when I build I get an error stating-

未能加载类型'MyNamespace.Global'。

Could not load type 'MyNamespace.Global'.

这似乎是因为myNameSpace对象命名空间(在隐藏文件Global.asax.cs中的code定义)不是由Global.asax文件中看到编译器(不中的R#intellisence显示..) 。
事实证明,这是一个非常难啃的骨头...任何帮助将AP preciated!

This seems to be because the MyNamespace namespace (defined in the code behind file Global.asax.cs) is not seen by the compiler in the Global.asax file (does not show in R# intellisence..). This turned out to be a very hard nut to crack... any help will be appreciated!

请注意:在Global.asax和Global.asax.cs中位于同一文件夹

Note: The Global.asax and the Global.asax.cs are located in the same folder.

注2:当从VS提示与CSC编译它编译O.K.

Note2: When compiling from the vs prompt with csc it compiles o.k.

推荐答案

一种情况我遇到这导致此问题是当你通过生成配置指定构建平台。

One situation I've encountered which caused this problem is when you specify the platform for a build through "Build Configuration".

如果您指定的x86作为构建平台,Visual Studio将自动分配斌/ 86 /调试作为该项目的输出目录。这是完全有效的其他项目类型,除了在那里ASP.NET预计组件输出到Bin文件夹的Web应用程序。

If you specify x86 as your build platform, visual studio will automatically assign bin/x86/Debug as your output directory for this project. This is perfectly valid for other project types, except for web applications where ASP.NET expects the assemblies to be output to the Bin folder.

我在我的处境中发现什么,他们输出到两个(斌彬/ 86 /调试),除某些DLL的,而且莫名其妙地最重要的一个是Web应用程序的DLL,是失踪从Bin文件夹。

What I found in my situation was that they were being output to both (Bin and Bin/x86/Debug), with the exception that some of the dll's, and inexplicably the most important one being your web application dll, being missing from the Bin folder.

这显然引起了编辑的问题,因此无法加载类型的全局异常。清洁解决方案,并删除组件作出后续构建没有区别。我的解决办法是只改变项目设置输出路径为Web应用斌(而非斌/ 86 /调试)。

This obviously caused a compilation problem and hence the "Could not load type Global" exception. Cleaning the solution and deleting the assemblies made no difference to subsequent builds. My solution was to just change the output path in project settings for the web app to Bin (rather than bin/x86/Debug).

这篇关于&QUOT;未能加载类型[命名空间]。全球&QUOT;导致我的悲伤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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