One of the most cryptic errors you can encounter when consuming or exposing WCF services in BizTalk is the SecurityException. It usually looks like this:
“Exception: System.ServiceModel.ServiceActivationException: The service ‘/MyService/Service.svc’ cannot be activated due to an exception during compilation. The exception message is: That assembly does not allow partially trusted callers.. —> System.Security.SecurityException: That assembly does not allow partially trusted callers.”
📝 One-Minute Brief
When running BizTalk WCF adapters, you may encounter a SecurityException stating that the assembly does not allow partially trusted callers. This usually happens because the WCF runtime requires Full Trust to execute certain security or serialization operations. The solution involves ensuring the BizTalk Host Instance account has the necessary local administrative permissions or, more accurately, modifying the .config files or machine trust levels to allow the WCF stack to operate without security restrictions.
This error occurs when the WCF adapter attempts to perform an operation that requires Full Trust, but the environment or the BizTalk Host Instance is restricted by .NET Code Access Security (CAS).
Solution
After some research, I found that I’m getting this problem because the WCF service requires full-trust permission to run from the server. One way to solve the problem is:
- Open the web.config file in Notepad
- In <system.web> section add the following tag:
<trust level="Full" originUrl=""/>
For example:
<configuration>
<system.web>
<trust level="Full" originUrl="https://api.sandro-pereira.com/"/>
</system.web>
</configuration>
These steps solved my problem.