Error using AlgLib library
Author: wbzhang
Creation Date: 10/7/2010 10:25 PM
profile picture

wbzhang

#1
I built an external library AlgLib for some math computation. This library has no any other dependencies.
In my strategy builder, I add this library (AlgLib.DLL) as references. I can compile my strategy successfully, but got run-time error:

QUOTE:
Runtime error: Could not load file or assembly 'AlgLib, version=1.0.3932.39070,Culture=neutral, PublicKeyToken=null' or one of its dependencies.


I cannot think of any problems. One possibility I guess is the .NET platform inconsistent. As I remembered, Wealth-lab can be run with .NET 2.0 or 3.5. Actually I have both platforms, and I am not sure how to configure the target platform of Wealth-lab.

Later, I tried to compile my AlgLib in both .NET 3.5 and 2.0, I got the same run time error in Wealth-Lab. However, if I use the AlgLib.DLL in SharpDevelop environment, it has no this run-time error.

Did I miss anything?
profile picture

Eugene

#2
.NET 3.5 is OK for use with WL6. As mentioned in the Wiki FAQ, only 4.0 is not OK. A couple of ideas:

1. Place AlgLib.DLL into the WLP's main folder. Then don't add a Reference (Wealth-Lab will find it.)
2. Some assembly on which AlgLib.DLL depends (if there's one), might be missing. Make sure it was copied to the main folder as well.
profile picture

Cone

#3
If you can't get your compilation to work, try using mine - click here to download.
profile picture

Eugene

#4
Note that it's a better idea to post such questions under "General" or "Extensions", rather than here - "Trading Strategies". This place is for discussing actual strategies with real code rather than some technical issues with a 3rd party library that may have a connection to a Strategy (or may not).
profile picture

wbzhang

#5
Thanks. Eugene and Cone.

QUOTE:
1. Place AlgLib.DLL into the WLP's main folder. Then don't add a Reference (Wealth-Lab will find it.)


That solves the problem. It is a little bit tricky that other directories wont work.
profile picture

Eugene

#6
QUOTE:
It is a little bit tricky that other directories wont work.

...with this library. I remember a case like this a couple years from now, just couldn't find the thread.
profile picture

sedelstein

#7
Hello Cone

I downloaded the .dll file in your post above #3

I assume that all I need in WL is to say

CODE:
Please log in to see this code.


I've put the dll file where all the other dll's for WL are kept (e.g. TASCIndicators, etc...)

When I compile I get an error that the type or namespace could not be found.

Is this perhaps because your post was from Oct-2010 and it is "old" and needs to be recompiled?
Any thoughts appreciated
profile picture

Eugene

#8
There's no such namespace. This will work:

CODE:
Please log in to see this code.


To peek inside an assembly for this purpose you might want to use Visual Studio's Object Browser or similar tool.
profile picture

sedelstein

#9
Indeed it does. The .dll file contained caps so I made an assumption

Thanks again
profile picture

tomphm

#10
Hello Eugene & Cone,

I downloaded the ALGLIB from Cone's post above and place the file in the WLP6 main directory (C:\Program Files\Fidelity Investments\Wealth-Lab Pro 6) and included the statement "using alglib;" in my strategy and still couldn't get it compiled. When I compile it has an error "The type or namespace name 'alglib' could not be found". This is strange and should work from the posts above - did I do something wrong? Thank you.
profile picture

Eugene

#11
Close WLP, find the new DLL file in the WLP6 main directory, right-click it, uncheck "File downloaded from the internet", make sure to click Apply/OK, restart WLP.
profile picture

tomphm

#12
Eugene, thanks for the quick reply. I closed WLP, removed the blocking due to "File downloaded from the internet" flag (and made sure I have the right permission to do that), open WLP and still got the same compile error. Other suggestions? Thanks.
profile picture

Eugene

#13
See my post #8 with the correct syntax, not #7 with the wrong one you're trying to use.
profile picture

tomphm

#14
Eugene,

That works! Now I downloaded and replaced the old dll with a more recent version - alglibnet2.dll. Using the same directive statement - "using alglib", I got a compiled error: "A using namespace directive can only be applied to namespaces; 'alglib' is a type not a namespace". My guess is that they must change 'alglib' to a type within the new dll and the new namespace have been changed to something else. If this is the case, based on your post #8, I should use a 'Visual Studio's Object Browser or similar tool' to look inside the dll file to learn its new namespace. Is this guess correct? Thank you.
profile picture

Eugene

#15
Usually, sites of developers have an online usage guide section where you can browse for a usage sample and/or calling convention.
profile picture

tomphm

#16
They changed it to a class type. thanks to your post #8, I was able to see the correct names and dependencies. Thanks again.
profile picture

tomphm

#17
Eugene,

I am re-posting this question here - am still could not understand and resolve it. I got a compiled error in Visual Studio when using a DllImport() like the one shown below.
Error: The name 'alglib' does not exist in the current context

Declaration:
CODE:
Please log in to see this code.


Function call:
CODE:
Please log in to see this code.


The same code syntax is work fine when compiled within WLP. Thanks for any suggestions you can give.
profile picture

Eugene

#18
Maybe you have not referenced the DLL? Or declared the variable inside a block?

Compiler Error CS0103
The name 'ablas' does not exist in the current context
profile picture

tomphm

#19
Thanks Eugene. In VS adding reference is done via the GUI (Project --> Add Reference) rather than using the DllImport seems to work better - at least for me.
profile picture

Eugene

#20
I don't think that DllImport, which is used for calling unmanaged code, is a substitute for directly referencing a .NET assembly which alglib is.
profile picture

rmandel00

#21
I downloaded the ALGLIB.dll file (12/16/09 552KB) in WLP's main folder (C:/programfiles/MS123/Wealth-Lab Developer 6).

I am trying to call some functions in a strategy containing alglib, e.g.
corr = alglib.pearsoncorr2(x, y, i);

The alglib statement is underlined in red and states:
The name alglib does not exist in the current context.

When I compile I get compile errors for each call on alglib to the effect, for example:
The type or name space pearsoncorr2 does not exist in the name space alglib (are you missing an assembly reference?)

I checked my for the version of .Net Framework installation and version 4.7 or newer is installed.
Please help as I need to do matrix and statistical operations in my strategy.

I migrated from Fidelity and WLD on 7/25/20 just in case that makes a difference.

Thanks,
Rich Man
profile picture

Eugene

#22
Please review this topic for insights. Let us know if issue persists. Thanks.
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).