0

Build the sample code, and run any test. (I tried abs.)

Each time I do it, I get TypeLoadException:

An exception of type 'System.TypeLoadException' occurred in Jurassic.dll but was not handled in user code

Additional information: Inheritance security rules violated by type: 'Jurassic.Compiler.WhiteSpaceToken'. Derived types must either match the security accessibility of the base type or be less accessible.

The problem is WhiteSpaceToken is a simple class, as so is Token, its base. So it looks like exception is not actually providing accurate information about the class name, and the error is probably caused by some other code.

My understanding is nearly 0 at this case. The only explanation I could possibly imagine is that you can't inherit an abstract class from portable library, but I've never heard about this kind of restriction.

Any ideas why is this happening?

P.S. Adding some quick info about code structure, as requested in comment

  1. Token class is a public abstract class in a portable library targeted to .NET 4, Silverlight 5, Windows 8, and Windows Phone 8. It only works with string class from mscorlib.
  2. WhiteSpaceToken is in a normal assembly, targeted to .NET 4. It inherits from Token. Also only works with int and string.
  3. Neither class has any attributes in its code.
  4. The unit test assembly is a normal unit test assembly on MSTest targeted 4.0
Community
  • 1
  • 1
LOST
  • 2,956
  • 3
  • 25
  • 40
  • 2
    Its doubtful people will download, build and run something you have provided via a url. This site runs off small, complete examples of issues. Perhaps rephrasing your question will help with answers. – Simon Whitehead Dec 24 '13 at 22:14
  • I'm looking more for insights, than for someone to actually go debug, and figure out what can be the cause. But thanks for the advice, I'll add some quick info – LOST Dec 24 '13 at 22:30

3 Answers3

5

I found source of the problem: it was System.Security.AllowPartiallyTrustedCallers set on the non-portable assembly, which contains WhiteSpaceToken. After I removed it, issue was gone. Looks like portable code had transparent model, which caused WhiteSpaceToken to be more loose in the sense of security, than Token, which in turn caused the problem as described in exception message.

Wish I those messages be more specific.

LOST
  • 2,956
  • 3
  • 25
  • 40
3

your question and answer helped me a lot, thanks!!!

I've solved my issue by opening the project properties and in the Security tab I've unchecked the "Enable ClieckOnce security settings".

silver
  • 1,633
  • 1
  • 20
  • 32
  • Wow. this problem appears in many different places. I was looking for it everywhere across the internet and nothing but this simple thing helped me. Thank you! – Andrei Jul 04 '16 at 20:50
  • 1
    Where is the security tab? I've tried the project properties and it's not there in VS2017 – Luke Jan 01 '18 at 13:44
  • Its not there on a web project I dont think as I can't see it either – djack109 Jul 24 '19 at 18:29
0

in my case system.net.HTTP caused error. i update it to latest version and fixed issue

Ali Sadri
  • 1,570
  • 14
  • 15