At work I have been asked to make some amendments to a vb.net website project i've not worked on before. I've cloned the code from TFS and opened it in VS2019 but there were errors when I tried to run it. I know the website runs because my colleague has been working on it, and it is also live on a server and being used by our clients.
I have fixed some errors in the web.config and added some missing references, but now i'm getting an issue with a class called Translation which is in the App_Code folder. The class is used all around the website but i'm getting the error:
Type 'Translation' is not defined.
All of the solutions i've come across say that I need to change the build action on the class to 'compile', but that isn't possible for a website because there is no build action property. The other suggestion i've seen is to add a 'using' statement but as the class has no namespace this is not an option.
I've seen lots of people asking how to do this for websites but nobody has provided an answer, so i'm hoping someone out there can finally come up with a solution which can help me and anyone else struggling with this problem.
There is often a problem with app_code. In fact two fold. First up, is IIS will compile the code in that folder and NOT Visual Studio. This can lead to problems on deployment (some (a lot) of web sites don't have the newer rosylin complier, and I find some of the great new features (such as free form strings in code) will not compile.
But expand the app code, and then right click (properties) for say the given class, or module code you have, and change/set this: (build action)
Change above "build" action to compile (if it not already).
And even before you do above, try a re-build all (that often fixes this).
So, change above - it possible that the code/module you added to app_code not been (ever) compiled, and thus not seen in your project).
So, I actually now often create my own folder called "MyCode" and often avoid the issues of app_code. However, you might be dealing with a existing applcation.
You could also try doing this:
Rename app_code and add it again:
eg:
but, I would first try setting the code module/or class in app_code to compile in the properties sheet first. And try a re-build all.
In fact, exit VS, re-load, open project. rebuild all. Do that first, just in case (since then you don't make any changes). If exit/reload don't work, then as noted, right click on the module/class in app_code and set build action to compile.
And last but not least, you could try a re-name, and add the app_code folder - since it a specials .net folder, and manually adding that folder often does not work (don't just add folder - add "asp.net" folder) - you need to let VS add it for you as per above screen cap.
After many painful hours i've finally got the code running - mostly thanks to the efforts of my colleagues and my boss. It seems the existing project wouldn't run for me so my boss created a new project and added the required websites to that. After some fiddling with the configuration he got it working.
So unfortunately I cannot provide an answer. Apologies if you've arrived here looking for one. I'm not sure this is actually an issue anyway as I never found anything about anyone else having the problem.
Thanks to Albert D. Kallal for trying to help
Related
How to add a reference to the App_code directory for a sub-folder in web project
I have been given a task to take an older, grown piecemeal over a decade internal website and bring it "up to speed". I have run into a problem in ASP files to "see" the app_code directory. Essentially the current site is a collection of folders that work(ish) that I am trying to collect together as a single project with the LEAST number of edits.
When functionality was superseded the old code was moved into a "deprecated" folder. The code files now reference object in the app_code directory which is not visible to the file from it's new location. The easy answer would be to copy a version of the class file into the "deprecated" folder but that seems more like a hack then a solution. The same for copying the App_code folder to a location visible to the ASP file.
My thought was to add a reference ("reference path") somehow to the deprecated folder pointing to the app_code folder but I cannot find how to do that.
A couple of other notes: 1) the site was built by using text editors and "freebie" editors - it has never been compiled or run in-total through VS before. 2) once I get it built and checked into TFS I am going to remove the deprecated folders. 3) I am working under some stipulations to satisfy concerns arising from actions of prior developers.
Code like:
tr.Controls.Add(GUI.GetTableCell("Salesman", 0, "Center"));
Works well when the ASP page is at the same directory level as the App_code folder ("GUI" is a class with a "GetTableCell" function).
If I can add a folder reference I can solve all of the remaining problems I have with this step in the project.
EDIT
Let me re-ask it this way. The image below is a composite of what I am facing in VS2017. I have such a feeling that a light bulb is simply not turning on for some reason. How I have done this so far is pulling down the current website from our internal Win2003 web server and am trying to convert it into a legit web project. I have done many of the steps necessary but there are 47 instances of the problem visible in the composite image from Visual studio
The code behind from SubscriptionEditor.aspx pictured lower right. Has reference to a namespace which is in the code files in the App_code folder (neatly hidden). This site functions fine but I am missing something to make it work from within VS. I am just at a loss.
For anyone that finds this I want to point out that there are a number of excellent answers available for similar questions here and i have looked at dozens and tried them all. The simple answer to my problem is "you can't".
How to convert ASP.NET website to ASP.NET web application came close
The problem being the source is just a collection of ASP files - it follows no project or template.
Namespaces are super important in development and the clever ways that prior developers found to breach that discipline can not be fixed through VS. It is simple a lot of bloody knuckle corrections of code and scope issues til the errors disappear.
The limitations put on me prohibit any solution. I will end up advocating not "saving the code" unless they are willing to put in the investment to heal the most egregious foibles. So if you see me in the "available for contract" sites then you know how that conversation went.
I currently have a solution which recently added a new website to the TFS source control. Due to a mistake during creation, the website physical directory is like below:
Z:\Projects\NewWebSite\NewWebSite
Instead, it should be like below:
Z:\Projects\NewWebSite\
The problem I had was when trying to remove and add the website with the new physical path into the solution. Every time I do so, for some reason it will automatically refers to the first path. If I tried to remove the folder, it will give me an error saying it can't open the path since the folder no longer exists.
My solution is to basically unbind everything and create a new solution from scratch, then re-adding the website to the solution. My worry is that I am just working around the problem, and that it is still present somewhere in TFS, waiting to mess up someone else's solution when they check out.
So, does anyone knows what is causing this, and what is the best way to fix this sort of behavior?
If your solution name is the same as your project name then that is the default structure. When making a new project, start by creating the solution with a unique name and then adding your project to that.
No matter what, you do actually want that structure. Its like that for the purpose of expandability. If you need to add additional projects or maybe separate your operations into different projects (like Data vs Web for instance), the Solution/Project folder setup will accommodate.
In other words, don't fight it. Just make your solution name unique from your Web application name to make it less ugly looking.
TFS doesn't deal with physical locations at all. This is handled by your TFS client, when you map a workspace a physical path. This is not something that TFS deals with.
As such, i'm confused by your comments.
So I'm left maintaining a proprietary codebase from a third-party vendor. The vendor is still sort of around, but support is limp. The site is ASP.NET.
I have made some changes but I am having a really hard time getting IIS to compile these changes in. The bin/ directory has what I believe is a precompiled dll for the core classes. I've changed these but it doesn't recompile. I have tried deleting the dll but then the app refuses to build saying that the Global.asax can't inherit the type anymore, so I don't really know how to rebuild with changes.
I spent all day Saturday setting up a build environment and trying to get a testing thing working. I have just been importing into VS2008 as a web site from the local IIS server. I got it to rebuild the app without changes, but it ignores changes I would place in it.
So I need to make a solution out of this website and/or directory structure so that I can do actual, big, full grown-up rebuilds and make changes to this codebase. Anyone know how I can go about this?
EDIT: A bit more elaboration. I've tried creating a blank project and just Add Existing File... on the whole website directory. This hasn't worked, it stops the import about 10% in.
Keep in mind there are two (actually, three) levels of 'builds' or compiles going on here.
1) The DLLs in the /bin directory should be pre-built, by visual studio or otherwise. The content of .ASPX, ASCX, ASHX, ASAX etc fiels are not included in those.
2) The ASPX, etc files I noted above are then compiled by IIS when the first request comes in (normally; there are ways to change that behavior). That is the source of the error with Global.asax you are seeing; With the DLL(s) gone, the class that Global.asax is supposed to inherit from does not exist.
3) Then there is the just-in-time compilation, which is not relevant for this discussion.
It sounds like you may be missing the source files for the project, or perhaps the web site is not getting properly set up as a project to compile that DLL
Try these links, I suppose this is what you are looking for.
http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/01/20/linking-files-in-visual-studio.aspx
http://support.microsoft.com/kb/306234
Not sure this question is really valid anymore. The source we were working with was rather different than it should have been. Not sure if someone got angry in the past and moved stuff around or what, but grabbing a new copy of the source fixed most of our issues. I am able to build now with an included csproj.
This doesn't really help many others with the same issue I suppose, but if you are getting weird build behavior like this, you might want to start with basics, like making sure that your source checkout is valid.
I am new in asp.net so I am not sure it is a professional way or not.
I have the project without .snl file. I just create a empty web site and then paste the files inside the folder where I created the project.
It worked for me.
I think pasting the files and folder directly by file manager will help you.
I have a .NET 4 website in VS2010 stored in a TFS 2010 team project. I need to add a reference to System.Data.Linq.dll to the website. I am referencing a LINQ DataContext that is defined in another project and I get build errors saying that I need the reference to System.Data.Linq. I go up to the "Add Reference" menu option and add it like I would any normal reference, and it even shows up in the Web.config and in the Properties pages for the website... BUT if I build I still get the same error.
So I found a place in my code where I was referencing the LINQ count function and it told me it was invalid because I was missing a reference and it offered to add the reference automatically. I told it to add the reference automatically and it is at this point that I get the error mentioned in the subject:
TF14040: The folder $/Folder/Subfolder may not be checked out. No items were checked out
I've done some research online but I haven't been able to find much. I saw on a blog that making the folder not readonly fixed the issue for him, but it didn't seem to work for me unless I misunderstood something.
I tried loading up the project from source control onto a fresh computer where that project had never been loaded before and I can reproduce the issue the same way. Help would be greatly appreciated.
FWIW, this error also occurs in different circumstances. I had the same error today from the command line when trying to use tfs checkout SomeFolder /login:user,password, although this was not within the context of an asp.net app, I'm currently working on dependency replication. For me, adding the /recursive command worked, like this:
tfs checkout SomeFolder /recursive /login:user,password
The hint to try that came from here, by the way.
I have no idea if this is your problem but I've noticed that TFS2010 seems to have some bug somewhere around folder renames/deletes/changes or something. The bugs seem to go away when you check everything in and try again after the folder change has been saved to source control. I have hit this issue a dozen times this week but don't know exactly what the scenarios are. It's quite frustrating.
I figured it out, but it's a little strange. I had some build errors that I hadn't fixed yet, also my web.config file used to be for a 3.5 SP1 site and I upgraded the site to 4.0. Somewhere along the line the build errors and the web.config combined to form this strange weird error that apparently has nothing to do with TFS.
I figured it out by creating a new website and slowly moving over portions of my site to that new site. Things didn't go totally crazy until I moved over my web.config. So I went back and updated my web.config file so that it more closely matched the way a .Net 4 web.config should by trimming out a lot of stuff and now things are good and building fine. Thanks for the help.
I have a solution with several projects in Visual 2008, let's say SuggestionProcessor (a class library) and Suggestions (a website) with a webhandler GetSuggestions.ashx. I changed a method in SuggestionProcessor which is used in the webhandler. The call in the webhandler has been adjusted to the changed method.
But now when I try to execute the webhandler after a rebuild I get an error that the method I changed is missing, displaying the old method signature. When I try to rebuild the entire project it seems that the website does not rebuild properly and the code I changed in the webhandler does not seem to be included in the rebuild. I made sure that the website is last in the build order.
What I tried is remove the dlls that the build process should rebuild from the bin folder (not the ones referenced from outside the website). When rebuilding I now get a: 'could not load type Suggestions.global'. Duh, that is what the build process should create. What is going wrong here?
I solved this one by reverting to a previous state when it still worked.
Thanks for the suggestions, I'm sorry they didn't work in my situation.
Shall I delete this question now that it doesn't really have a clear use for someone else?
I would check your web.config file, there may be references there that are causing the error since they are missing.
Maybe try and right click on your solution and select "Clean solution" and then try and rebuild all.
If that doesn't work, check your solutions build configuration and make sure all your projects are getting built
Try "Clean Solution", then building SuggestionProcessor, and after that clean and rebuild the web solution.
Visual Studio creates a copy of all your DLLs and sometimes this copies are not refreshed.
Just execute iisreset and delete all folders in:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary
ASP.NET Files\
Of course change windows installation folder and framework folder to your version!
I don't think so... I've seen similar issues in Visual Studio 2008 working on web projects where the build and rebuild would fail time after time. I knew that my changes shouldn't have affected the build so I just kept cleaning and building each of the individual projects in my solution until finally (and I do mean finally as in, it took up to 10 builds) my web project would build correctly. I have no idea why, but it feels like some sort of caching issue.
From my answer at "Could not load type [Namespace].Global" causing me grief:
It seems that VS 2008 does not always add the .asax(.cs) files correctly by default.
In this case, refreshing, rebuilding, removing and re-adding, etc. etc. will not fix the problem. Instead:
Check the Build Action of Global.asax.cs. It should be set to Compile.
In Solution Explorer, Right-click Global.asax.cs and go to Properties. In the Properties pane, set the Build Action (while not debugging).