*.cs.aspx cannot access *.cs files in App_Code folder - c#

This site was developed a few years ago. it was working 100%. I am re-deploying to my pc to make some changes and testing. Now it cannot find those classes in those files. I have always used 4.5 Framework. I have searched for a solution, unfortunately those have not resolved my issue. including coping it into main directory. It worked when I copied the actual code into one of the *.cs.aspx files. However there are more then 20 pages using this email file. Any advice would be welcome. I have been scratching around for days. Thx.
===================ERROR========================>
The error is as follows:The type or namespace name 'Emailer' could not be found (are you missing a using directive or an assembly reference?)
===================ERROR-DISPLAY================>
Source Error:
Heading

As the message is saying you are most likely missing an Assembly reference. Look at the references of the old project (pic below) and make sure your new project has the same ones added.
If you locate any missing references you can add them by clicking on References > Add reference, and find it among the listed ones or browse to the physical path.

Go to class property window by right clicking on it. Look for build option here Change your class build option to compile.

You probably changed a Web Site Project to a Web Application Project. There are a couple of differences between these project types. Among them, in Web Application Projects, the App_Code directory seems to be ignored.

Related

Website Publish Fails

I have a Web Application consuming a WebService. My web application has 2 projects - Startup and Other projects. I am able to build my solution and also run it without any problem in my local machine.
My Other project has a dll referenced named crypto. It is strongly named dll. Now I trying to publish my web app using File System. However it fails. Following are the errors.
The type or namespace name crypto could not be found (are you missing a using directive or an assembly reference)
From my output window
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "crypto". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
And finally it skips the Publish of website. Could anyone suggest me whats going on? Similarly I even had an WPF app and I was facing similar issue in Strongly Named dlls while creating Setup file. There I just put all the dlls in Special GAC folder and things worked. Here I am not sure.
Help would be appreciated.
Remove crypto dll from your projects, and add reference again , and be sure that crypto that you upload is exactly same as one you adding in reference. and then upload your project's dll again.

WebSuperGoo.ABCpdf8

I'm combing through a massive program for work that was worked on previously by 4-5 other programmers and ironing out the errors. I've come across an error involving the following line of code at the beginning of the file:
using WebSupergoo.ABCpdf8;
it's giving the following error: "The type or namespace name 'WebSupergoo' could not be found (are you missing a using directive or an assembly reference?)"
I know this is due to a reference I haven't included, and I found the website that has the files for it. But I can't figure out how to bring in the reference. I created a reference using the .dll file and then I included the reference, but I'm still getting the error. I don't have permission to post the program online, but I can give more details if necessary.
Any suggestions would be appreciated. If you need more information, feel free to ask.
Thanks!
Check if .NET Target framework version of your project is not lower than the framework used for building ABCpdf.dll.
This probably won't be too helpful at this point. But I struggled with this as well from an inherited project after a Windows Update broke a very old implementation of ABCPDF within an ASP.NET web application. I am not saying you should repeat these steps, but I am putting all these steps in here in case it helps someone else identify what they might need to do. Also, I was on ABCPDF10, but I don't see why this wouldn't work for any version.
I deleted all the ABCPDF files out of the project and bin/ manually including the ABCPDF.dlls, the ABCGecko.exe, the XUL Directory, and the PrintHooks.dlls.
I removed all the references to all those files in the proejct.csproj file
I removed all the Packages out of the ../packages for ABCPDF and ABCPDF.Gekco
I then installed 64-bit ABCPDF10, and then installed 32-bit ABCPDF10 via the MSI for each.
I then copied the files from their respective C:/Program Files directories into the bin/ of my project manually per ABCPDFs instructions. This didn't work for me because when I went to build in VS2015 it couldn't see the .DLL for some reason.
I then uninstalled it by deleting the files out of my project bin/ manually and then using Add/Remove Apps in Server2012R2.
I then used Nuget to download ABCPDF and that worked and it could build. But I still needed ABCPDF.Gekco
I then used Nuget to try and install ABCPDF.Gecko. This downloaded it, but it didn't install it fully. I manually copied over the missing .dlls and .exe into the bin/ directory and Built the project.
But at this point I got an error that it couldn't find the x64.dll even though it was in the bin/
What worked for me here is I left the Project and bin/ directory alone and I then used the .MSI installer and re-installed only the x64 version to the C:/ like any other program. I didn't have to copy any files to the bin/. I just re-built the project and boom! That worked.
It feels to me like a registry key/path issue. But I have no idea if that is right.
Hopefully that helps someone else.

web userControl

