Visual Studio Development Bookmark and Share   
 index > Visual C# Express Edition > Redistributing Brother printer application with msm thingie?
 

Redistributing Brother printer application with msm thingie?

Hi all,
New to this forum - I have tried searching the web and msdn for an answer but haven't found any, so now I have signed up to this forum instead! Please notice: I'm very much new to C#, Visual studio and developing in this environment - my background is Java, php and the like - so I'm sorry if this is very basic or if I have missed this information somewhere else...!

I'm using Visual C# 2008 express edition and am developing a client program that uses my Brother QL-560 label printer. It fetches orders from an e-store (through MySqlConnection, works great) and then prints these orders on my locally attached label printer. I have installed Brother b-PAC SDK which gives me access to a BrssCom COM object that I have included in my project (References). Works nicely, but strangely enough only on the first occasion!

That is, I first install the b-PAC SDK on my computer, then work on my project and debug and publish and then the printer responds nicely. But when I turn off my computer, get back the other day, get back to Visual C# and my project, printing doesn't work anymore! Instead, Windows tries to install this component.

Understanding that the problem is that the Brother component isn't included in my project, I found info on brothers homepage (http://www.brother-usa.com/Ptouch/Software/BPAC/FAQs.aspx#faq12) that I need to add BrssCom.msm to the Windows installer project. Of course, the SDK is not for redistribution - instead the BrssCom.msm is what should be included in the project.

Does this mean I need the separate Visual Studio Installer program to create a redistributable version of my application - is that how I can include a .msm file into a installer file? Or can I somehow include this BrssCom.msm file into my project in Visual C# 2008 Express Edition so it gets included when I publish it (through Build/Publish menu option) - and how do I include it? I have tried adding the distributable BrssCom.msm file to the project (as Resources - "BrssCom" is already added as a reference and works fine in the first instance (see above).

Yours,
Carl
Ekoman  Sunday, March 22, 2009 7:36 PM
A .msm file is an MSI merge module. You cannot create MSI installers with the Express edition. You'll have to purchase a license for the retail edition.
Hans Passant.
nobugz  Sunday, March 22, 2009 8:38 PM
Interop.BrssCom.dll is not the COM component. It is a so-called interop assembly that .NET needs to be able to use the COM component. You must copy it along with your .exe to the target machine. The actual COM DLL, and its support DLLs, is probably copied somewhere in the c:\program files folder.

Printer manufacturers are not usually very picky about how their drivers get distributed. They are selling printers, not software. If you got it installed on your machine, surely it could be installed on another machine. If you paid for it, you almost certainly can't distribute it.
Hans Passant.
nobugz  Sunday, March 22, 2009 9:43 PM
If you found it back in Add Reference then it got installed. COM components need to be registered, that creates entries in the HKCR\CLSID registry key. Visual Studio searches that key for COM components that advertise themselves to be available to other programs, then shows them in the list you see.

You don't have to do anything to make the COM component available if it only gets used on your own machine. It is available "at large". But of course only to programs that know how to use COM components and were designed to take advantage of BrssCom in particular. Odds are low you have any, other than the shovelware that came with the printer.

There's no good way to tell what all those other DLLs are used for. It's not unlikely they are needed to make the COM component work. They might also have written to make other specific programs work with the printer. Like a Japanese version of Quick Books.

Hans Passant.
nobugz  Sunday, March 22, 2009 10:52 PM
Wow - I'm learning heaps here! Thanks a bunch!

Well, then it's strange that everytime I try running the program (after publishing and installing it), it starts looking for the Brother SDK and tries to install it.

However, I think I have solved it in a different way. The thing is: previously, I have used a web interface for managing my e-store. What I then did was copy-and-paste the address labels to the "shovelware" for my label printer. So I wanted to automate this procedure - so I started working with this client program that will 1) notify me on incoming orders, and 2) allow me to print the labels - i.e. all without the web interface.

Now, however, I have written some javascript (IE only) that activates and uses the BrssCom object. Now, in my web interface, I have a new print link for each incoming order, which prints the label directly through my browser interface!

And that really does the trick for me!

Still - I'll modify my C# program as it is great for keeping track on incoming orders. A nifty little notifyIcon in the taskbar changes when a new order has come in. (I solve this with a timer-ticker that connects to the MySql-database on the e-store, through the MySql.Data object, which works great).

So - I'll keep using the web interface for shop management, now as it also has print-out-capabilities directly through the ActiveX component!

