Assembly problem when using a .ashx file in my layouts folder - c#

I have a *.ashx file in my "Layouts" folder for sharepoint and it doesnt seem like I can access any of my custom made classes outside of the Layouts folder. Is there a problem with the assembly? I keep getting the error:
The type or namespace name 'PropertiesHelper' does not exist in the namespace 'Company.SharePoint.Test' (are you missing an assembly reference?)
I have tried to put a using statement to import the class but it seems like it isnt able to find it. I also tried writing out the full path of the function like: Company.SharePoint.Test.PropertiesHelper.someMethod

Usually when this happens to me, it's because I forgot to actually deploy the assembly to the GAC (or locally depending on how you're doing it). Either way, it can't find the assembly because it's not in the right location or not trusted.

Related

VSTS hosted agent can't load DLL MSB3246

We are trying to port our build on VSTS hosted agent. We have bunch of DLLs pushed through git lfs to remote. These DLLs work fine on local machine. But when I tried to run build on VSTS hosted agent, one of the DLL got warning MSB3246
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): Warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly 'FooBar.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format
There are 2 DLLs in our git lfs. I don't see other DLLs success/failure message in log so not sure whether it is working fine or it might also have same issue(this DLL might be breeaking things first).
Obviously, I got errors refering to code from this DLL.
Error CS0234: The type or namespace name 'Foo' does not exist in the namespace 'Bar' (are you missing an assembly reference?)
I found similar issue on https://social.msdn.microsoft.com/Forums/vstudio/en-US/f2d8d30f-62b0-476f-a28e-17e372b6c557/issues-with-build-on-hosted-build-controller?forum=TFService but we already have our gitattributes file set correctly.
What might be going wrong here? Have anyone solved this already?
In the Get Sources step there is a specific checkbox to enable git-lfs support. Without it the file will be replaced with a placeholder to the lfs download location. Of course you can't compile against those.

How can i reference windowbase dll from a different path from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

I've looked around to try to find some posts on this and there are many but none that address my specific question. I am trying to add window base dll in my script but its coming from : C:\Windows\Microsoft.NET\Framework\v4.0.
actually i need to upload the cs file and supporting dll to the server and i don't know the path where .net framework is installed in server.
when i try to add copy windowbase.dll and upload it, i am getting following error :
The type or namespace name 'Packaging' does not exist in the namespace 'System.IO' (are you missing an assembly reference?)
please suggest some solution for this

Unable to find the type or namespace name after moving files

I get this error message in Visual Studio when I'm trying to run the C# code:
The type or namespace name 'Shape' could not be found (are you missing a using directive or an assembly reference?)
Is this because I changed the location of some files in the Solution Explorer? From the beginning I had the files in a folder and then I moved them outside and erased the folder. I have tried to use rebuild solution and clean, but I still get this error.
Now I have all files in the same "level" in the Solution Explorer. What can I do to get it to work again?
A few things to try:
Make sure the class file containing the Shape class is marked as "Include in project" in the Solution Explorer.
In the file with the error, make sure you have an appropriate using statement referencing the namespace where the Shape class is located.
If the Shape class is in an external DLL, make sure it is referenced in your project.
Double-check what the namespace is for the class file that contains the Shape class. Depending on how you moved those files around, it may have changed and you will need to update the using statement where you use it.
This can be caused by many things. e.g. public, assembly referencing, and in a project or a solution folder. JohnFx has already handled some of these in his reply. But to get you "going" do the following:
Move all of the files into the same project within the solution. So you solution has a project and all of the files are in that one project.
This should at least get you going. Then experiment.
Good luck.

Webservice reference cannot find assembly reference

I have a c# project with a reference that cannot be found when checking in to TFS. The project runs fine when i debug.
It its in my services project the problem is located. I have a reference to lets say ProjectSec. And i have a wewbservice reference to Projectservice.
The webservice uses the ProjectSecurity.Security namespace that is located in the ProcectSec assembly.
When i check in my files i get the following error:
The type or namespace name 'ProjectSecurity' could not be found (are you missing a using directive or an assembly reference?)
Could not resolve this reference. Could not locate the assembly "ProjectSec". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
The ProjectSec.dll is located in the lib folder and its there. There is no error when i try to use it elsewhere in my project.
This may not be a perfect explanation but does anyone know what i could try?
I have removed the reference and added it over again, but no luck.
A common pitfall with TFS-build is to have in Source Control something, for example, like this:
$/Sources/Webservice
$/Libs/ProjectSecurity
And then, in the build definition that is validating your checkin, to have only
Active | $/Sources/Webservice | $(SourceDir)
as workspace mappings.(You can access this by right-clicking on the build definition in TeamExplorer, select "Edit Build Definition.." & go to Tab "Workspace")

Cannot deploy Aspx website, App_code folder classes become unreadable

I have recently finished creating my website, I have therefore come to the stage where I have to deploy it to a live server however when copying across, all of the App_Code, App_Data and Bin folder items become unaccessible. All of the classes are fine when I run on my dev server but once the files go across (exactly as they are) I can no longer create instances of objects from the App_code folder (very important).
The error I get is a quite generic error message.
CS0246: The type or namespace name 'Display' could not be found (are you missing a using directive or an assembly reference?)
I have never needed to declare a namespace for the code in App_Code before so I presume the error is not completely accurate. The permissions on files and folders are also the same.
When I use intelisense on the deployed website, it does recognise the objects. However once Comiled are not usable.
Any help would be much appreciated.
Do you have a missing refrence when you move to the new server?
Check your project's refrence folder and project settings. Make sure the .dlls are marked copy local and if your using anything from the GAC. If so you may need to deploy the .dll to the production server for things to work.
Are you manually copying the site's files (say, with an FTP client) or are you using the Copy Website tool ('Website' menu, `Copy Website...' menu item)? I'd hope the tool can help you get all the necessary files copied over neatly.
The error message you are seeing doesn't necessarily require namespaces; it's referring to a type with no namespace, or in one of the namespaces in your 'using' statements, called 'Display,' that you've referred to in one of your ASPX files. That;s pesumably one you've put in your App_Code folder. Don't worry about using namespaces.
I am using the VS2008 Copy Website function to deploy the website. I have not needed to have a using declaration before to access the app code I presumed it was always accessible from anywhere within the website.
How do I check the dll which you mentioned?

Categories

Resources