Simple Bartender .net Application With Visual Studio 2013
Follow the below steps in order to create a simple Windows form application that integrates with BarTender.
1. From within Visual Studio select the "File>New Project" menu item. Select the "Visual C#>Windows Desktop" template type, and then choose the ,"Windows Forms Application" item. Specify a unique name and location for the project and click OK.

2. In the "Solution Explorer" for the project double click on the solution's "Properties" to configure the solution's settings.

Choose the target framework you wish to work with for your solution. The default, ".NET Framework 4.5" is acceptable, but you make select frameworks 4.5.1 or 3.5 if you prefer.

As BarTender is currently only available as a 32 bit (x86) application you'll need to specify this under the "Build" section on the solution properties. Failure to set this appropriately will cause an error on an x64 computer system.

If you selected the .NET Frameworks 4.5 or 4.5.1 in the solution properties you'll need to make a small alteration to the app configuration. To do this, double click the "App.config" file from the Solution Explorer and add the, "useLegacyV2RuntimeActivationPolicy" attribute to the <startup> tag giving it a value of "true". See below an example of this:
In order for your application to integrate with BarTender a reference should be added to the project for the BarTender .NET component, which is listed as "Seagull.BarTender.Print" in the "Assemblies>Extensions" list. Tck the checkbox alongside it and click OK.

In the form designer view add a command button to the form and then double click it to edit the underlying code.

To start, add a using reference to the "Seagull.BarTender.Print" component at the beginning of the code alongside other using statements, thus bringing the BarTender class into scope.
Enter in your BarTender specific automation code into the contents of the button's click event. In the below example we create a BarTender engine instance, start it, define an application window making it visible, pause for five seconds, and then lastly, stopping the BarTender engine instance.
Save all your work and test run the project by clicking the "Start" button in the toolbar of Visual Studio.
Enjoy!
-
Hi Ian, this didn't work for me when running as 32bit app. I had to change it to a 64bit app - noticed that the dll was taken from "Program Files" folder not "Program Files x86"
0 -
Dwayne: The above instructions were for older BarTender releases (v10.1 or before), and thus does not apply to BarTender 2016 where much of these details changed due to the introduction of an x64 application and our targeting of the v4.0 .NET framework.
0 -
Hi, Ian, I got this to work, do you have an example of it bringing up a label and printing it.Thanks Don
0 -
I am using a old version --- so this worked fine.
0
请先登录再写评论。
评论
4 条评论