neo-project / examples

MIT License
138 stars 135 forks source link

Error when building ICO_Template #11

Closed Chubby-Chocobo closed 6 years ago

Chubby-Chocobo commented 6 years ago

To whom it may concern, I checked out repos at the latest commit 3544cc42d4c9c8f868ce22dca51f83af0fccf744 When building ICO_Template project this error occurs:

1>------ Rebuild All started: Project: ICO_Template, Configuration: Debug Any CPU ------
1>  ICO_Template -> C:\workspace\examples-csharp\ICO_Template\bin\Debug\ICO_Template.dll
1>  Start NeoContract converter, Source File: C:\workspace\examples-csharp\ICO_Template\bin\Debug\ICO_Template.dll
1>  Neo.Compiler.MSIL console app v2.0.3.0
1>CONVERTTASK : LoadModule error : System.Exception: can't parese event type from:System.Action`3<System.Byte[],System.Byte[],System.Numerics.BigInteger>.maybe it is System.Action<xxx> which is defined in mscorlib.dll,copy this dll in.
1>     at Neo.Compiler.MSIL.ILField..ctor(ILType type, FieldDefinition field)
1>     at Neo.Compiler.MSIL.ILType..ctor(ILModule module, TypeDefinition type)
1>     at Neo.Compiler.MSIL.ILModule.LoadModule(Stream dllStream, Stream pdbStream)
1>     at Neo.Compiler.Program.Main(String[] args)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

My system specs:

Windows 10 Education
MS Visual Studio Professional 2017 - Version 15.4.5
MS .NET Framework Version 4.7.02053

Could you please take a look into this issue?

One more thing, I'm new in NEO world and looking for a tutorial/example to implement an ICO, like https://aphelion.org/ Is there any more detailed example/tutorial for newbie to understand and follow?

Many thanks,

erikzhang commented 6 years ago

Try the latest version of compiler: https://github.com/neo-project/neo-compiler

Chubby-Chocobo commented 6 years ago

I've tried the latest version of compiler, but the error still occurs.

erikzhang commented 6 years ago

@lightszero Can you check this?

lightszero commented 6 years ago

you need to find a mscorlib.dll from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework and copy it to where Neo.SmartContract.Framework.dll and .avm is.

Chubby-Chocobo commented 6 years ago

@lightszero Thanks for your suggest, but the error still occurs in my case. I tried to copy dll and pdb files of ICO_Template project to the same folder with neon.exe, then run neon ICO_Template.dll there and got the avm file finally.

I deployed that contract to testnet, but it seems there's no new asset is registered. Is there's any guide/documents about how to use this ICO_Template project correctly, and how to make an ICO like Aphelion? Could you please give me some guide/advice @erikzhang Or is there a forum/community for NEO developers that I can look for help there? Many thanks,

tanZiWen commented 6 years ago

623dd85263998b768e8cec7fa0d5aca7

Try copy mscorlib.dll to you directory C:\workspace\examples-csharp\ICO_Template\bin\Debug\

facadev commented 6 years ago

Any instruction for Mac users given the full-fledged .NET Framework doesn't support macOS? @tanZiWen tan

apisit commented 6 years ago

I'm also on mac. got this error when I am trying to compile ICO_Template.dll

LoadModule Error:System.Exception: can't parese event type from:System.Action`3<System.Byte[],System.Byte[],System.Numerics.BigInteger>.maybe it is System.Action<xxx> which is defined in mscorlib.dll,copy this dll in.
   at Neo.Compiler.MSIL.ILField..ctor(ILType type, FieldDefinition field) in /Users/xxxx/xxxx/neo-compiler-master/neon/MSIL/ILModule.cs:line 127
   at Neo.Compiler.MSIL.ILType..ctor(ILModule module, TypeDefinition type) in /Users/xxxx/xxxx/neo-compiler-master/neon/MSIL/ILModule.cs:line 73
   at Neo.Compiler.MSIL.ILModule.LoadModule(Stream dllStream, Stream pdbStream) in /Users/apisit/Downloads/neo-compiler-master/neon/MSIL/ILModule.cs:line 48
   at Neo.Compiler.Program.Main(String[] args) in /Users/xxxx/xxxx/neo-compiler-master/neon/Program.cs:line 71

I tried copying mscorlib.dll into where ICO_Template.dll is located but doesn't seem to help.

I was able to compile the simple HelloWorld just fine.

apisit commented 6 years ago

I finally have this solved.
this is the updated code for ICO_Template.cs

public delegate void MyAction<T, T1>(T p0, T1 p1);
public delegate void MyAction<T, T1, T2>(T p0, T1 p1, T2 p2);

[DisplayName("transfer")]
public static event MyAction<byte[], byte[], BigInteger> Transferred;
[DisplayName("refund")]
public static event MyAction<byte[], BigInteger> Refund;

big thanks to jianying li(a coder) on discord. kindly help me debug this.

It's about System.Action that is defined in mscorlib.dll on windows but in mono it's maybe in somewhere else. making neon.dll unable to find it.

So if you write a smart contract in C# on mac. do not use System.Action

mwherman2000 commented 6 years ago

I've also documented the problem (and solution) here ...with some step by step instructions: https://github.com/mwherman2000/neo-windocs/blob/master/windocs/neo-problems/ICO-Template-Problems.md

NeoParticle commented 6 years ago

Hi, Copying mscorlib.dll to debug or release folder is not a straight forward solution. Add mscorlib.dll into solution and in property of the added file, set "Copy to Output Directory" to "Copy always"

niastakevin commented 6 years ago
  1. open example-csharp-master
  2. open example.sln with visual studio
  3. re-install Neo.SmartContract.Framework on ICO Templates (remove Neo.SmartContract.Framework first) (then right clik on reference, choose Manage NuGet Packages, uninstall Neo.SmartContract.Framework, install again)
  4. Add Reference--> Assemblies --> choose mscorlib.dll then OK)
  5. Build the ICO Templates C#

worked with me.

Chubby-Chocobo commented 6 years ago

Some above workaround helps.