Question

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?

Was it helpful?

Solution 2

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.

OTHER TIPS

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"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top