I am using a nuget package called QuickFix/n and an external DLL. Both are NETStandard 2.0. If I use just one or another in my application, it works fine, but if I use both, I get the error message below when creating the QuickFix.Transport.SocketInitiator:
"System.TypeLoadException: 'Could not load type 'mtapi.mt5.Struct.TradeRequestInternal' from assembly 'mt5api, Version=4.3210.2.0, Culture=neutral, PublicKeyToken=null' because it contains an object field at offset 4 that is incorrectly aligned or overlapped by a non-object field.'"
Also if I remove the line "mtapi.mt5.FillPolicy fillPolicy = mtapi.mt5.FillPolicy.FillOrKill;", it works.(https://prnt.sc/H0IXBnKaAmkD)
I have tried removing all the "using" but it didn't work: https://prnt.sc/pOP_JJL_UB3v
It also works if I don't use QuickFix.(https://prnt.sc/YNCHUHns1Aop)
The error message: https://prnt.sc/wmpquTvZtWe4
My code:
using QuickFix;
using QuickFix.Fields;
using mtapi;
namespace TestApp2
{
class Program
{
public static void Main(string[] args)
{
TestClass testClass= new TestClass();
mtapi.mt5.FillPolicy fillPolicy = mtapi.mt5.FillPolicy.FillOrKill;
testClass.Start();
Console.WriteLine("done");
}
}
class TestClass : QuickFix.IApplication
{
public IInitiator MyInitiator;
public TestClass()
{
SessionSettings sessionSettings = new SessionSettings(@"G:\Saját meghajtó\Links\config-LMAXFIX.cfg");
QuickFix.IMessageStoreFactory storeFactory = new QuickFix.FileStoreFactory(sessionSettings);
this.MyInitiator = new QuickFix.Transport.SocketInitiator(this, storeFactory, sessionSettings);
}
public void Start() => this.MyInitiator.Start();
public void FromAdmin(Message message, SessionID sessionID) => throw new NotImplementedException();
public void FromApp(Message message, SessionID sessionID) => throw new NotImplementedException();
public void OnCreate(SessionID sessionID) => throw new NotImplementedException();
public void OnLogon(SessionID sessionID) => throw new NotImplementedException();
public void OnLogout(SessionID sessionID) => throw new NotImplementedException();
public void ToAdmin(Message message, SessionID sessionID) => throw new NotImplementedException();
public void ToApp(Message message, SessionID sessionID) => throw new NotImplementedException();
}
}
I am a newbie and would like to know what is going on here and how can I avoid this conflict?