我有以下的C#類,我想利用在F#錯誤在F#腳本文件創建C#類的實例
using System;
using System.Collections.Generic;
using System.Text;
namespace DataWrangler.Structures
{
public enum Type { Trade = 0, Ask = 1, Bid = 2 }
public class TickData
{
public string Security = String.Empty;
public uint SecurityID = 0;
public object SecurityObj = null;
public DateTime TimeStamp = DateTime.MinValue;
public Type Type;
public double Price = 0;
public uint Size = 0;
public Dictionary<string, string> Codes;
}
}
我想在F#創建它的一個實例。我使用的這個過程的代碼是在F#腳本文件
#r @"C:\Users\Chris\Documents\Visual Studio 2012\Projects\WranglerDataStructures\bin\Debug\WranglerDataStructures.dll"
open System
open System.Collections.Generic;
open System.Text;
open DataWrangler.Structures
type tick = TickData // <- mouse over the "tick" gives me a tooltip with the class structure
// it bombs out on this line
let tickDataTest = tick(Security = "test", TimeStamp = DateTime(2013,7,1,0,0,0), Type = Type.Trade, Price = float 123, Size = uint32 10)
我得到的錯誤是:
error FS0193: internal error: Could not load file or assembly 'file:///C:\Users\Chris\Documents\Visual Studio 2012\Projects\WranglerDataStructures\bin\Debug\WranglerDataStructures.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
我檢查了文件路徑,他們似乎是正確的。我可以將鼠標懸停在'類型'上,它給了我C#對象的結構。所以它似乎在找到C#代碼。任何人都可以告訴我我在這裏做錯了什麼?句法?還是很新的C# - > F#introp
我可以運行你的代碼沒有任何問題。也許你忘記了alt +進入F#交互的'#r'行? –
沒有。它給了我正確的反饋,當我點擊該行:'Referenced'C:\ Users \ Chris \ Documents \ Visual Studio 2012 \ Projects \ WranglerDataStructures \ bin \ Debug \ WranglerDataStructures.dll'' –
如何刪除'type tick'並使用'新的TickData'來創建對象實例? –