I have create a new empty web application in c# Asp.net 4.0 and then added App_Code folder then added 3 classes into that folder. I have added a web user control and set the reference of App_Code class into the control but it throws an error.
The type or namespace name 'App_Code' does not exist in the namespace (are you missing an assembly reference?)
Any ideas?
This point can be confusing.
A "web application project" is not expecting the App_Code folder.
A "website project" would expect that folder and know how to use it.
Whether you realize it or not (and depending upon which version of Visual Studio you use), you will get a WAP or a WSP when you first create your web solution. They are different. It takes some effort to convert from one to the other.
Here are a few articles explaining the differences.
To solve your immediate problem, then, you can just move the 3 class files out of the App_Code folder into the root folder, or better, create a new folder to contain those classes and move them into it. Depending upon whether you give the classes in that folder namespaces, you may have to add a reference to that namespace in your UserControl.
Did you create the App_Code folder manually?
I was the impression the folder was created automaticaly when creating the project.
If not, when you add something to the project you select Add ASP folder, and it would have App_Code option along others there.
If the option isn't there is probably because you created a Web Application.
This might help you more: http://vishaljoshi.blogspot.com/2009/07/appcode-folder-doesnt-work-with-web.html

Project stopped building and appending a '.1' to the project .dll

Recenently my ASP.Net Mvc 3 project stopped compiling and I have no idea why. It is giving me this error message.
"Could not load file or assembly 'ProjectName.1' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"
Any suggestions on why this might have happened and how to fix it?
Are you using source control? If so, I'd look for changes since the last version that built.
Also try cleaning the project, as well as manually clearing out the Obj/Bin folders to see if that helps.
Maybe also try searching for ".1" across the folder your app is in!
I think #DanTup - Danny Tuppeny has the right idea about searching for the .1 but I would recommend looking inside of the actual project files (and/or solution file) that is directly getting these messages. Right Click Project < Unload, Right Click Project, edit or with notepad on disk.
This is where you'll find the raw project references and build configuration and will most likely clue you in on what's happening. I would also agree using version history differences is the right idea and to do that on the project files.
You may want to try creating a blank (new) mvc 3 project and adding all your files from your old project to it, it's odd but it's fixed some strange mvc2 problems for me.

Cannot use external references with C# Console Application

I have tried all the suggestions below but still no joy.
I'm now trying a console application, and let me explain exactly what I'm doing.
I create a new console project in VS 2010
I add a number of references (dll's) some that aren't mine such as Castle.Winsor and N2 CMS dlls
in the console app I can add using statements indicating I am using name spaces within the referenced DLLs
I start writing code.
As soon as I compile all the code that uses the referenced DLLs immediately complains with "The type or namespace name '' could not be found (are you missing a using directive or an assembly reference?)"
I have tried setting the dlls to copy to local always, I have copied the DLL into the same directory, I have tried added reference by project and adding a reference to the DLL's themselves
I don't get this problem with a web application project or a ASP.net project they always work fine, only something that is compiled to an EXE like a console app or windows service.
there must be something I'm missing or I would have got this working by now.
Change the project Target to a non Client Profile target. Right click the Project and select Properties, you should see a list of Framework versions. As you are using VS2010, the Console project you've created by default targets .NET Framework 4.0 Client Profile, change that to .NET Framework 4.0.
Check if Copy Local is set to true for the referenced assembly.
First, as to your question, its hard to know exactly what you're doing wrong, but from the fact that you're using an underscore in an assembly name (and probably in namespaces and type names), it suggests you're rather new to the .NET world.
This suggests that you're adding references to other projects in your solution by browsing to the compiled assembly, rather than by adding a Project Reference. When adding a reference, you must select the Project tab rather than browsing for the assembly.
Even if you don't believe this is the issue, remove all references and re-add project references to make absolutely sure. Assumption, asses etc.
Once you've done that, I'd strongly suggest remove all the underscores from your types, namespaces and assemblies. You might want to go read the framework design guidelines, too.
Open your .Proj(Windows service project file) file in notepad and check whether your assembly location(data_object) is the same which you are pointing.
When you open .Proj file in notepad you can check for,
Project reference,
<ProjectReference Include="C:\StackOverflow\StackOverflow.csproj">
And if you giving dll or exe refrence then
<Reference Include="StackOverflow, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<ExecutableExtension>.exe</ExecutableExtension>
<HintPath>C:\StackOverflow\bin\Debug\StackOverflow.exe</HintPath>
</Reference>
I suggest you to give exact location including drive name like above example.
Other option you may try,
1. Clean and rebuild
2. Add Project reference if you already tried dll reference
3. Check whether the folder (referred assembly location) is Read Only then remove it.
In VS 2019, I had two projects, one C++ and other one C# Console in one solution file. When tried to add a dll reference through "Add reference", I was not able to see Browse button in "Reference Manager" window, to select dll file.
But when I created only C# Console app inside solution then I could add dll reference.

Categories