473,413 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

ASP.NET 2.0 and Partial Trust with VSTO

Hi folks,

I need some help with an ASP.NET 2.0 page that generates the following error
when it calls a VSTO runtime DLL:

System.Security.SecurityException: That assembly does not allow partially
trusted callers.

My understanding was that for my partial-trust Web application to call a
VSTO strong-named assembly, the assembly needs to be in the GAC. That is,
the GAC grants Full Trust by default.

My ISP (ServerIntellect) kindly installed the VSTO runtimes in the GAC, but
still no luck - same error when I run the code.

What needs to be done in this case? Does the VSTO assembly need to be marked
with the 'allow partially trusted callers' (APTCA) even when in the GAC?

I've put in some repro code below.

Thanks!

Ken
Microsoft MVP [ASP.NET]
kj***@hotmail.com

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Web.Configuration" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Common" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="Microsoft.VisualStudio.Tools.Applicatio ns.Runtime" %>

<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim template() As Byte
Dim sd As
Microsoft.VisualStudio.Tools.Applications.Runtime. ServerDocument
Response.Write(Environment.UserName)
sd = New
Microsoft.VisualStudio.Tools.Applications.Runtime. ServerDocument(template,
".DOC")
End Sub
</script>

Jun 12 '06 #1
6 1983
VSTO call unmanged code so its not trusted. installng it in the gac does not
make it trusted. as you proably do not have the source code to change the
attributes you need to write a trusted wrapper around it andf install this
in the gac. this is a really bad idea for your ISP, as VSTO can crash
asp.net if not called correctly.

-- bruce (sqlwork.com)

"Ken Cox [Microsoft MVP]" <BA**********@newsgroups.nospam> wrote in message
news:uy**************@TK2MSFTNGP02.phx.gbl...
Hi folks,

I need some help with an ASP.NET 2.0 page that generates the following
error when it calls a VSTO runtime DLL:

System.Security.SecurityException: That assembly does not allow partially
trusted callers.

My understanding was that for my partial-trust Web application to call a
VSTO strong-named assembly, the assembly needs to be in the GAC. That is,
the GAC grants Full Trust by default.

My ISP (ServerIntellect) kindly installed the VSTO runtimes in the GAC,
but still no luck - same error when I run the code.

What needs to be done in this case? Does the VSTO assembly need to be
marked with the 'allow partially trusted callers' (APTCA) even when in the
GAC?

I've put in some repro code below.

Thanks!

Ken
Microsoft MVP [ASP.NET]
kj***@hotmail.com

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Web.Configuration" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Common" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="Microsoft.VisualStudio.Tools.Applicatio ns.Runtime"
%>

<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim template() As Byte
Dim sd As
Microsoft.VisualStudio.Tools.Applications.Runtime. ServerDocument
Response.Write(Environment.UserName)
sd = New
Microsoft.VisualStudio.Tools.Applications.Runtime. ServerDocument(template,
".DOC")
End Sub
</script>

Jun 12 '06 #2
Hmmm. Strange.

The ServerDocument object isn't supposed to require Word or Excel so where
would it use unmanaged code?

The bits I'm using constitute a technology that was *designed* for server
use. If you're right, somebody really screwed up here.
"bruce barker (sqlwork.com)" <b_*************************@sqlwork.com> wrote
in message news:%2****************@TK2MSFTNGP02.phx.gbl...
VSTO call unmanged code so its not trusted. installng it in the gac does
not make it trusted. as you proably do not have the source code to change
the attributes you need to write a trusted wrapper around it andf install
this in the gac. this is a really bad idea for your ISP, as VSTO can crash
asp.net if not called correctly.

-- bruce (sqlwork.com)

"Ken Cox [Microsoft MVP]" <BA**********@newsgroups.nospam> wrote in
message news:uy**************@TK2MSFTNGP02.phx.gbl...
Hi folks,

I need some help with an ASP.NET 2.0 page that generates the following
error when it calls a VSTO runtime DLL:

System.Security.SecurityException: That assembly does not allow partially
trusted callers.

My understanding was that for my partial-trust Web application to call a
VSTO strong-named assembly, the assembly needs to be in the GAC. That is,
the GAC grants Full Trust by default.

My ISP (ServerIntellect) kindly installed the VSTO runtimes in the GAC,
but still no luck - same error when I run the code.

What needs to be done in this case? Does the VSTO assembly need to be
marked with the 'allow partially trusted callers' (APTCA) even when in
the GAC?

I've put in some repro code below.

Thanks!

Ken
Microsoft MVP [ASP.NET]
kj***@hotmail.com

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Web.Configuration" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Common" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="Microsoft.VisualStudio.Tools.Applicatio ns.Runtime"
%>

<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim template() As Byte
Dim sd As
Microsoft.VisualStudio.Tools.Applications.Runtime. ServerDocument
Response.Write(Environment.UserName)
sd = New
Microsoft.VisualStudio.Tools.Applications.Runtime. ServerDocument(template,
".DOC")
End Sub
</script>


Jun 13 '06 #3
Hello Ken,

