Visual C# Assembly
Author: QuinnHarris
Creation Date: 3/8/2010 5:57 PM
profile picture

QuinnHarris

#1
I am trying to use Microsoft Visual C# 2008 Express edition to create a .NET 2.0 assembly to be used by Wealth lab to share some code between many strategies. I have been able to compile my code that references WealthLab types (by adding references to the wealth lab assemblies (DLL's) to the project). But when I attempt to write a strategy in WealthLab that uses the classes in the assembly I created I get the following error after clicking "Compile"

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

************** Exception Text **************
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at WealthLab.WealthScriptCompiler.CompileSource(String references)
at dx.k(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.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
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.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


I am probably missing something simple. Any ideas what is wrong?

Are there some instructions somewhere on how to make assemblies for use in WealthLab with MS tools?
Is there a different way to share code between many strategies?

Thanks,
Quinn
profile picture

Eugene

#2
Pretty weird. It probably means that some of the classes in your library cannot be loaded.

You need to tell us which Wealth-Lab version and build you're using and give us an idea about the assemblies referenced in your project, which .NET framework they belong to (3.5, 2.0 etc), how does the code look like etc.
profile picture

Cone

#3
QUOTE:
Is there a different way to share code between many strategies?
Sure. Follow the link on the home page to the WL5 Wiki, and look at all of the "Community" source code that is available to you.

(You can add to the Community source, or simply use it by installing the Extension.)
profile picture

QuinnHarris

#4
I am using Wealthlab 5.6.20.0359653 with Visual C# 2008 Express Edition 9.0.30729.1

In Visual C# the project is set to use .NET Framework 2.0 (is this correct) and is the only change from the default "Class Library" template. The only .cs file contains the following

CODE:
Please log in to see this code.


All References in the project to other assemblies have been removed except "System"

In the Wealthlab strategy a reference to the compiled DLL file was added under "Other Assemblies to Reference".

The Strategy will compile until one of the classes in the Assembly is inherited at which point I get the error described above.

The following Strategy code will product that error:

CODE:
Please log in to see this code.


This appears to only happen if I try to create a class that inherits from a class in the assembly. So, the following strategy code will compile without error.

CODE:
Please log in to see this code.


Any ideas?
profile picture

Eugene

#5
Thanks for the explanation. I was unable to reproduce the error. What I did was compiling the Strategies.ActiveTrader library with your "MyClass", and then inheriting it:
CODE:
Please log in to see this code.

No problems, it compiles and runs without an exception. Try taking Strategies.ActiveTrader as the sandbox.
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).