Home All Groups Group Topic Archive Search About

?cannot be instantiated under a partially trusted security policy (AllowPartiallyTrustedCallersAttri

Author
1 Apr 2005 4:08 PM
Michael Shupe via .NET 247
I have been grappling with ?cannot be instantiated under a partially trusted security policy (AllowPartiallyTrustedCallersAttribute is not present)? on SharePoint for the last few days, incorporating some procedures gleaned from the net and msdn.microsoft.com but I have not beaten it yet.

1.    I created a service and a web.config, put the config file in \inetpub\wwwroot\myservice, put the dll in ?myservice\bin, all on my own PC, and watched it work.
2.    When I created the same arrangement on my SharePoint server, correctly excluding the myservice directory from SharePoint. I got the error ?..cannot be instantiated under a partially trusted security policy (AllowPartiallyTrustedCallersAttribute is not present).? The exception is thrown by the HttpRemoteHandlerFactory.  I should note at this point that I could have no references to SharePoint in my service and get the same result.
3.    Next, I strongly named my DLL and added [assembly: AllowPartiallyTrustedCallersAttribute] to the AssemblyInfo.cs of my service. Same result.
4.    Next, I added my service to the GAC. Same result. I moved the DLL out of the bin directory under InetPub but I got the same result.  Now this doesn?t make sense to me because I understand that, by default, assemblies in installed in the GAC run with full trust. Perhaps this doesn?t apply when remoting.

From here, I followed procedures described in an msdn.microsoft.com article entitled ?Microsoft Windows SharePoint Services and Code Access Security?. This is an excellent article even if it was not sufficient to lead me to a working system.

5.    From the article, I tried to set my SharePoint server to FullTrust in its web.config file in Program Files\Common Files\Microsoft Shared\Web server extensions\60\config but FullTrust was not one of the options. I had to choose between WSS_Minimal and WSS_Medium which are the trust levels created by SharePoint. I thought I would have the original five trust levels (FullTrust to Minimal) in addition to the two WSS options but such was not the case.
6.    Next, I followed the article?s instructions to create my own trust level to include my new service. I got confirmation that I was in the right place because if I made syntax errors in a config file, it was reported when I tried to run the service. However, when I fixed those problems, I was back to ?..cannot be instantiated..?

Now I am at a loss. If I understand the situation correctly, the security problem is not between my service and the SharePoint object model, it is between my client app and my service. The SharePoint portal is being overprotective of my service and I connect convince it to ease up.

Does anyone have any ideas about what I might be doing wrong or how I could go about debugging this?

While I am at it, the Microsoft article talked about putting assemblies in ?the BIN directory? as opposed to the GAC. I am not sure if the BIN directory is a .NET directory, a SharePoint directory, or an ASP.NET directory. I thought it might refer to the BIN directory that I created under InetPub. Can someone set me straight on this?




--------------------------------
From: Michael Shupe

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>5ta0nSRc1Ey7LEAM/Uvqng==</Id>

Author
2 Apr 2005 1:33 PM
Nicole Calinoiu
Might http://support.microsoft.com/?kbid=827929 be relevant here?  If so, it
looks like at least one person has successfully resolved it, as documented
at
http://groups-beta.google.com/group/microsoft.public.sharepoint.windowsservices/browse_frm/thread/491b9fcda01a3915/dc423bceb049dbee.



"Michael Shupe via .NET 247" <anonym***@dotnet247.com> wrote in message
news:eAHLNUtNFHA.2384@tk2msftngp13.phx.gbl...
I have been grappling with ?cannot be instantiated under a partially trusted
security policy (AllowPartiallyTrustedCallersAttribute is not present)? on
SharePoint for the last few days, incorporating some procedures gleaned from
the net and msdn.microsoft.com but I have not beaten it yet.

1. I created a service and a web.config, put the config file in
\inetpub\wwwroot\myservice, put the dll in ?myservice\bin, all on my own PC,
and watched it work.
2. When I created the same arrangement on my SharePoint server, correctly
excluding the myservice directory from SharePoint. I got the error ?..cannot
be instantiated under a partially trusted security policy
(AllowPartiallyTrustedCallersAttribute is not present).? The exception is
thrown by the HttpRemoteHandlerFactory.  I should note at this point that I
could have no references to SharePoint in my service and get the same
result.
3. Next, I strongly named my DLL and added [assembly:
AllowPartiallyTrustedCallersAttribute] to the AssemblyInfo.cs of my service.
Same result.
4. Next, I added my service to the GAC. Same result. I moved the DLL out of
the bin directory under InetPub but I got the same result.  Now this doesn?t
make sense to me because I understand that, by default, assemblies in
installed in the GAC run with full trust. Perhaps this doesn?t apply when
remoting.

From here, I followed procedures described in an msdn.microsoft.com article
entitled ?Microsoft Windows SharePoint Services and Code Access Security?.
This is an excellent article even if it was not sufficient to lead me to a
working system.

5. From the article, I tried to set my SharePoint server to FullTrust in its
web.config file in Program Files\Common Files\Microsoft Shared\Web server
extensions\60\config but FullTrust was not one of the options. I had to
choose between WSS_Minimal and WSS_Medium which are the trust levels created
by SharePoint. I thought I would have the original five trust levels
(FullTrust to Minimal) in addition to the two WSS options but such was not
the case.
6. Next, I followed the article?s instructions to create my own trust level
to include my new service. I got confirmation that I was in the right place
because if I made syntax errors in a config file, it was reported when I
tried to run the service. However, when I fixed those problems, I was back
to ?..cannot be instantiated..?

Now I am at a loss. If I understand the situation correctly, the security
problem is not between my service and the SharePoint object model, it is
between my client app and my service. The SharePoint portal is being
overprotective of my service and I connect convince it to ease up.

Does anyone have any ideas about what I might be doing wrong or how I could
go about debugging this?

While I am at it, the Microsoft article talked about putting assemblies in
?the BIN directory? as opposed to the GAC. I am not sure if the BIN
directory is a .NET directory, a SharePoint directory, or an ASP.NET
directory. I thought it might refer to the BIN directory that I created
under InetPub. Can someone set me straight on this?




--------------------------------
From: Michael Shupe

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>5ta0nSRc1Ey7LEAM/Uvqng==</Id>