Deploying SharePoint layout ASP .NET assembly into GAC - asp.net

I'm currently rewriting a legacy SharePoint application and I need to figure out how to deploy it.
The application itself is SharePoint solution with several features, including webparts and simple web pages with some code.
There is a webpage that is designed to be deployed in layouts subfolder.
In production environment, there is no codebehind in layouts subdirectory, just the .aspx file.
I understand that corresponding codebehind assembly is loaded from GAC. Indeed, it is there.
However the page code doesn't contain <%# Assembly %> directive that would ask it look in GAC, nor does it specify fully-qualified name:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BadWolf._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- -->
</html>
So how does this page locate its code assembly in the production environment? I need to deploy the same code to a different server but if I don't specify <%# Assembly %> SharePoint gives me Unknown Error, which is represented in logs as follows:
Exception Type: System.Web.HttpException
Exception Message: Could not load type 'BadWolf._Default'.
What did I miss? Is there any special config, any special setting, whatever?

You need to use Inherits= with the fully qualified assembly name...
Inherits="MyAssembly.MyNamespace.MyClass, MyAssembly, version=1.0.0.0, culture=neutral, publickeytoken=123456789"

Turned out the assembly was in SharePoint bin folder, that's why it was loaded without specifying the fully qualified name. However removing it from GAC yielded another issue:
Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed
This is funny because removing the assembly from either GAC or bin folder makes it unusable (or else requiring additional configuration which I seek not), and I'm not sure which one is actually being loaded.
I think I'll stick with keeping assembly in GAC (to have full trust) and specifying fully qualified name.

Related

Ajax Control Toolkit fails to load

I am having trouble getting my AJAX control tool kit working in asp.net. The website runs fine when I run it using the localhost/website.aspx address however when I attempt to access the website via the net I get the error below. Any Suggestions?
Parser Error Message: Could not load file or assembly
'AjaxControlToolkit' or one of its dependencies. The system cannot
find the file specified.
Line 1: <%# Page Language="VB" AutoEventWireup="false"
CodeFile="Submit_Employee_Info.aspx.vb" Inherits="_Default"
MaintainScrollPositionOnPostback="true" %>
Line 3: <%# Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit" TagPrefix="asp" %>
Source File: /RequestForm/Submit_Employee_Info.aspx Line: 3
Sorry not much reputations so posting as answer instead of comments. Do you have ajax toolkit dll referenced in your project. To confirm, check your bin/debug director.
In your local solution, expand the references folder in the web application, and find the AjaxControlToolkit.dll.
Right click, Properties, and check the path to where the DLL is referenced
If it's referenced to a folder outside of your project, you will need to include this in the project.
You have a couple of choices...
Copy DLL into a 3rdPartyLibs folder in the solution, and change the reference to point here
Use Nuget to download the file into the solution, the only issue here is that the version may be incorrect, so option 1 here might be best in your scenario.

Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified

I am working on sharepoint 2010. I have created a simple visual web part which contain one text box and I have added calendarextender to it. I have added ajaxcontroltoolkit.dll as reference. But when I deploy to sharepoint site then it gives me following error.
"Parser Error" Message:
Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 3: <%# Register Assembly="AjaxControlToolkit"> Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
Source File:
/_CONTROLTEMPLATES/VWP_Ajax/VisualWebPart1/VisualWebPart1UserControl.ascx Line: 9
Any ideas where Im going wrong?
Is the AjaxControlToolkit.dll in the bin directory after you deploy the site?
The assembly (AjaxControlToolkit.dll) needs to be deployed to the Global Assembly Cache (GAC) or put in the \BIN folder of the SharePoint site's folder.
This definitely worked for me with SharePoint 2010 ...
Error Code:
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxControlToolkit"%>
Working Code:
<%# Register Assembly="AjaxControlToolkit, Version=3.5.60501.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" Namespace="AjaxControlToolkit" TagPrefix="ajaxControlToolkit"%>
Another possible solution is to explicitly set the full assembly name in your register command. I found that I had to update my code to include this to get it to work properly:
<%# Register Assembly="AjaxControlToolkit, Version=3.0.30930.28736, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
For third-party controls like this, it's worth being as specific as possible to avoid any errors if versions change.
Even you tried above and it wont work, Just add another Page/MasterPage and add ToolKitScriptManager on it.It will create Bin Folder at required path. If still there is Error check the Register Assembly line on newly added page/MasterPage and copy that Register Assembly line to other pages wherever your error is.

Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified

i have installed AJAXcontrolsToolkit with my visual studio and placed "Combobox" Ajaxcontrol controls in my webpage . when i am compiling the code getting below error
"Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified"
Have you added the required assembly to the references of your project?
The above post was very useful
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
I was using the above code , i replaced the code as below and now working
<%# Register Assembly="AjaxControlToolkit, Version=3.5.40412.0, Culture=neutral, PublicKeyToken=****" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
Thanks for your post
I use File-Zilla to upload my files to the web server. I found that my reference files (AjaxControlToolkit.dll and AjaxControlToolkit.pdb) in the bin folder on the web server had not been completely transferred. so I deleted them and I uploaded new ones from the development site directly into the bin folder of the web server.
And Voila! Everything just fell into place like magic.
The application not load because it not find or not is compatible, try to do download from at nuget Install-Package AjaxControlToolkit -version x.x, or in site.

Using <%# Assembly %> reference without CopyLocal

I am trying to write a standalone ASPX page (no codebehind) for reasons I won't get into. So I want to have some functions declared in the page. But those functions need to reference assemblies that aren't generally referenced by ASPX pages. This means that I need an <%# Assembly %> reference, as detailed here:
http://msdn.microsoft.com/en-us/library/d864zc1k.aspx
And it all works fine if I have my reference to the assembly set to CopyLocal = true. However, it is in my GAC, so I don't want to set it to copy local. But if I don't have the DLL in my /bin folder, the page does not compile due to a bad reference.
What do I have to do to get the <%# Assembly %> declaration to work against an assembly in the GAC?
Typically assemblies that are in the GAC are referenced in the web.config. Is your assembly referenced in the system.web -> compliation -> assemblies section? If not, adding it should resolve your issue.

What is the purpose of precompiledApp.config?

If you precompile a web site and keep it updatable, the ASP.NET parser can see from the Page directive that there is no codefile or codebehind and where to find the base class (inherits attribute).
<%# page language="C#" autoeventwireup="true" inherits="_Default, Precompiled"
theme="Default" validaterequest="false" %>
If the site is precompiled and not updatable, the .compiled files in the bin folder should give the ASP.NET runtime all the necesary information on how to instantiate the page classes.
So why is the precompiledApp.config needed?
Thanks!
It's used to indicate whether or not the ASPX/ASCX pages in your site are updateable or not. You can precompile and have the code behind compiled, but leave these pages updateable so you can make minor GUI-related tweaks should you wish.

Resources