- Home /
Custom DLL - MissingMethodException: string[] string.Split
For some reason, I can't get string.split to work from within the dll. (I can successfully use it in Unity/C#)
Here is a snip of my C# code in a separate solution:
using System;
using System.Collections.Generic;
namespace DLLPackage
{
public class TimeSheet : BaseObject
{
public TimeSheet(string builder)
{
string[] elements = builder.Split(',');
}
}
}
Everything compiles great. I put the dll in my assets/plugins folder.
namespace UnityApp
{
public static class Portfolio
{
public static void Example()
{
TimeSheet t = new TimeSheet("-1,0,0,0");
//MissingMethodException: string[] string.Split(char,System.StringSplitOptions)
}
}
}
I have tried various cleans/rebuilds/renames that I found while googling. Nothing seems to help, it's ONLY this system method. I can call other system methods, my own methods, my own constructors no problem.
Answer by Fillmore · Mar 09, 2018 at 10:44 PM
Alright, after I wasted half a day on this, if anyone finds this - Your solution template is wrong. Also see below @AllanSmithZ3 and @Otto_Oliveira answers. Depending on your use case, try the various settings until you get something that will work for your project.
(On OSX) When I made a new solution I selected "Class Library .NET Core". I made a "Portable Library Multiplatform" with my same files, and it fixed it.
The only thing that tipped me off was on this page: https://msdn.microsoft.com/en-us/library/tabh47cf(v=vs.110).aspx It says: Portable Class Library Supported in: portable .NET platforms
Not 100% sure if this solution type is what I should continue with, but it seems to be working for now.
Answer by Otto_Oliveira · Mar 31, 2019 at 09:56 PM
Hi @Fillmore , In my case, I fixed this creating a Empty C# Project and then adding the necessary References, as you can see the 'System' assembly.
Using this method it's also necessary to change the Compile Target to Library. Currently I'm using Unity 2018.3 so I kept the Target Framework to 4.7.1
Answer by AllanSmithZ3 · Jun 07, 2019 at 05:10 PM
Hey @Fillmore, answering about one year later but... since PLC is deprecated now its a better idea to create .NET Standard 2.0 class library instead of PLC, and it solves this problem as well. I know because I literally just did this, first I was following your answer, then noticed that System.Serializable doesnt work for PLC, but it does for .NET Standard 2.0, so I changed my projects back to .NET Standard 2.0 and finally string.split is working.
At any rate, thanks for the original answer haha, had you not posted it I probably would have taken years to figure it out that you need a different project type...
Your answer

Follow this Question
Related Questions
How to split a string into array? 2 Answers
Extract number from string? 3 Answers
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
Unity JS Equivalent of split()? 2 Answers
How to split String? 1 Answer