Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Benproductions1 · Aug 23, 2013 at 08:57 AM · reflectionscript loadingreference assemblies

Limit namespace access on compiled scripts

Hello, I'll try and keep this as brief as possible:

I am building a sort of modding system for a certain aspect of my game.
It basically allows the common user to write some C# code which will be used to give access to certain elements of the game at certain times. Like giving the host of a multiplayer server the ability to decide what map to load with what parameters etc...

I already have the assembly loading working. It's quite neat and not very complicated XD
But now I've come to the point where it would be very nice if I could give the "user" some access to assemblies such as System and UnityEngine.
I could of course include the dll's in the ReferenceAssemblies property of the CompilerParameters, but that would give them access to possibly harmful functionality, such as reflection, Instantiation, Destroy as well as many others...

How would I limit the assembly references to only certain namespaces, such as System.IO and System.Collections, without giving access to System.Reflection?

Now for the posting of some possibly relevant code:

 //Excuse the UnityScript... I find it quicker to do things in
 //Create compiler parameters
 var params:CompilerParameters = new CompilerParameters();
 params.GenerateExecutable = false;
 params.GenerateInMemory = false;
 //Add assembly reference
 params.ReferencedAssemblies.Add("System.dll");
 //I wish I could put System.IO in here instead of System.dll
 
 //Create provider and load/compile assembly
 var provider:CodeDomProvider = new CodeDomProvider.CreateProvider("CSharp");
 var results:CompilerResults = provider.CompileAssemblyFromFile(params, path);

I hope this is even possible ;)
Thank you,
Benproductions1

EDIT:

I forgot to add: Is it possible to add: Is it possible to add the current Assmbly to that list? So I could inherit a class etc., or do I have to make my own assembly and include that in the project? (Not that it's hard, just a minor pain XD)

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Aug 23, 2013 at 09:19 AM 0
Share

This sounds a bit like a question for StackOverflow to me... It's that kinda complicated.

It would probably be better if you wrote some kind of facade DLL to the bits you wanted from the system libraries and your own types and then add a reference to that (now I'm not convinced you wouldn't have to reference all of the others too though if you didn't repeat the structures).

avatar image Benproductions1 · Aug 23, 2013 at 09:27 AM 0
Share

@whydoidoit I was thinking of writing some sort of wrapper for all the necessary System functions, but with the amount of stuff that would be useful and safe is enormous and I don't have that much time ;)
^- why I asked the question

$$anonymous$$aybe I should go ask this on Stack Overflow, thanks for the tip

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by HappyMoo · Jan 07, 2014 at 10:36 AM

Have you seen this?

CAS: http://stackoverflow.com/questions/3807069/net-security-limiting-runtime-loaded-assemblies-from-accessing-certain-apis

MAF: http://stackoverflow.com/questions/1520113/restrict-plug-in-assembly-code-access

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Benproductions1 · Jan 08, 2014 at 12:55 AM 0
Share

Thanks for the links! I'll check out $$anonymous$$AF, but it seems that $$anonymous$$ono doesn't support CAS...

There is no planned release date to support CAS in $$anonymous$$ono

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

HashTable could not be found 1 Answer

Can anybody tell me why reflections are not smoother from 2nd reflection? The first reflection is smooth but later ones aren't smooth. Please find the attached gif. 1 Answer

How do I open editor windows using internal methods? 2 Answers

How to make a system that can be both manually controlled and automatized through a sorto of a simplified coding system? 0 Answers

On disabling light, the illumination of it still remains 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges