skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    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


  2. 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)

    enter image description here

    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:

    enter image description here

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search