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 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)

This 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 {
 
     }
     ..
     ..
 
 }

This 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 this is. Is it related to changing the name of the dll? Or is there something fundamental about the Assembly-CSharp.dll that i took from the original project that mean it can't be used in this 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 this and it works fine for compiling a limited number of scripts (which 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 this is time sensitive.

I'm also open to suggestions of completely different ways of doing this, it may even be that I'm missing something 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

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.

Wat? Are you hiring shady people, or working for a pointy-haired boss..? Either way, sounds like you've got a rather dysfunctional company structure, addressing which would be my first suggestion as to "completely different ways of doing things. "

avatar image Benproductions1 · Jul 09, 2013 at 12:25 AM 0
Share

Um... so you want dev's to subclass, without the class they are subclassing????

Also, format your code

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.

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

DLL problems for MySql 0 Answers

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

When I build my game it gives me this error 'Assets/Builds/Build_0.01_Data/Managed/Assembly-CSharp.dll' shouldn't be queried by IsAssemblyCompatible, missing IsInternalOrCompiledAssembly check ? 2 Answers

Distribute terrain in zones 3 Answers

How do I; when building, make Unity ignore .net asembly referencing the UnityEditor assembly ? 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