1

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
  • "I know the website runs because my colleague has been working on it,..." WITH? Commented Jan 26, 2022 at 17:19
  • Share your App_Code class and its consumers? source code Commented Jan 26, 2022 at 17:23

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Please re-read the question. I stated multiple times that the project is a website not a webapp, but your answer is for a webapp. In any case, having taken another look I think the error message is misleading. When I open the Translation class I get 80 errors, most of which state that a reference is required to System.Web version 4.0.0.0. The stupid thing is there IS a reference to that dll. I think if I can figure out how to fix those errors the class might become accessible.
Looks like that was a seperate issue. I closed vs, deleted the .vs folder from the project and reopened vs and those errors have gone. Still getting the Type 'Translation' is not found error though...
0

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

Comments

0

You just need to select class files and change their property Build Action : Compile. This will compile those class files and then you will be able to use those in your program.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.