简体   繁体   English

网站项目中的App_code文件夹不可访问

[英]App_code folder in web site project is not accessible

I am trying to utilise the advantage of App_code folder in my project. 我正在尝试利用项目中App_code文件夹的优势。 I have gone through THIS POST I have added Empty web site and added webforms to it. 我已经完成了本发布,我已经添加了Empty网站并向其中添加了网络表单。 I have 3 layers in my project. 我的项目中有3层。 I want to use the class in app_code in my Data layers. 我想在我的数据层的app_code中使用该类。 But which i am not able to use... 但是我无法使用...

I went on googling and what i find is " THIS ". 我继续谷歌搜索,发现是“ THIS ”。

Again when i tried to change the Build action of that class in properties, i could not even find the properties of that class in solution explorer. 同样,当我尝试在属性中更改该类的Build操作时,我什至无法在解决方案资源管理器中找到该类的属性。 Please anybody help me what i am missing here...?? 请有人帮我在这里我想念的东西吗?? Snapshot below 下面的快照 在此处输入图片说明

At the bottom of the screenshot, you might see a "Properties" tab, or you might have a "Properties" window. 在屏幕截图的底部,您可能会看到一个“属性”标签,或者您可能有一个“属性”窗口。 You can also go to View -> Properties Window, or press F4. 您也可以转到查看->属性窗口,或按F4。 Any of those should bring it up. 任何这些都应该提出来。 While you have "Helper.cs" selected, the properties should appear in that window - one of which is the Build Action property you mentioned, and you set that to "Compile". 当您选择“ Helper.cs”时,属性应显示在该窗口中-其中之一是您提到的Build Action属性,并将其设置为“ Compile”。

There are several other things you need to do to make your class accessible to your project. 要使您的项目可访问您的类,还需要做其他几件事。 You should add a common namespace for all of your code-behind and classes, and then add using MyNamespace; 您应该为所有代码隐藏和类添加一个通用名称空间,然后using MyNamespace;添加using MyNamespace; statements at the top of these classes. 这些类顶部的语句。 You would need to ensure your classes and methods you are calling are public/exposed to the classes doing the calling. 您需要确保您正在调用的类和方法是公开的/公开给进行调用的类。 There are also issues where the App_Code folder seems to have issues, and just creating a generic folder called "AppCode" (no underscore) and putting the files in that seems to correct the problems (at least, that's how I had to solve some issues). 还有一些问题,其中App_Code文件夹似乎有问题,只是创建一个名为“ AppCode”的通用文件夹(没有下划线),然后将文件放入其中似乎可以解决问题(至少,这就是我必须解决的问题) )。

As for why "Properties" doesn't appear on that menu in your screenshot, you might need to re-install Visual Studio - seems like a bug, to me. 至于为什么“属性”没有显示在屏幕快照的菜单上,您可能需要重新安装Visual Studio-对我而言似乎是个错误。

尝试将其添加到您的网站项目中作为参考。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM