Problem with Swift Dictionary in C# / .NET

Hi, I’m trying to create a Class Library DLL using Fire and Swift on my Mac to run on a Windows computer with a C# / .NET environment.

Creating a class library project with just this code:

import System.Collections.Generic

public class Algorithms {
	
	public static func optimizeCurrentLoans(user: Int, maximumNumberOfIterations: Int) -> [String: String] {
		return ["key": "value"]
	}
	
}

Fails when I run it. By trial and error I found it’s due to the dictionary.
Any idea why this is failing? I get a runtime exception, method not found.

Thank you.

What exactly is failing? this runs fine for me:

import System.Collections.Generic

public class Algorithms {
	
	public static func optimizeCurrentLoans(user: Int, maximumNumberOfIterations: Int) -> [String: String] {
		return ["key": "value"]
	}
	
}

print(Algorithms.optimizeCurrentLoans(user: 5, maximumNumberOfIterations: 8))

prints:

Floorshow:~ mh $ /usr/local/bin/mono "/Users/mh/Test Projects/ConsoleApplication146/bin/Debug/ConsoleApplication146.exe"
System.Collections.Generic.Dictionary`2[System.String,System.String]
Floorshow:~ mh $ 

Are you on 9.0 or the 9.1 gamma? if the former, can you try the latter?

Fire for me is on 9.0.27.2071 (master).

I’m running it on a C# / .NET Windows environment, importing the 3 generated DLLs, Echoes.dll, Swift.dll and ClassLibrary.dll.

And you’re probably creating a console application and running on your Mac, which also works for me.
What I’m trying to do is create a ClassLibrary in order to import the DLLs into another project (that has nothing to do with Silver, Swift or Fire).
Building on Fire works fine, I get a runtime error on Windows when I call the method.

Fire for me is on 9.0.27.2071 (master).

I’m running it on a C# / .NET Windows environment, importing the 3
generated DLLs, Echoes.dll, Swift.dll and ClassLibrary.dll.

And you’re probably creating a console application and running on your Mac,
which also works for me.
What I’m trying to do is create a ClassLibrary in order to import the DLLs
into another project (that has nothing to do with Silver, Swift or Fire).
Building on Fire works fine, I get a runtime error on Windows when I call
the method.

Obs.: I also tried buying a support ticket, but got a server error.

Can you send me the full project that shows this problem?

curious, whats the error you got, and on what page?

—marc

I’ll try getting you the project.

Thats the error I got (well, not me exactly, I would have saved a print… but who was making the purchase sent me this):

Curious. this happens every time, for you? when did you last try this, so i can check out logs against it — because i’m not even seeing any failed purchase attempts for today, at all…

Here is the project that is giving me the runtime error
ConsoleTestAppJoel.zip (194.0 KB)

That’s a Visual C# (,csproj) project, not an Elements one?

Correct.

What I need is a way to generate a DLL that runs on any C# / .NET platform.

I’m confused. you said you had a concrete problem with your Swift app not running. What dopes this .csproj have to do with it?

No, it’s not a Swift app, “I’m trying to create a Class Library DLL using Fire and Swift on my Mac to run on a Windows computer with a C# / .NET environment”.

I need to write some code in Swift and generate a DLL that will run on a regular C# / .NET project on Windows.

Ok, then got ahead and do that. i’m still not understanding what exactly is not working?

The project I sent you is giving me a runtime error.

To clarify, the project is importing the DLLs generated by Fire/Silver and calling the Algorithms static method and then giving me the runtime error.

Ok. obviously i can’t help you with VC# projects, as those aren’t using our compiler. i’ll need the actual Elements (i.e. Swift) project.

But the issue is inside the generated DLLs.
Aren’t those supported on any other platform?

The issue is not with the compiler, it’s a runtime error.

This is the Swift project I’m using to generate the DLLs.
ClassLibrary.zip (685.9 KB)

right. bit i cant really comment on what coukld be wrong with the dll without having the project that created it, right?

FTR, there’s no “other platform:” here you’re building a .NET dll wit Elememts and using that .NET dll in a .NET project.

thanks. i’ll have a look at this tomorrow.

Thank you for helping me.

I also ended up buying a support ticket, should I ask the question there or just wait here?

Here is fine for me, if it’s for you.

Thanks, logged as bugs://77576