473,614 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

That assembly does not allow partially trusted callers

From the amount of articles about this one I’m sure this gets asked a lot,
but I haven’t yet found a succinct article which explains what is required in
its entirety.

I work using Visual Studio 2005 SP1 mainly in ASP.Net using VB.Net 2.0.

I have an application which runs without error on my development server so I
believe that the underlying code is correct.

Most of my applications including this one runs on a shared server (Win
2003) that my hosting provider runs in medium trust. I understand from
background reading that because of the trust issue certain ASP.Net 2.0
assemblies require additional alterations to their compilations files to
allow other assemblies to call there methods etc.

The application is set up so that the main application (project) has a
reference to a second project (the business layer) within the solution, where
most of the code is kept and maintained. Compilation of the business layer
passes the dll to the bin folder of the main application and then the
application including the dll in the bin folder is copied across to the live
server.

When I run the application on the live server I get the error “That assembly
does not allow partially trusted callers”

After background reading I added the line –

<Assembly: AllowPartiallyT rustedCallersAt tribute()>

into the AssemblyInfo.vb file along with an “Imports System.Security ”

I could find no mention of where in the file this line should be added so I
assume this is of no importance.

I recompiled the application and uploaded it again but the error was still
present. Further research suggested that the assembly should have a “Strong
Name” so I went to the signing tab of the project settings and ticked the box
to “Sign the assembly” I then created a new “strong name key file” there were
none before this and the key “keyname.pfx appeared in the business layer
project folder.

This is where I became stuck! I can find no reference explaining what I am
supposed to do with the key although I assume it is required on the live
server so that the business layer dll file can be referenced. I have uploaded
the new dll but the application still fails. I tried adding the key to the
bin folder on the live application but that didn’t help matters.

Any advice on the above or anybody know one good article which explains the
whole thing.
--
Regards

Martyn Fewtrell
May 2 '07 #1
5 18457
wow, slow your roll. There's no reason for this to fail on the shared server
if it works on the dev machine, after all, the assemblies on the dev machine
are (hopefully) the same ones on the share. Couple questions: What assembly
is it complaining about partial trust? This may quite possibly be a security
issue related to accessing the assembly on a shared drive, masquerading as
an aptca issue. The way to confirm/eliminate that issue is to turn CAS
policy off on the production machine and see if you get the message.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Martyn Fewtrell" <mf*******@news group.nospamwro te in message
news:81******** *************** ***********@mic rosoft.com...
From the amount of articles about this one I'm sure this gets asked a lot,
but I haven't yet found a succinct article which explains what is required
in
its entirety.

I work using Visual Studio 2005 SP1 mainly in ASP.Net using VB.Net 2.0.

I have an application which runs without error on my development server so
I
believe that the underlying code is correct.

Most of my applications including this one runs on a shared server (Win
2003) that my hosting provider runs in medium trust. I understand from
background reading that because of the trust issue certain ASP.Net 2.0
assemblies require additional alterations to their compilations files to
allow other assemblies to call there methods etc.

The application is set up so that the main application (project) has a
reference to a second project (the business layer) within the solution,
where
most of the code is kept and maintained. Compilation of the business layer
passes the dll to the bin folder of the main application and then the
application including the dll in the bin folder is copied across to the
live
server.

When I run the application on the live server I get the error "That
assembly
does not allow partially trusted callers"

After background reading I added the line -

<Assembly: AllowPartiallyT rustedCallersAt tribute()>

into the AssemblyInfo.vb file along with an "Imports System.Security "

I could find no mention of where in the file this line should be added so
I
assume this is of no importance.

I recompiled the application and uploaded it again but the error was still
present. Further research suggested that the assembly should have a
"Strong
Name" so I went to the signing tab of the project settings and ticked the
box
to "Sign the assembly" I then created a new "strong name key file" there
were
none before this and the key "keyname.pf x" appeared in the business layer
project folder.

This is where I became stuck! I can find no reference explaining what I am
supposed to do with the key although I assume it is required on the live
server so that the business layer dll file can be referenced. I have
uploaded
the new dll but the application still fails. I tried adding the key to the
bin folder on the live application but that didn't help matters.

