c# - File imported into App_Code isn’t referenced -
Q1
a) I have created a new one. CC file, declare a class in it and then save it to my disk Now according to my book, I would like to be able to import this file into the website's app_software folder (Add -> existing item through website-btw - When the file was copied to the root folder of the website, I had to move it to the App_Code folder manually), and the file automatically compiled And will be referenced by all the pages in a website. But this is not the case, because when I try to use this class inside the ASPX page, I compile the error of time and say that "type or namespace was not found" < / P>
The author probably knows his stuff, it is safe to assume that I am doing something wrong
b) If you are in the class library And you want to refer to this component from some web application, you can website -> Add Reference , but when you create the class library, VS creates two DLS, which is located in the bin folder and obj / debug folder I think that I should add the reference to the DLL contained inside the bin and not for the dll contained in obj / debug ? If so, why?
thanx
Edit:
< P>I have not left any information, so hopefully the following information will be auspicious:
I used to first class1 Has created a file called .cs, has put the following code into that file, and saved it somewhere on my disk. Here is code 1 code:
using the system; Namespace class 1 {public square class 1 {public static string string someString = "this is class 1"; }}
Then I copied Class1.cs into my web site's App_Code folder. This web site has only one ASPX page and its code behind the file. However, after copying Class1.cs to the App_Code folder, I tried to refer to it with a code behind the file:
using class1; Public Partial Class _Default: System.Web.UI.Page {Secure Zero Page_load (Object Sender, EventArgs E) {Label1.Text = Class1.someString; // It will not be compiled}}
For the first question we are going to be a bit More context is needed Can you post the definition of class or at least the header? And where is this place referred?
For the second question, use the outside of the bin \ debugs, the obege folder is primarily used by compiler and compile system for temporary files used as part of the compiler process. In many ways these files are temporary and can be removed by a number of actions, it is better to trust the file with bin \ debug.
Comments
Post a Comment