As for the CAS exception you encountered, my understanding is that the VSTO
assembly(or maybe another intermediate assemby which calls VSTO assembly)
is demanding the caller to have FullTrust permission. I haven't performed
deep investigation into VSTO , but looking from the CAS perspective, if it
is some certain assembly in the calling path(from your asp.net code to VSTO
runtime assembly) that demand fullTrust permission, simply adding the VSTO
assembly into GAC will not work. Because your ASP.NET application is still
a partial trusted runtime host and if the demand is performed from the
GACed assembly to your ASP.NET application, it will still fails.

I think Bruce's suggestion is reasonable. You can create a wrapper class
which call those VSTO components and this wrapper class is compiled into a
separate assembly(wrapper assembly), strong name it and install this
wrapper assembly into GAC. Thus, when any linkedDemand(for FullTrust)
performed from the callee assembly of the wrapper assembly, it will get
satisfied. Also, apply the "AllowPartiallyTrustedCallersAttribute" for the
wrapper assembly so that your ASP.NET(partial trusted) host can call it
correctly.

Hope this helps.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Jun 13 '06 #4
Hi Ken,

I just forgot the step that you'll also need to assert the certain CAS
permission in your wrapper assembly's code so that the demand won't go
upper to any further caller assemblies. You can refer to the "Wrapping
Privileged Code" section in the following msdn article:

http://msdn.microsoft.com/library/en...7.asp?frame=tr
ue#paght000017_wrappingprivilegedcode

Thanks & Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 13 '06 #5
Hi Steven,

Thanks for your response.

The problem is that the Web site in question is hosted by an ISP. I don't
have control over what goes into the GAC, and I can't imagine that the ISP
wants to start putting client components into the GAC. They agreed to
install VSTO because it is a Microsoft-supported technology.

Am I right in concluding that VSTO is not really designed for Internet
applications where the site owner doesn't control the Web server?

Thanks,

Ken
Microsoft MVP [ASP.NET]

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:Jg**************@TK2MSFTNGXA01.phx.gbl...
Hello Ken,

As for the CAS exception you encountered, my understanding is that the
VSTO
assembly(or maybe another intermediate assemby which calls VSTO assembly)
is demanding the caller to have FullTrust permission. I haven't performed
deep investigation into VSTO , but looking from the CAS perspective, if it
is some certain assembly in the calling path(from your asp.net code to
VSTO
runtime assembly) that demand fullTrust permission, simply adding the VSTO
assembly into GAC will not work. Because your ASP.NET application is still
a partial trusted runtime host and if the demand is performed from the
GACed assembly to your ASP.NET application, it will still fails.

I think Bruce's suggestion is reasonable. You can create a wrapper class
which call those VSTO components and this wrapper class is compiled into a
separate assembly(wrapper assembly), strong name it and install this
wrapper assembly into GAC. Thus, when any linkedDemand(for FullTrust)
performed from the callee assembly of the wrapper assembly, it will get
satisfied. Also, apply the "AllowPartiallyTrustedCallersAttribute" for the
wrapper assembly so that your ASP.NET(partial trusted) host can call it
correctly.

Hope this helps.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 13 '06 #6
Hi Ken,

Yes, and this is true for any other components which will demand FullTrust
callers or host environment. In .net framework 2.0, the "PermCalc.exe" tool
can be used to evaluate the CAS permission set required of a certain
assembly:

#Permission Calculator Tool (Permcalc.exe)
http://msdn2.microsoft.com/en-us/library/ms165077.aspx

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Jun 14 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Howard Kaikow | last post by:
I just visited the MSFT web site and saw the comparison/pricing of the different VS 2005 versions. I was looking for a statement of the system requirements for VS Pro and VSTO, could not find. ...
15
by: Enrique | last post by:
Question I am posting this question again (3rd time) because some issues with my no spam alias. Here it is the question: I have not been able to run unit tests for a VSTO (2005) project. I...
2
by: Le | last post by:
Folks, I'm trying to do some office automation using VSTO 2005. I've verified that ..Net Programmability Support is installed for every MS Office application and Microsoft Forms 2.0 .Net...
6
by: Joseph Geretz | last post by:
I'm porting a C# Outlook Addin originally engineered as a COM Addin over to use VSTO. I've gotten this to the point where my VSTO Addin installs its Menu items and Toolbar buttons when Outlook...
5
by: Toulousse | last post by:
Hi, I'm currently a VB6 developer and I write mostly office type apps (not always Office though). At this point in time I have a project where I need to develop an add-in for Microsoft Project....
3
by: Paul H | last post by:
Most of my projects are developed in Access 2003. I have not even installed Office 2007 yet! I need to buy VSTO to get the run-time licence for Access 2003. No doubt I will soon need a run-time...
5
by: =?Utf-8?B?TWFydHluIEZld3RyZWxs?= | last post by:
Hi there. I posted an earlier issue under the name "That assembly does not allow partially trusted callers" but have now identified what the issue is. As explained before I am working in...
0
by: arturbl | last post by:
I just finished my sort of MVC/P framework where I do url rewriting. During the url rewriting I access properties of the controller/presenter based on the url. First thing that most of us would...
0
by: Atul Thombre | last post by:
Hello, I am developing a custom membership provider. For that I built a prototype that uses a SQL Server 2005 database as a backend store. I implemented the class...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.