Any advice on the above or anybody know one good article which explains
the
whole thing.
--
Regards

Martyn Fewtrell

May 3 '07 #2
Hi Martyn,

As for the problem you met, it is likely a typical .NET(ASP.NET) Code
access security issue. As the error message indicate some assembly not
allow partial trusted caller, I agree with Alvin that you should first
check which assembly is the exact one that raise this error. Normally in a
public service hoster(with restricted code access permission policy), this
is common issue. And it is not necessarily your assembly, but could be some
other assemblies(syst em assembies) your assembly uses that raise this
error.

Generally, at development time, since your ASP.NET application is running
under Full Trust policy, there won't raise such CAS problem. At publich
shared hoster, CAS policy is restricted, if your application has called
some privileged code(according to .NET CAS permission), it may raise some
error. As for the "strong-name" or "AllowPartially TrustedCallers"
attribute, it is a typical approach use to create a wrapper assembly which
call those privileged code and install it into GAC. Here is a good MSDN
article detailedly describe ASP.NET 2.0 code access security and how to
deal with some common issues. You can have a look:

#How To: Use Code Access Security in ASP.NET 2.0
http://msdn2.microsoft.com/en-us/lib...0017_wrappingp
rivilegedcode

If you have any more specific questions, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.
May 3 '07 #3
Hi there and thanks for the reply

To expand a little the error is as follows:

-----------------------------------------------

[SecurityExcepti on: That assembly does not allow partially trusted callers.]
BusinessLayer.e xRateFactory.Se rializeClass(ex Rate _exRate, String Path)
in exRateFactory.v b:91
BusinessLayer.e xRateFactory.Ge tExRate() in exRateFactory.v b:26
Test.Page_Load( Object sender, EventArgs e) in
D:\networkclub2 couk\wwwroot\we bservices\exRat e\Test.aspx.vb: 9
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +99
System.Web.UI.C ontrol.LoadRecu rsive() +47
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +6953
System.Web.UI.P age.ProcessRequ est(Boolean includeStagesBe foreAsyncPoint,
Boolean includeStagesAf terAsyncPoint) +154
System.Web.UI.P age.ProcessRequ est() +86
System.Web.UI.P age.ProcessRequ estWithNoAssert (HttpContext context) +18
System.Web.UI.P age.ProcessRequ est(HttpContext context) +49
ASP.test_aspx.P rocessRequest(H ttpContext context) +29

System.Web.Call HandlerExecutio nStep.System.We b.HttpApplicati on.IExecutionSt ep.Execute() +154
System.Web.Http Application.Exe cuteStep(IExecu tionStep step, Boolean&
completedSynchr onously) +64

-----------------------------------------------

exRateFactory and exRate are classes in the business layer. The two methods
which are called are GetexRate which basically sets a number of values on the
exRate class and SerializeClass which serializes the exRate class once the
values are loaded. Basically the exRateFactory either calculates new values
or takes the values from the serialized class according to certain perameters.

As far as I understand it when I build the solution the BusinesLayer.dl l is
copied to the bin foilder of the main application. The main application then
calls the classes from within the BusinessLayer.d ll. This works without issue
on the devlopment server.

When I upload the application to the Shared hosting environments all the
contents of the bin folder are copied to the bin folder on the live
application.

I'm assuming from the error message that the offending assembly is the
BusinessLayer.d ll

I have quite a few applications on this host built with the same basic
architecture (using BusinessLayer.d ll) buit have never come across this issue
before. As a result I am somewhet confused!

The development server and live server are set up as close to the same as
possible, same versions of ASP.Net etc but I have no control over the live
server as it is not mine. My hosting provider is however very helpfull.

I apologise if my explanations are muddled but despite reading several
articles on this im not entirly sure I fully understand the problems.

--
Regards

Martyn Fewtrell
"Steven Cheng[MSFT]" wrote:
Hi Martyn,

