- Home /
Build argument -reference:ALIAS=DLL
My problem is the following. As I need to use System.Windows.Form namespace for Windows dialogs I first tried to use normal "Edit Reference" in MonoDevelop, search for the .dll in ...\Unity\Editor\Data\Mono\lib\2.0 and just adding it. This caused a problem because as I had algo as reference System, when I write using System.Windows.Form and then build the solution, it tells me that it didn't found 'Windows' in 'System' namespace. This is obvious because it didn't had to lookup there. So I solved it in mono by adding "/reference:WinForm=" in compiler additional arguments and in my class heading:
extern alias WinForm.
When I needed to use a namespace from that import I write for example:
WinForm::System.Windows.Forms.SaveFileDialog saveDialog = new WinForm::System.Windows.Forms.SaveFileDialog();
saveDialog.FileName = Path.GetFileName(myPathVar);
My problem now is that I can't access the compiler arguments in Unity. Error: Assets/scripts/GenerateFiles.cs(1,14): error CS0430: The extern alias `WinForm' was not specified in -reference option, where do I put -reference??
I have tried:
Unity.exe -batchmode -buildWindowsPlayer "PATH.TO.EXE.exe" -reference:WinForm="C:\Program Files (x86)\Unity\Editor\Data\Mono\lib \mono\2.0\System.Windows.Forms.dll" but it ain't working =S.
Thanks in advance.
Hi, I'm getting similar problem here. Did you ever figure out how to do this?
Answer by b4th · Feb 16, 2017 at 03:23 PM
You can access the compiler arguments in Unity by creating an smcs.rsp file in your project. These files are defined in the following doc:
https://docs.unity3d.com/Manual/PlatformDependentCompilation.html
Add your -reference flag into this file. Note that this file will not re-import automatically - you may need to right-click-reimport a script to refresh the project changes.
I've uploaded a sample project demonstrating this feature here: https://github.com/DashW/UnityExternAlias
Answer by timstark · Nov 05, 2019 at 07:40 AM
Hello @b4th
I have the same error, missing an extern alias.
I've downloaded your sample, but it's not working, either in my script.
I'm using Unity 2018.4.12f1. Is this outdated?,Hello @b4th
I'm also missing an extern alias: "Assets\TestBehaviour.cs(1,14): error CS0430: The extern alias 'ClassLibrary1' was not specified in a /reference option"
I've downloaded your sample project. But it's not working in your sample, either in my project.
I'm using Unity 2018.4.12f1. Could this be outdated? I'm not finding any newer answer.
Thanks in advance
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Cache Server doesn't work localy on Unity 5.6. 0 Answers
Custom Build Question?? 0 Answers
the main compilation does not work (for pc) 1 Answer
Unity force stop build to Android 2 Answers