THANKS a bunch for your info - I'm definitely gonna stay on this brilliant forum!
Ekoman  Sunday, March 22, 2009 11:33 PM
A .msm file is an MSI merge module. You cannot create MSI installers with the Express edition. You'll have to purchase a license for the retail edition.
Hans Passant.
nobugz  Sunday, March 22, 2009 8:38 PM
Thanks very much for your answer!

Ouch. That's a bit steep, especially as I only will use this application for my own purposes.

I looked closer at the properties for the actual COM object - BrssCom - in Visual Studio and found the path to the dll - Interop.BrssCom.dll - that is copied to the output directory. How come this dll file isn't enough for the program to work?
Ekoman  Sunday, March 22, 2009 9:12 PM
Interop.BrssCom.dll is not the COM component. It is a so-called interop assembly that .NET needs to be able to use the COM component. You must copy it along with your .exe to the target machine. The actual COM DLL, and its support DLLs, is probably copied somewhere in the c:\program files folder.

Printer manufacturers are not usually very picky about how their drivers get distributed. They are selling printers, not software. If you got it installed on your machine, surely it could be installed on another machine. If you paid for it, you almost certainly can't distribute it.
Hans Passant.
nobugz  Sunday, March 22, 2009 9:43 PM
Okay. Once again, thanks a lot! I'm quite new to the .NET environment so I'm well aware that these questions might be very basic, and thus even more grateful for your helpful comments!

The thing is, I got everything installed on the same PC machine: Visual C# Express, the label printer, the printer software (that came with it), the SDK for developing printer stuff. After I had installed the Brother SDK, I found the BrssCom component in the Project/Add reference/COM tab list. But still, this doesn't mean that the COM object itself is really installed on my machine, right?

As I only will be using this program on this very same machine, isn't it possible to make this COM object available to the machine "at large"?

Edit: along with the printer, I got Brother's own software along for printing labels - got this installed as well on my computer. In this program folder are a lot of dll:s. But these are, I guess, not related to the COM object in question?
Ekoman  Sunday, March 22, 2009 9:57 PM
If you found it back in Add Reference then it got installed. COM components need to be registered, that creates entries in the HKCR\CLSID registry key. Visual Studio searches that key for COM components that advertise themselves to be available to other programs, then shows them in the list you see.

You don't have to do anything to make the COM component available if it only gets used on your own machine. It is available "at large". But of course only to programs that know how to use COM components and were designed to take advantage of BrssCom in particular. Odds are low you have any, other than the shovelware that came with the printer.

There's no good way to tell what all those other DLLs are used for. It's not unlikely they are needed to make the COM component work. They might also have written to make other specific programs work with the printer. Like a Japanese version of Quick Books.

Hans Passant.
nobugz  Sunday, March 22, 2009 10:52 PM
Wow - I'm learning heaps here! Thanks a bunch!

Well, then it's strange that everytime I try running the program (after publishing and installing it), it starts looking for the Brother SDK and tries to install it.

However, I think I have solved it in a different way. The thing is: previously, I have used a web interface for managing my e-store. What I then did was copy-and-paste the address labels to the "shovelware" for my label printer. So I wanted to automate this procedure - so I started working with this client program that will 1) notify me on incoming orders, and 2) allow me to print the labels - i.e. all without the web interface.

Now, however, I have written some javascript (IE only) that activates and uses the BrssCom object. Now, in my web interface, I have a new print link for each incoming order, which prints the label directly through my browser interface!

And that really does the trick for me!

Still - I'll modify my C# program as it is great for keeping track on incoming orders. A nifty little notifyIcon in the taskbar changes when a new order has come in. (I solve this with a timer-ticker that connects to the MySql-database on the e-store, through the MySql.Data object, which works great).

So - I'll keep using the web interface for shop management, now as it also has print-out-capabilities directly through the ActiveX component!

THANKS a bunch for your info - I'm definitely gonna stay on this brilliant forum!
Ekoman  Sunday, March 22, 2009 11:33 PM
Hi there,

I am reading all your threads and still cannot apply with my own issue.

Please guide me if you can.

Here is my situation.

I am using Visual Studio 2005 .NET 2.0 Framework C# with SQL SERVER 2005.

I have to build a web app that runs on client and on the server and need to be able to print to P-Touch 9500PC label printer.

