Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3609800
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:40:24+00:00 2026-05-18T21:40:24+00:00

Together with Ben (@BuildStarted), we’ve been building the RazorEngine project , which is designed

  • 0

Together with Ben (@BuildStarted), we’ve been building the RazorEngine project, which is designed to allow you compile and parse arbitrary templates outside of ASP.NET MVC. The project has had a couple of releases for a while now, and the feedback has been great (thanks to all!). But, we have encountered an issue: Medium trust.

Because we are using the CSharpCodeProvider to compile the Razor-generated classes (to load into the current AppDomain for execution), we encounter a SecurityException when trying to invoke it, due to the LinkDemand enforced on it. When a normal ASP.NET page is compiled (regardless of trust level), it does so through a BuildProvider which is normally GAC’d, and thus is implicity granted the appropriate permissions to compile. Hence ASP.NET WebForms works as standard in Medium trust.

Our code does not, and we need to target scenarios where our built library won’t be deployed to the GAC and is running in Medium trust. So we considered building a BuildProvider specifically for it and defer compilation to the ASP.NET build system, but this seems overly complex and disjointed, and the provider itself requires both a mapping through a file extension, and a virtual path (which may or may not resolve to a physical file – think VirtualPathProvider). It all seems overkill, just to get the project working in Medium trust; not just that, but purely for ASP.NET projects as our engine also works outside of ASP.NET

So my question is this, does anyone know of any techniques or technologies for compiling C# code in a Medium trust environment?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:40:24+00:00Added an answer on May 18, 2026 at 9:40 pm

    Perhaps you could consider using MCS (Mono Compiler Service), which has the possibility to emit to an in memory assembly instead of a file (yes, I know CSharpCodeProvider has the ability for in memory only, but it still writes temp files and performs file system operations).

    Caveat: You’ll probably run into security issues with MCS too, but it’s open source (obviously) and I’ve been able to modify it so as to do expression compilation in Silverlight… Just saying, it’s probably not going to be a piece of cake.

    Update: Per the Mono roadmap page, my modifications aren’t really necessary anymore since they say they support Silverlight out of the box in version 2.8.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I put together some VBA code for Outlook 2007 which has been working predominantly
I am putting together some ideas for our automated testing platform and have been
I'm working now together with others in a grails project. I have to write
I've put together several reports which render exactly as I'd like them to in
I have recently put together a JWS application which gets it's argument from a
I've been putting together an auditing solution for a program I am developing, where
Have been hacking together a couple of libraries, and had an issue where a
As I put together each asp.net page It's clear that most of the time
I am putting together a proposal for a large multinational company for our licenced
How do I concatenate together two strings, of unknown length, in COBOL? So for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.