在线网站中的课程文件 [英] Class file in live website

查看:61
本文介绍了在线网站中的课程文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我为asp.net网站编写了一个类文件.
在我的本地主机中,我刚刚使用Visual Studio创建了新的类文件,并创建了App_Code文件夹,并将该类文件放在此处,然后就可以使用该类了.
当我尝试在实时网站上进行同样的操作(创建App_Code文件夹并将类文件放入文件夹中)时,编译器无法识别该类,因此我无法使用该类.
如何使用课程?

解决方案

该类文件必须采用称为dll的编译版本的形式,才能在网页上使用.
在Visual Studio中运行网站时,它会为您进行编译.

只需将bin文件夹中的相应dll复制到您的网站路径中即可.方法.您看到VS创建了一个App_Code文件夹并将该类放在其中,您正尝试在LIVE网站上做同样的事情!太棒了!

看一下本文: ASP.NET应用程序文件夹入门指南 [ ^ ]

如果我们存储任何类文件(例如.cs或.vb),则ASP.NET会以特殊方式处理文件-编译器会自动编译它们.现在通过创建App_Code放置类文件不会做任何事情,因为它是编译时的事情!本文对您来说是一本好书: ASP.NET网站项目中的共享代码文件夹 [^ ]

避免在下次更改代码时执行快捷方式".


从此处开始 ^ ]

有关设置方法的更多详细信息:
ASP.NET网站项目中的共享代码文件夹 [用于编译的codeSubDirectories元素(ASP.NET设置架构) [ App_Code文件夹不适用于Web应用程序项目(WAP) [ ^ ]


并查看了解ASP.NET动态编译 [如何:在用户帐户下运行辅助进程 [ ^ ]


您可能还会发现以下一些有趣的内容:
如何向其中动态添加控件网页 [ ASP.NET中的动态控件 [ 解决方案

The class file needs to be in the form of a compiled version called dll to be used on the web page.
When you run your website in visual studio, it does the compilation for you.

Just copy the appropriate dlls from the bin folder into your website path.


This is a clear example of what happens when you do things without knowing/understanding why it''s done in a given way. You saw that VS created an App_Code folder and put the class there, you are trying to do the same on LIVE site! Awesome!

Have a look at this article:
Beginner''s Guide to ASP.NET Application Folder[^]

If we store any class files (like .cs or .vb), ASP.NET handles files in special ways - compiler compiles them automatically. Putting class file now by creating App_Code will not do anything as its a compile time thing! This article would be a good read for you: Shared Code Folders in ASP.NET Web Site Projects [^]

Avoid doing ''shortcuts'' with code changes next time.


Start here Web Application Projects versus Web Site Projects[^]

More details on how to set things up:
Shared Code Folders in ASP.NET Web Site Projects[^]
codeSubDirectories Element for compilation (ASP.NET Settings Schema)[^]

You may also find this useful App_Code folder doesn’t work with Web Application Projects (WAPs)[^]


And have a look at Understanding ASP.NET Dynamic Compilation[^]

Depending on how the host is configured you may need to run the IIS worker process under an account with sufficient privileges How to: Run the Worker Process Under a User Account[^]


You may also find the following to be of some interest:
How To Dynamically Add Controls to a Web Page[^]
Dynamic Controls in ASP.NET[^]

Best regards
Espen Harlinn


这篇关于在线网站中的课程文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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