Iam able toprint to label printer viathe web app that run on client (IIS)(http://localhost/...)but not the one on the server when I go www.mydomain.com to the page that I has a button to print to label.

I already installed printer driver on the server. I pointed to where my label templates locate on.

I also went to http://www.aspfaq.com/downloads/ASPFAQ-2006-04-18.pdfon page 664-665 and tried to do but still does not work.


I tried all these path

http:\\www.mydomain.net\LabelTemplates\

http:\\\\www.mydomain.net\\LabelTemplates\\

http://www.mydomain.net/LabelTemplates/

http:////www.mydomain.net//LabelTemplates//


while the path is @"C:\Inetpub\wwwroot\xTrak\LabelTemplates\"; on my client one.


Please help me to post the solution or suggestionshere or email me to popgugu@gmail.com. It will be much appreciated.



The last time I got this error.


Server Error in '/xTrakDev' Application.

--------------------------------------------------------------------------------

Retrieving the COM class factory for component with CLSID {7979FAA5-3A2A-4E50-A2C9-286C6F34C1D3} failed due to the following error: 8000401a.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {7979FAA5-3A2A-4E50-A2C9-286C6F34C1D3} failed due to the following error: 8000401a.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

Sompop  Saturday, April 11, 2009 1:29 AM
Sorry to bring up an old topic. Ekoman, can you post how you got the BrssCom object to print to you local printer through the web browser? I too have tried some javascript through IE and it still does not print to the local printer.
Daniel Yee  Wednesday, August 12, 2009 5:43 PM
Hi!
Just got an email alert regarding this thread so I'll try to explain!

<script language="javascript" type="text/javascript">
var labelPath="C:\\mylabel.lbl"; //Static path to my label
<br/>
function print(line_0,line_1,line_2) {
	var docObj = new ActiveXObject("BrssCom.Document");
	if (docObj.Open(labelPath))
	{
		docObj.SetText(0,line_0);
		docObj.SetText(1,line_1);
		docObj.SetText(2,line_2);
		docObj.DoPrint(0,"");
		docObj.Close();
	}
	else {
		alert('Error opening '+labelPath);
	}
}
</script>

that is, on my web page, I call the above function with input. It thus reads the label (placed on a static location on your hd), sets the text and then prints it.

Good luck!
Ekoman  Wednesday, August 12, 2009 6:00 PM
Did you ever get this to work? I am doing the same thing and need this to run from my web app I was useing almost the same script as you but mine dosent work. I can do it from the code behind but the printer has to be connected to the web server and thats not an option.
Shellz  Thursday, October 08, 2009 7:04 PM
It works fine for me, but I'm not having it connected to the web server - I got the printer installed on my own PC and then I just print through the web server.

I have no experience with windows web server (only *NIX-servers) so I have no idea how to make it work with a Windows server. My guess is that you have to write a server program that uses the COM component in a similar fashion, but then you are back at the original problem I had, trying to develop a C# program for printing on my QL-560 printer. And I never solved that problem as I am quite satisfied with the javascript/Com solution.
Ekoman  Thursday, October 08, 2009 7:12 PM
So the Java script you posted works?
or is it another script you are useing that works?

<script language="javascript" type="text/javascript">
var labelPath="C:\\mylabel.lbl"; //Static path to my label
<br/>
function print(line_0,line_1,line_2) {
var docObj = new ActiveXObject("BrssCom.Document");
if (docObj.Open(labelPath))
{
docObj.SetText(0,line_0);
docObj.SetText(1,line_1);
docObj.SetText(2,line_2);
docObj.DoPrint(0,"");
docObj.Close();
}
else {
alert('Error opening '+labelPath);
}
}
</script>
 My script below

var

strFilePath As String = "C:\Label\asset.lbl"

 

 

function PrintBtnClicked()

{

 

var ObjDoc;

ObjDoc =

new ActiveXObject('BrssCom.Document');

 

 

var Text0 = document.getElementById('<%= txtID.ClientID %>');

 

var Text1 = document.getElementById('<%= txtPrimeContractNum.ClientID %>');

alert(Text0.value +

' '+ Text1.value);

 

if (ObjDoc.Open('strFilePath'))

{

ObjDoc.SetText(0, Text0);

ObjDoc.SetText(1, Text1);

ObjDoc.SetText(2, Text2);

ObjDoc.DoPrint(0, 1);

ObjDoc.Close();

 

}

 

 

else

alert(

'Error: Label file Not Found!');

}

Shellz  Thursday, October 08, 2009 7:35 PM

You can use google to search for other answers

Custom Search

More Threads

• Debug and Release
• Drag Objects
• Getting modified code to compile
• Controlling 2 Rich Text Box with 1 scrollbars
• How to create user settings at runtime?
• "Universal Coordinated Time" since 01/01/2000?
• How to let the page automatic redirect to a new page
• Listbox Saving and Loading Question
• how to access the parallel port?
• C# handling multiple events