In ASP.NET where and all we can refer the assembly reference? - asp.net

In ASP.NET where and all we can refer the assembly reference in Project? for ex: generally we can refer the file in web.config file as like below
<%# Register assembly="System.Web" namespace="System.JavaScript.Web" tagprefix="ex" %>
Except this what are the other pages in which we can refer assembly as like above.

secondly you can refer the assembly in project. Right click on references and select the required assembly, and click add. This will add assembly reference to your project.
Some assemblies like ajaxtoolkit.dll or if you are using some partial views (ascx) pages, then you can use the reference which you have mentioned.

Related

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

We have added third party (DropdownCheckBoxes) dll reference in our SharePoint web part application.
On the user control, registered this assembly as
<%# Register Assembly="DropDownCheckBoxes" Namespace="Saplin.Controls" TagPrefix="asp" %>
When we run it on browser, it giving us error as --
Could not load file or assembly 'DropDownCheckBoxes' or one of its dependencies. The system cannot find the file specified.
Can you please guide what needs to be done for this?
Thank You!

HttpHandler assembly name in ASP.NET Website type project

How do you specify the assembly qualified type name of your HTTP Handlers in an ASP.NET web site type project because the assembly that the handler will be compiled into will be dynamically generated at run-time?
You give the full namespace and assembly name like this....
MySite.MyHandler, MySite
Reference

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.

How to load webusercontrol from classlibrary

I have a classlibrary. This library contains widget.ascx control. How to load this webusercontrol from web. I know "LoadControl". But this not applicable.
How can i load web usercontrol from library?
2009.09.24
My main goal is i'm creating addon based web application. Every addon will be widget of web application.
I need dynamically load web usercontrol from library
You need to add a reference of the library to your web project.
Then instantiate it as you would with any other control, either programatically or in an #Register directive.
Kindness,
Dan
In addition to obviously adding the DLL to your project references, you also need to register the control. You can do this on each page that will use the control, but I usually prefer to do it in web.config. As a quick example, here's the line I used to register the Infragistics UltraWebGrid control in my app.
<pages>
<controls>
<add tagPrefix="ig" namespace="Infragistics.WebUI.UltraWebGrid" assembly="Infragistics35.WebUI.UltraWebGrid.v8.2, Version=8.2.20082.1000, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB"/>
</controls>
</pages>
TagPrefix works kind of like an in-page namespace, so if I had a bunch of controls I was importing from one DLL, they'd probably all have the same TagPrefix. In the page, I'd simply reference my control as follows:
<ig:UltraWebGrid runat="server" SetSomeOtherPropertiesToo="blah" />
I am not sure how the .ascx file is added to your class library. Normally user controls are loaded using LoadControl which requires an existing file. In case the user control is compiled as embedded resource in your class library you could use GetManifestResourceStream() to read the user controls' contents and then ParseControl to create a control from the string read using GetManifestResourceStream.

LoadControl on control with assembly reference

I'm trying to use System.Web.UI.TemplateControl.LoadControl to build a templated web part for a SharePoint application, and I'm having trouble with a control that references an external assembly.
I have a user control with the first few lines like this:
<%# Control Language="C#" ClassName="MyControl" %>
<%# Assembly Name="AjaxControlToolkit" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
The web part derives from a base webpart that implements the templating and some other utilities which is in an assembly called "MyWebParts" (for example), while the derived web part class is in "MyProject". MyProject has a reference to "MyWebParts" (obviously), and to "AjaxControlToolkit", but "MyWebParts" does not have a reference to "AjaxControlToolkit". At runtime, when the templated web part tries to load the user control (a .ascx file in the "controltemplates" SharePoint root folder), it calls the base methods it inherited across assemblies, and it throws an HttpParseException, indicating that it couldn't load a required assembly. The EventViewer confirms that the assembly in question is AjaxControlToolkit.
I tried adding the AjaxControlToolkit assembly to the web.config for sharepoint, and it's sitting in the GAC, but to no avail.
Anyone know how I can do this without having a reference to every assembly in existence in my "MyWebParts" assembly?
Add a reference to your assembly in the web.config assemblies section, this will force sharepoint to load that assembly into memory, like so:
<assemblies>
<add assembly="AjaxControlToolkit, Version=1.0.10920.16768, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
</assemblies>
P.S. this is for ajax 1.0, correct the assembly version if you are using the AJAX 3.5 version.

Resources