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

  • SEARCH
  • Home
  • 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 4531618
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T13:55:37+00:00 2026-05-21T13:55:37+00:00

I was under the impression Mono’s compiler was usable in Microsoft.NET edit: updated blog

  • 0

I was under the impression Mono’s compiler was usable in Microsoft.NET

edit: updated blog posting here that I originally missed that explains some of it (is consistent with Justin’s answers)

I created a simple class to try to use it

[TestFixture]
class Class1
{
    [Test]
    public void EXPR()
    {
        Evaluator.Run("using System;");

        int sum = (int)Evaluator.Evaluate("1+2");

    }
}

And a project in Visual Studio 2010 that references C:\Program Files (x86)\Mono-2.10.1\lib\mono\4.0\Mono.CSharp.dll.

However when I try to run this task I get the following exception, thrown at the Evaluator.Run call:

    System.TypeInitializationException was unhandled by user code
      Message=The type initializer for 'Mono.CSharp.Evaluator' threw an exception.
      Source=Mono.CSharp
      TypeName=Mono.CSharp.Evaluator
      StackTrace:
           at Mono.CSharp.Evaluator.Run(String statement)
           at Experiments.Class1.EXPR() in W:\Experiments\Class1.cs:line 16
      InnerException: System.TypeLoadException
           Message=Method 'Mono.CSharp.Location.ToString()' is security transparent, but is a member of a security critical type.
           Source=Mono.CSharp
           TypeName=Mono.CSharp.Location.ToString()
           StackTrace:
                at Mono.CSharp.Evaluator..cctor()
           InnerException: 

A google confirms one other person asking this question but no answer. I tried to start reading the microsoft article on security transparent code but got confused quite quickly. Would someone be able to suggest a quick workaround to allow me to use this? And possibly summarise the security implications, if any, to me (in the context of my situation – in the future I hope to package it with a thick client application, to be used both internally and by end-users)

  • 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-21T13:55:38+00:00Added an answer on May 21, 2026 at 1:55 pm

    It looks like this is a bug in Mono.

    .NET 4 abandoned Code Access Security but kept the concept of Security Transparent Code. In a nutshell, low-level code that does stuff, like call unmanaged code, must be “security critical”. Application level code is marked “transparent”. “Transparent” code cannot call into “security critical” code.

    It sounds like Mono.CSharp.Location.ToString() needs to be marked with the [SecuritySafeCritical] attribute if you want the Mono 2.10 code to work with .NET 4. Maybe even better would be marking all of Mono.CSharp as SecuritySafeCritical.

    http://msdn.microsoft.com/en-us/library/system.security.securitycriticalattribute.aspx

    PS. Sorry to have multiple answers for one question. After I realized that 2.11 would work, I became more curious about what the error with 2.10 meant. I cannot really combine this answer with the others.

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

Sidebar

Related Questions

I was under the impression that I could run it on any machine, but
I'm under the impression that the Dot '.' (wild card) character is dangerous to
I've long been under the impression that goto should never be used if possible.
I was under the impression that the format() function of the PHP DateTime class
Till recently, I was under the impression that if you detach a thread after
From the reading I've done I'm under the impression the DataContractSerializer handles versionong issues
Under VS's external tools settings there is a Use Output Window check box that
Under what circumstances might you want to use multiple indirection (that is, a chain
Under Windows XP WPF true 3D content (which is usually displayed using the Viewport3D
Under what circumstances - if any - does adding programmers to a team actually

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.