I keep getting
System.IO.FileNotFoundException: 'Could not load file or assembly
'Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral,
PublicKeyToken=89b483f429c47342 or one of its dependencies
error when I try to check for existence of a role. The problem is that have references to unmanaged data access"Oracle.DataAccess.dll" and none to managed!
I checked web.config and all the references and can't see where this managed data access reference is coming from. Any ideas?
using System;
using System.Web;
using System.Web.Security;
using System.Web.Routing;
public class Global : HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
if (Roles.Enabled)
{
if (!Roles.RoleExists("User")) <--- Error pops up here
{
Roles.CreateRole("User");
}
...
}
}
}
In web.config:
<compilation defaultLanguage="c#" debug="true" targetFramework="4.6">
<assemblies>
<add assembly="Oracle.DataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89B483F429C47342"/>
<add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
....
<roleManager enabled="true" defaultProvider="AHSOracleRoleProvider">
<providers>
<add name="AHSOracleRoleProvider" type="Oracle.Web.Security.OracleRoleProvider, Oracle.Web, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" connectionStringName="AHSConnectionString" applicationName="/"/>
</providers>
</roleManager>
I have console project with some .cshtml files stored in Resources folder, which is built into .cs files with Razorgenerator.MsBuild nuget package.
I need to replace WebViewPage view base class for generated view, but adding web.config file with pageBaseType="ConsoleApp.MyViewBase" option set or changing location of files in different ways did not help me and no any other ways where found.
View class is always generated as:
public partial class _Resources_Index_cshtml :
System.Web.Mvc.WebViewPage<ConsoleApp.ModelClass> { ... }
Hope, there is some way to confgure the class globally for all views, without adding directives at the beginning of every .cshtml file.
It looks that that setting base view in web.config works in latest RazorGenerator.
So update your RazorGenerator package and try to have something like this in web.config:
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="WebApplication2.Views.BaseView2">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>
In my case I was adding precompilation (with RazorGenerator.Mvc and RazorGenerator.MsBuild packages) to old project and it didn't work. The problem was that I had Version=2.0.0.0 in my configSections project and had to change it to Version=3.0.0.0.
If someone finds it helpful, there is a nuget package for this by me. It is same Razorgenerator.MsBuild but with replacing System.Web.Mvc.WebViewPage by Custom.System.Web.Mvc.WebViewPage. So if you want to use custom WebViewPage, install the package and add you class named WebViewPage in namespace Custom.System.Web.Mvc. Like:
namespace Custom.System.Web.Mvc
{
public abstract class WebViewPage<T>
{
...
}
}
I have been scratching my head for days. I've googled to no avail. I am trying to get stuff from a database with jquery.ajax, based on the information I send over (sorta a post AND a get) everytime though, the server responds with an Error 404: Not Found, and is telling me I asked for Localhost:1986/undefined, which is not the case.
I'm sure exactly where all my folders and files are is important, so I will include as much as I can, feel free to ask for more if it is necessary.
My script is copy pasted and modified from another script I have to post to the database, and that works fine, so why this one doesn't stumps me:
function nextSlide() {
var articleLink = document.getElementsByTagName("a")[0];
$.ajax({
type: 'POST',
url: "../SlideShow/NextArticle",
data: {
slideID: articleLink.getAttribute("id"),
},
success: function (result) {
$(articleLink).id = result[0];
document.getElementById("articleImage").setAttribute("src", result[1]);
document.getElementById("articleTitle").innerHTML = result[2];
document.getElementById("articleText").innerHTML = result[3];
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + errorThrown);
}
});
}
This is the method inside my SlideShowController.cs file I am trying to use:
[AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
public JsonResult NextArticle(string slideID)
{
int ID = int.Parse(slideID);
var articles = db.Slides.ToList();
var currentArticle = db.Slides.First(s => s.SlideId == ID);
int articlePosition = articles.IndexOf(currentArticle);
articlePosition = (articlePosition + 1) >= articles.Count() ? 0 : articlePosition + 1;
var nextArticle = articles.ElementAt(articlePosition);
//nextArticle.Article.ArticleText.Substring(0, 50)+"..."
string[] returnParameters = {
nextArticle.SlideId.ToString(),
nextArticle.Image.ImageURL,
nextArticle.Article.ArticleTitle,
nextArticle.Article.ArticleText
};
return Json(returnParameters);
}
The SlideShowController.cs file is inside a folder named Controllers in the root directory. The script is called from a _SlideShowPartial.cshtml file in a Root/Views/SlideShow folder. That file is loaded in a Index.cshtml file in a Root/Views/Home folder using #html.Partial()
Here is a screenshot of the error that appears in chrome console:
And here is the contents of the Web.Config file inside the Views folder:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="TIAWebWorkConnect.Models.AppViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
You're definitely sending url wrongly to the server. try a complete url, or remove url from your $.ajax query.
Consider introducing T4 MVC into your project. This will give you strongly typed access to MVC actions and let you avoid URL strings which looks like your issue here.
https://github.com/T4MVC/T4MVC/blob/master/README.md
My view is having issues finding a class located in one of my references.
This reference is to a dll built outside of the project.
The view always gives error:
The type or namespace name 'Company' could not be found (are you
missing a using directive or an assembly reference)
Here is the controller. No issues there.
using Company.Entities;
public ActionResult Find()
{
Person test = Person.SelectByADDistinguishedName("L*", false);
return View(test);
}
Here is the View. The error occurs in the #Model line.
#model Company.Entities.Person
#{
ViewBag.Title = "Bob";
}
<h2>Find</h2>
My Views/Web.config currently looks like this
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="Company.Entities" />
</namespaces>
</pages>
</system.web.webPages.razor>
I've checked similar threads like this one but to no avail.
Here is the message on the screen
Line 25: using System.Web.Mvc.Html;
Line 26: using System.Web.Routing;
Line 27: using Company.Entities;
Line 28:
Line 29:
Source File: c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET
Files\root\49c9c7db\1f9dd5c8\App_Web_find.cshtml.a8d08dba.xro6gxci.0.cs
Line: 27
If I strip out any mention of the assembly (out of web.config - no #using statments). I get the same error message when loaded but against this line
public class _Page_Views_Home_Find_cshtml : System.Web.Mvc.WebViewPage<Company.Entities.Person> {
After working it with it for awhile, I ended up solving it.
I had to add the assembly under the assemblies section of the main web.config (not the one under the views)
Sample of the web.config.
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="Company, Version=2.0.31.0, Culture=neutral, PublicKeyToken=df9010405db60e6d"/>
</assemblies>
</compilation>
Thanks for people who gave me suggestions.
Be sure to check your views directory for an additional web.config file. I seem to remember running into a similar problem because I hadn't updated the correct web.config. YMMV.
Adding the reference
before where you use your control, in .cshtml file works. Example:
#model IEnumerable<MyApp.Models.MyModel>
#using System.Web.UI.WebControls;
But you can put it in web.config, under namespaces tag.
This way it is global to all views. Also, there is no need to specify the version:
<namespaces>
<add namespace="System.Web.UI.WebControls" />
</namespaces>
I've got a vague handle on how Code Access Security works in Sharepoint.
I have developed a custom webpart and setup a CAS policy in my Manifest
<CodeAccessSecurity>
<PolicyItem>
<PermissionSet class="NamedPermissionSet" version="1" Description="Permission set for Okana">
<IPermission class="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" version="1" ObjectModel="True" Impersonate="True" />
<IPermission class="SecurityPermission" version="1" Flags="Assertion, Execution, ControlThread, ControlPrincipal, RemotingConfiguration" />
<IPermission class="AspNetHostingPermission" version="1" Level="Medium" />
<IPermission class="DnsPermission" version="1" Unrestricted="true" />
<IPermission class="EventLogPermission" version="1" Unrestricted="true">
<Machine name="localhost" access="Administer" />
</IPermission>
<IPermission class="EnvironmentPermission" version="1" Unrestricted="true" />
<IPermission class="System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" version="1" Unrestricted="true"/>
<IPermission class="System.Net.WebPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
<IPermission class="System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Unrestricted="true" />
<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" PathDiscovery="*AllFiles*" />
<IPermission class="IsolatedStorageFilePermission" version="1" Allowed="AssemblyIsolationByUser" UserQuota="9223372036854775807" />
<IPermission class="PrintingPermission" version="1" Level="DefaultPrinting" />
<IPermission class="PerformanceCounterPermission" version="1">
<Machine name="localhost">
<Category name="Enterprise Library Caching Counters" access="Write"/>
<Category name="Enterprise Library Cryptography Counters" access="Write"/>
<Category name="Enterprise Library Data Counters" access="Write"/>
<Category name="Enterprise Library Exception Handling Counters" access="Write"/>
<Category name="Enterprise Library Logging Counters" access="Write"/>
<Category name="Enterprise Library Security Counters" access="Write"/>
</Machine>
</IPermission>
<IPermission class="ReflectionPermission" version="1" Unrestricted="true"/>
<IPermission class="SecurityPermission" version="1" Flags="SerializationFormatter, UnmanagedCode, Infrastructure, Assertion, Execution, ControlThread, ControlPrincipal, RemotingConfiguration, ControlAppDomain,ControlDomainPolicy" />
<IPermission class="SharePointPermission" version="1" ObjectModel="True" />
<IPermission class="SmtpPermission" version="1" Access="Connect" />
<IPermission class="SqlClientPermission" version="1" Unrestricted="true"/>
<IPermission class="WebPartPermission" version="1" Connections="True" />
<IPermission class="WebPermission" version="1">
<ConnectAccess>
<URI uri="$OriginHost$"/>
</ConnectAccess>
</IPermission>
</PermissionSet>
<Assemblies>
....
</Assemblies>
This is correctly converted into a wss_custom_wss_minimaltrust.config when it is deployed onto the Sharepoint server and mostly works.
To get the WebPart working fully, however I find that I need to modify the wss_custom_wss_minimaltrust.config by hand after deployment and set Unrestricted="true" on the permissions set
<PermissionSet class="NamedPermissionSet" version="1" Description="Permission set for MyApp" Name="mywebparts.wsp-86d8cae1-7db2-4057-8c17-dc551adb17a2-1">
to
<PermissionSet class="NamedPermissionSet" version="1" Description="Permission set for MyApp" Name="mywebparts.wsp-86d8cae1-7db2-4057-8c17-dc551adb17a2-1" Unrestricted="true">
It's all because I'm loading a User Control from the webpart. I don't believe there is a way to enable that using CAS but am willing to be proven wrong.
Is there a way to set something in the manifest so I don't need to make this fix by hand?
Thanks
Is your web part in the bin file?
Have you set partially trusted callers in the assembly?
If not do so! it's best practice.
Sometimes, it is hard to determine what permissions are actually being used when loading a usercontrol. Try granting unrestricted=true on the following list of security classes, and if you get it working, remove them one by one until you get the minimal set needed for your web part:
<SecurityClass Name="AllMembershipCondition" Description="System.Security.Policy.AllMembershipCondition, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="AspNetHostingPermission" Description="System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<SecurityClass Name="DataProtectionPermission" Description="System.Security.Permissions.DataProtectionPermission, System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<SecurityClass Name="DnsPermission" Description="System.Net.DnsPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="EnvironmentPermission" Description="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="EventLogPermission" Description="System.Diagnostics.EventLogPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="FileCodeGroup" Description="System.Security.Policy.FileCodeGroup, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="FileDialogPermission" Description="System.Security.Permissions.FileDialogPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="FileIOPermission" Description="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="FirstMatchCodeGroup" Description="System.Security.Policy.FirstMatchCodeGroup, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<SecurityClass Name="IsolatedStorageFilePermission" Description="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="KeyContainerPermission" Description="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="NamedPermissionSet" Description="System.Security.NamedPermissionSet"/>
<SecurityClass Name="NetCodeGroup" Description="System.Security.Policy.NetCodeGroup, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="OleDbPermission" Description="System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="PerformanceCounterPermission" Description="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="PrintingPermission" Description="System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<SecurityClass Name="ReflectionPermission" Description="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="RegistryPermission" Description="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="SecurityPermission" Description="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="SocketPermission" Description="System.Net.SocketPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="SharePointPermission" Description="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<SecurityClass Name="SmtpPermission" Description="System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<SecurityClass Name="SqlClientPermission" Description="System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="StorePermission" Description="System.Security.Permissions.StorePermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="StrongNameMembershipCondition" Description="System.Security.Policy.StrongNameMembershipCondition, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="UIPermission" Description="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="UnionCodeGroup" Description="System.Security.Policy.UnionCodeGroup, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="UrlMembershipCondition" Description="System.Security.Policy.UrlMembershipCondition, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<SecurityClass Name="WebPartPermission" Description="Microsoft.SharePoint.Security.WebPartPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<SecurityClass Name="WebPermission" Description="System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="ZoneMembershipCondition" Description="System.Security.Policy.ZoneMembershipCondition, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
To setup cas look at the codeplex and see wspbuilder.
You won't need to do this manually.
As far as i know, there is no way you can apply custom cas for user controls. Dlls loading user controls should necessarily be in Gac or the web application Trust level need to be set to full.
Try avoiding user control if you need to put your dll in bin