As for the problem you met, it is likely a typical .NET(ASP.NET) Code
access security issue. As the error message indicate some assembly not
allow partial trusted caller, I agree with Alvin that you should first
check which assembly is the exact one that raise this error. Normally in a
public service hoster(with restricted code access permission policy), this
is common issue. And it is not necessarily your assembly, but could be some
other assemblies(syst em assembies) your assembly uses that raise this
error.

Generally, at development time, since your ASP.NET application is running
under Full Trust policy, there won't raise such CAS problem. At publich
shared hoster, CAS policy is restricted, if your application has called
some privileged code(according to .NET CAS permission), it may raise some
error. As for the "strong-name" or "AllowPartially TrustedCallers"
attribute, it is a typical approach use to create a wrapper assembly which
call those privileged code and install it into GAC. Here is a good MSDN
article detailedly describe ASP.NET 2.0 code access security and how to
deal with some common issues. You can have a look:

#How To: Use Code Access Security in ASP.NET 2.0
http://msdn2.microsoft.com/en-us/lib...0017_wrappingp
rivilegedcode

If you have any more specific questions, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.
May 3 '07 #4
Hi there

I have now identified what the problem is. As this post is now rather old
and partially irrelevant I'll start a new thread.

Thanks for your advice.
--
Regards

Martyn Fewtrell
"Martyn Fewtrell" wrote:
Hi there and thanks for the reply

To expand a little the error is as follows:

-----------------------------------------------

[SecurityExcepti on: That assembly does not allow partially trusted callers.]
BusinessLayer.e xRateFactory.Se rializeClass(ex Rate _exRate, String Path)
in exRateFactory.v b:91
BusinessLayer.e xRateFactory.Ge tExRate() in exRateFactory.v b:26
Test.Page_Load( Object sender, EventArgs e) in
D:\networkclub2 couk\wwwroot\we bservices\exRat e\Test.aspx.vb: 9
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +99
System.Web.UI.C ontrol.LoadRecu rsive() +47
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +6953
System.Web.UI.P age.ProcessRequ est(Boolean includeStagesBe foreAsyncPoint,
Boolean includeStagesAf terAsyncPoint) +154
System.Web.UI.P age.ProcessRequ est() +86
System.Web.UI.P age.ProcessRequ estWithNoAssert (HttpContext context) +18
System.Web.UI.P age.ProcessRequ est(HttpContext context) +49
ASP.test_aspx.P rocessRequest(H ttpContext context) +29

System.Web.Call HandlerExecutio nStep.System.We b.HttpApplicati on.IExecutionSt ep.Execute() +154
System.Web.Http Application.Exe cuteStep(IExecu tionStep step, Boolean&
completedSynchr onously) +64

-----------------------------------------------

exRateFactory and exRate are classes in the business layer. The two methods
which are called are GetexRate which basically sets a number of values on the
exRate class and SerializeClass which serializes the exRate class once the
values are loaded. Basically the exRateFactory either calculates new values
or takes the values from the serialized class according to certain perameters.

As far as I understand it when I build the solution the BusinesLayer.dl l is
copied to the bin foilder of the main application. The main application then
calls the classes from within the BusinessLayer.d ll. This works without issue
on the devlopment server.

When I upload the application to the Shared hosting environments all the
contents of the bin folder are copied to the bin folder on the live
application.

I'm assuming from the error message that the offending assembly is the
BusinessLayer.d ll

I have quite a few applications on this host built with the same basic
architecture (using BusinessLayer.d ll) buit have never come across this issue
before. As a result I am somewhet confused!

The development server and live server are set up as close to the same as
possible, same versions of ASP.Net etc but I have no control over the live
server as it is not mine. My hosting provider is however very helpfull.

I apologise if my explanations are muddled but despite reading several
articles on this im not entirly sure I fully understand the problems.

--
Regards

Martyn Fewtrell
"Steven Cheng[MSFT]" wrote:
Hi Martyn,

As for the problem you met, it is likely a typical .NET(ASP.NET) Code
access security issue. As the error message indicate some assembly not
allow partial trusted caller, I agree with Alvin that you should first
check which assembly is the exact one that raise this error. Normally in a
public service hoster(with restricted code access permission policy), this
is common issue. And it is not necessarily your assembly, but could be some
other assemblies(syst em assembies) your assembly uses that raise this
error.

