Yup I got it using the Project / ClassLibrary3 Properties / ClassLibrary3 / Build in the menu, thanks! I've been looking for something like this for awhile, glad to finally be able to use C# directly with Ami!
--- In [email protected], Steve Wong <swstevewon...@...> wrote: > > Hello Janhaus > > already register the dll? > > I register it under the VS command prompt (run as administrator if Vista) > > regasm ClassLibrary3.dll /codebase /tlb > > That's it. (if you read COM interop there is also a tool called gacutil.exe > for registering to the .NET GAC; but I tried and there is no need to register > to the GAC for Amibroker to call.) > > By the way, since this is not through the Amibroker ADK, so no getpluginfo() > is implemented. > > No need to copy the dll to the Amibroker plugin directory. (Because it's > regasm'ed already) > > Rdgs > SW > > > > ________________________________ > From: janhausd <janhaus.dres...@...> > To: [email protected] > Sent: Monday, May 4, 2009 11:43:21 PM > Subject: [amibroker] Re: Amibroker Plugin C# template? Anyone? > > > > > > Heya Steve, > > Thanks for providing this example, and I'd be very interested in working with > C# through Amibroker! I've given this a go and it compiles but doesn't work > as a plugin as-is. Did you have to implement the getplugininfo( ) functions > for this to work? > > --- In amibro...@yahoogrou ps.com, Steve Wong <swstevewong38@ ...> wrote: > > > > Hello, > > > > below is my experimental c# code to illustrate the original VB IIR2 example > > and the VExampleMA from the ADK. > > from the Amibroker side the object creation in AFL will be: > > > > myobj = CreateObject( "csharp.amlib1" ); > > //call method > > iir2 = myobj.IIR2(Close, 0.2,1.2,-0.4) ; > > //calling Windows Forms > > myobj.ShowDialog( "AFL called me"); > > > > // c# below > > using System; > > using System.Runtime. InteropServices; > > namespace ClassLibrary3 > > { > > [ > > Guid("16308AFC- FB7E-4cc6- 9A3B-F47B99B7F18 B"), > > InterfaceType( ComInterfaceType .InterfaceIsDual ), > > ComVisible(true) > > ] > > public interface IMyAmPlugin1 > > { > > [DispId(1)] > > string HelloAmibroker( ); > > [DispId(2)] > > int ShowDialog(string msg); > > [DispId(3)] > > object IIR2( object input, float f0, float f1, float f2); > > [DispId(4)] > > object MyExampleMA( object input, int range); > > }; > > [ > > Guid("4328EB81- CFFF-423b- B1B4-D5B1F1AC76B 7"), > > ProgId("csharp. amlib1"), > > ClassInterface( ClassInterfaceTy pe.None), > > ComDefaultInterface (typeof(IMyAmPlu gin1)), > > ComVisible(true) > > ] > > public class Class1 : IMyAmPlugin1 > > { > > private const float EMPTY_VAL = -1e10f; > > public string HelloAmibroker( ) > > { > > return "Hello Amibroker, I'm from C#"; > > } > > public int ShowDialog(string msg) > > { > > > > System.Windows.. Forms.MessageBox .Show(msg, ""); > > return 0; > > } > > public object IIR2(object input, float f0, float f1, float f2) > > { > > object[] inputArray = (object[]) input; > > object[] outputArray = inputArray; > > outputArray[ 0] = inputArray[0] ; > > outputArray[ 1] = inputArray[1] ; > > for (int i = 2; i < inputArray.Length; i++) > > { > > outputArray[ i] = f0 * Convert.ToSingle( inputArray[ i]) + > > f1 * Convert.ToSingle( outputArray[ i - 1]) + f2 * > > Convert.ToSingle( outputArray[ i - 2]); > > } > > return outputArray ; > > } > > private int SkipEmptyValues( int nSize, object[] srcArray, object[] > > result) > > { > > int i; > > for (i = 0; i < nSize && (Convert.ToSingle( srcArray[ i]) == > > EMPTY_VAL); i++) > > { > > result[i] = EMPTY_VAL; > > } > > return i; > > } > > public object MyExampleMA( object input, int range) > > { > > object[] inputArray = (object[]) input; > > int nSize = inputArray.Length; > > object[] result = new object[nSize] ; > > int j = SkipEmptyValues( nSize, inputArray, result); > > for (int i = j; i < nSize; i++) > > { > > if (i < j + range) > > { > > result[i] = EMPTY_VAL; > > continue; > > } > > float sum = 0.0f; > > for (int k = 0; k < range; k++) > > { > > sum += Convert.ToSingle( inputArray[ i - k]); > > } > > result[i] = sum / range; > > } > > return result; > > } > > } > > } > > > > Regards > > SW > > > > > > > > ____________ _________ _________ __ > > From: Yofa <jtoth100@ .> > > To: amibro...@yahoogrou ps.com > > Sent: Monday, May 4, 2009 4:06:32 AM > > Subject: Re: [amibroker] Amibroker Plugin C# template? Anyone? > > > > > > > > > > > > Hi Dan, > > > > 1. make the c# code a "COM visible" component. > > 2. Register it on the AB machine. > > 3. write c++ plugin to access it as a COM component. (Use ADK) > > > > Y > > > > ------------ --------- --------- --------- --------- -- > > From: "ccr1der" <d...@hottuna. com> > > Sent: Thursday, April 30, 2009 7:46 AM > > To: <amibro...@yahoogro u ps.com> > > Subject: [amibroker] Amibroker Plugin C# template? Anyone? > > > > > Does anyone have a C# based template for AB plugins? Has anyone ever > > > compiled a C# plugin for AB? I have a very important piece of code in C# > > > that I need accessible from within AB, and while I'm not at all well > > > versed in C#, I'm willing to take a stab at trying to get this to > > > work.... > > > but I need some kind of a starting point? > > > > > > Any help would be greatly appreciated. Thanks. > > > > > > -Dan > > > > > > > > > > > > > > > ------------ --------- --------- ------ > > > > > > **** IMPORTANT PLEASE READ **** > > > This group is for the discussion between users only. > > > This is *NOT* technical support channel. > > > > > > TO GET TECHNICAL SUPPORT send an e-mail directly to > > > SUPPORT {at} amibroker..com > > > > > > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at > > > http://www.amibroker.com/feedback/ > > > (submissions sent via other channels won't be considered) > > > > > > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: > > > http://www.amibroker.com/devlog/ > > > > > > Yahoo! Groups Links > > > > > > > > > > > > > > >
