• 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 wkrp · Jul 08, 2013 at 11:45 PM · c#errordllsubclassingtypeloadexception

How is it best to distribute a complex unity project to other devs as asingle dll

I have a complex Unity project that I would like to distribute to a couple of other devs. They need to be able to write some new classes that subclass a particular class in the project.

However it's a requirement that the code content of the main project itself, preferably including the class they need to subclass, is not accessible to the devs. [EDIT: It's only the source code they can't access. They can still use the class, and will have documentation.]

Ideally the project I distribute would include one dll that contains the all of the classes from the original project.

The approach I have taken is as follows (it may be overly simplistic - I've not worked with .NET outside a Unity context)

1) Take the original project and get the Assembly-CSharp.dll that it has compiled from the Library/ScriptAssemblies folder

2) Create a new project, and place the dll in the Assets folder and rename it.

Note:Not renaming it causes the following error - I'm assuming the name is reserved

ApplicationException: Unable to find a suitable compiler UnityEditor.Scripting.ScriptCompilers.CreateCompilerInstance (MonoIsland island, Boolean buildingForEditor, BuildTarget targetPlatform) (at C:/BuildAgent/work/812c4f5049264fad/Editor/Mono/Scripting/ScriptCompilers.cs:99)

T$$anonymous$$s works and satisfies the requirement of having one dll that i could distribute.

The problem I have occurs when I add new scripts that try to subclass a class that is wrapped in the dll.

So for instance if the dll packages a class such as

  namespace MyNameSpace {
     
     public class  Fruit: IFruit  {
 
     }
     ..
     ..
    
  }

and I create a new script called Banana that attempts to subclass Fruit

 namespace MyNameSpace
 {
 
     public class Banana : Fruit, IFruit {
 
     }
     ..
     ..
 
 }

T$$anonymous$$s causes a runtime exception TypeLoadException: Could not load type 'MyNameSpace.Banana' from assembly 'Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

I haven't so far been able to find out why t$$anonymous$$s is. Is it related to changing the name of the dll? Or is there somet$$anonymous$$ng fundamental about the Assembly-CSharp.dll that i took from the original project that mean it can't be used in t$$anonymous$$s way? As I say I don't have a background in .NET, so I realise what I'm doing maybe somewhat naiive.

Also, I have experimented with compiling individual scripts, and groups of scripts, into dlls, and extending classes embedded i those dlls without any problems. I've used Assembly Builder ( http://studio.foriero.com/products/assembly-builder/assembly-builder.php ) to do t$$anonymous$$s and it works fine for compiling a limited number of scripts (w$$anonymous$$ch it is what it's built for). It seems to have problems with large numbers of classes. So if I try to build my entire project like that it will crash. I could also look at compiling the project into a number of dlls, however I have some significant refactoring I'd have to do, and t$$anonymous$$s is time sensitive.

I'm also open to suggestions of completely different ways of doing t$$anonymous$$s, it may even be that I'm missing somet$$anonymous$$ng really obvious?

Anyway, I appreciate any help I can get!

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 Kiloblargh · Jul 08, 2013 at 11:53 PM 1
Share
avatar image Benproductions1 · Jul 09, 2013 at 12:25 AM 0
Share

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by wkrp · Jul 09, 2013 at 07:42 AM

All sorted using Visual Studio to create a separate project. Compile the scripts into a dll and then used the dll in the project I want to distribute.

Comment
Add comment · 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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

Importing C++/CLI DLL causes errors 0 Answers

.DLL can't build for Windows Standalone. 0 Answers

Distribute terrain in zones 3 Answers

Error Building Player: Extracting dlls 1 Answer

Connecting external application (e.g. Notepad) to Unity 0 Answers


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