Generally, at development time, since your ASP.NET application is running
under Full Trust policy, there won't raise such CAS problem. At publich
shared hoster, CAS policy is restricted, if your application has called
some privileged code(according to .NET CAS permission), it may raise some
error. As for the "strong-name" or "AllowPartially TrustedCallers"
attribute, it is a typical approach use to create a wrapper assembly which
call those privileged code and install it into GAC. Here is a good MSDN
article detailedly describe ASP.NET 2.0 code access security and how to
deal with some common issues. You can have a look:

#How To: Use Code Access Security in ASP.NET 2.0
http://msdn2.microsoft.com/en-us/lib...0017_wrappingp
rivilegedcode

If you have any more specific questions, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

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

May 5 '07 #5
Thanks for your reply Martyn,

I haven't got replied due to some other urgent business. How are you doing
and what's the problem you've identified? I think it is ok to continue to
discuss here or if you want, you can also feel free to create a new thread.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

May 8 '07 #6

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

Similar topics

3
2355
by: Dmitri Shvetsov | last post by:
Hi, Maybe somebody knows why it's happening? I wrote a C# Windows Application working with the remote database through a DataSet. It works cool from my computer but when I gave this application to my friend who (and only him) has to work with the database tables to edit them he began receiving the following message every time when a new window opens:
1
1385
by: Scott Meddows | last post by:
Is there an easy way for me to add something in my source code to give my code only partially trusted access so I can debug it? Thanks. Scott
2
4985
by: Vandana T | last post by:
I created a console application to read and manipulate an Excel file. I added reference to the Microsoft Excel 11.0 Object Library. When I place it in Network Drive and try to run the .exe from my system, it gives error 'That assembly does not allow partially trusted callers.' I tried to make the Network Drive where my Console Application is placed a trusted location in the .NET Framework 2.0 Configuration Tool, by adding a Child Code Group to...
1
6501
by: Matt Culbreth | last post by:
Hello All, I've got a very simple ASP.NET 2.0 application which uses a DLL from a third party. I don't have the source to this DLL. Everything has been working fine on my XP development machine, but as soon as I deploy to a Windows 2003 Server I'm getting the following error:
0
1301
by: Gibble | last post by:
Argh! Ok, now that that's out of my system. I'm getting this error "That assembly does not allow partially trusted callers". It only seems to happen when I try and call a function in an included project... For example, I have my main project, in it's load, I add a control from an included project, in it's load, I am calling a function in another included project...then BAM! Error.
1
2259
by: John G | last post by:
I have created an ActiveX control that does word automation. Once I creat an instance of work I get the following message System.Security.SecurityException: That assembly does not allow partially trusted callers. I am using .net 2. I have a key and use the regasm tool after it the dll is compiled I am really lost on how to make this work any help will be appreciated
1
7376
by: nish85 | last post by:
Hi, i have uploaded my sit to web server goddady.com i have a button to download dyanmically generated excel file.This button is ajax enabled.....When i am click on this button it will popup a message like "That assembly does not allow partially trusted callers" This is my web.config file Please help me on this issue? <?xml version="1.0"?>
3
2723
by: Joris van Lier | last post by:
I'm running an ASP.NET 2.0 web application in a Medium Trust environment, the application uses ODBC to connecto to MySQL and the hosting company has granted OdbcPermission, the solution includes a Visual Studio 2005 Web Deployment Project which is configured to add the AllowPartiallyTrustedCallers attribute to the assemblies. However I still get a SecurityException with the message "That assembly does not allow partially trusted...
0
1288
by: John G | last post by:
I tried creating a app with Silverlight. The app works great when I run it in vs.net 2008. But when I publish the app I get the following error: Assembly does not allow partially trusted callers I am attempting to do office automation. I have added allowpartiallyTrustedcallers to the assembly and I had the security tab set to Full Trust. Is there something I have do on client side. thanks,.
0
8197
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8640
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8287
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6093
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5548
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4136
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2573
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1438
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.