Hi all,
With all the problems I was having with the Brother printer COM server, I thought I'd try writing my own in C# (VS2015). Mine is very simple right now. It just prints a sample label. I wrote a second C# console program to test... works fine. Demonstrating to myself that the Brother COM object works as advertised, just not in PB. The label prints as expected. (Sorry, I forget the reason why I had to go from a simple dll to a com object.)
I found a similar question in Q&A from about 4 years ago. Rodolfo Reyes provided a great link that shows how to make and install a COM object from VS.
http://blogs.artinsoft.net/Mrojas/archive/2009/03/03/Calling-NET-from-PowerBuilder.aspx
I followed all of the directions... but in my PB app I keep getting error code -2: Class name not found when I'm trying to connect to the object.
OLEObject label
int li_rc
boolean lb_rc
label = CREATE OLEObject
li_rc = label.ConnectToNewObject("PTouch.PTouch")
if li_rc<> 0 then
MessageBox("Error","Component Installation Error: " + string(li_rc))
else
lb_rc = label.PrintLabel()
end if
destroy label
return
In VS2015, I've got a Namespace named "PTouch" and I've got a Class named "Ptouch" and I have a Method named "PrintLabel".
namespace PTouch
{
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("PTouch:PTouch")]
public class PTouch
{
private bool lb_rc = false;
private string strLabel = "";
public bool PrintLabel()
{
strLabel = "C:\\BenchTop10\\Standard 1in.lbx";
bpac.Document doc = new Document();
etc...
Here's the PB Code...
OLEObject label
int li_rc
boolean lb_rc
label = CREATE OLEObject
li_rc = label.ConnectToNewObject("PTouch.PTouch")
if li_rc<> 0 then
MessageBox("Error","Component Installation Error: " + string(li_rc))
else
lb_rc = label.PrintLabel()
end if
destroy label
return
Any ideas why I'm getting Error -2, Class Name not Found?
~~~Tracy