Error "Could not load file or assembly Microsoft.CodeAnalysis" when debugging strategy in VS2017
Author: yuriverges
Creation Date: 2/26/2020 12:58 PM
profile picture

yuriverges

#1
Good Morning ....

I have a VS Project to help debug my WL strats and since I´ve installed the latest release of Wealthlab an error have been ocurring.

After I´ve built my project for the first time and the dlls inside MS123 folder were overriden, everytime that I open an script in WL (not in visual studio), the error below happens and the platform crashes.


I thought it was a compatibility error consequence of the .net framework, but this wasn´t the case, since ive updated the framework in my machine and also in my project and the error still present.


Do you have any guess about the reason of this error?

Tks

Yuri


PS. Also I saved the original WL Microsoft.CodeAnalysis dll and tried to used this oneto build my Project and the error persisted.


See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Microsoft.CodeAnalysis, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at WealthLabPro.Editor..ctor(ChartForm chartWindow)
at WealthLabPro.ChartForm.set_Strategy(Strategy value)
at WealthLabPro.MainForm.OpenStrategyWindow(Strategy s, Boolean executeOnSelectedSymbol, Boolean useAdvancedSettings)
at WealthLabPro.MainForm.OpenStrategyWindow(Strategy s, Boolean executeOnSelectedSymbol)
at WealthLabPro.MainForm.OpenStrategyWindow(Strategy s)
at WealthLabPro.MainForm.OpenStrategyExplorer()
at WealthLabPro.MainForm.b0(Object A_0, EventArgs A_1)
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].


************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
profile picture

Eugene

#2
Hi Yuri,

Apparently the upgrade frm 6.9.15 to 6.9.22 did not go correctly for you. First of all I recommend you do a clean reinstall using this procedure:

1. Uninstall WLD
2. Completely remove the main folder under Program Files to get rid of any "DLL-Hell" effects. Do not save any files
3. Do a clean install
4. Reinstall all required Extensions from our gallery

QUOTE:
After I´ve built my project for the first time and the dlls inside MS123 folder were overriden,

The program DLLs inside the main folder should not be overridden, only your Strategy library's DLL should. To ensure, click through all respective References in Solution Explorer and choose "Copy Local = false".

QUOTE:
PS. Also I saved the original WL Microsoft.CodeAnalysis dll and tried to used this oneto build my Project and the error persisted.

It should not be required once you perform a clean reinstall and fix your VS project.
profile picture

Eugene

#3
<<To ensure, click through all respective References in Solution Explorer and choose "Copy Local = false".>>

In case it wasn't evident here's an illustration:

profile picture

yuriverges

#4
Hi Eugene! Actually I was doing exactly as you are instructing ... but the problem is that, when I rebuild or clean my Project/Solution, actually it cleans the dlls inside WL instalation folder associated with the .NET framework ....
profile picture

Eugene

#5
I have probably close to half a hundred solutions now (public, in-house and private) targeting my WL installation folder. Never did VS "clean" Wealth-Lab's DLLs except the compiled binaries themselves. I think your VS workflow is somewhat misconfigured. Here are some suggestions:

1. Did you try to use our Strategies.ActiveTrader solution as the starting point? It's preconfigured correctly.
2. .dll's are missing after rebuild/clean-build solution
profile picture

yuriverges

#6
Hi! I just found the problem. I had the package R.Host.Client.API installed in my Project, which depends on Newtonsoft.Json that by consequence depends on Microsoft.CodeAnalysis (WL also depends on this dll too, but on a different version).


As a result, every time that I was cleaning my Project, all dlls that could present a dependency were being deleted. I guess this conflict is a consequence of different versions of .net. Which is the current being used in WL?

profile picture

Eugene

#7
Glad you found the culprit. Please follow procedure in post #2 above to reinstall the version of Microsoft.CodeAnalysis used by WL.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).